quartz-graphics

CGImageCreateWithMask works great but the masked out area is black in my resulting image, how can I set it to be white?

只谈情不闲聊 提交于 2019-11-30 15:55:12
问题 I've masked out my image thusly: CGImageRef maskRef = [[UIImage imageNamed:@"testMask2.png"] CGImage]; CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef), CGImageGetHeight(maskRef), CGImageGetBitsPerComponent(maskRef), CGImageGetBitsPerPixel(maskRef), CGImageGetBytesPerRow(maskRef), CGImageGetDataProvider(maskRef), nil, YES); UIImage *image = [UIImage imageWithContentsOfFile:path]; CGImageRef masked = CGImageCreateWithMask([image CGImage], mask); imageView.image = [UIImage

CGImageCreateWithMask works great but the masked out area is black in my resulting image, how can I set it to be white?

懵懂的女人 提交于 2019-11-30 14:48:34
I've masked out my image thusly: CGImageRef maskRef = [[UIImage imageNamed:@"testMask2.png"] CGImage]; CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef), CGImageGetHeight(maskRef), CGImageGetBitsPerComponent(maskRef), CGImageGetBitsPerPixel(maskRef), CGImageGetBytesPerRow(maskRef), CGImageGetDataProvider(maskRef), nil, YES); UIImage *image = [UIImage imageWithContentsOfFile:path]; CGImageRef masked = CGImageCreateWithMask([image CGImage], mask); imageView.image = [UIImage imageWithCGImage:masked]; And it works great, but the resulting image has BLACK where it was masked out, how can

Clear CATiledLayers Cache When Changing Images

╄→尐↘猪︶ㄣ 提交于 2019-11-30 14:37:47
I have a UIScrollView with a single subview, a UIView backed by a CATiledLayer. All is working well with one exception: when I change images from one to another the CATiledLayer caches the previous images zoom levels. Scrolling around then displays the old image for a split second before the updated image loads. Is there any way to totally clear out the CATiledLayer's cache so it doesn't show old images? The CATiledLayer obviously knows that the backing image changed because it asks it's delegate for new tiles... I think you are making this a little more complicated than it needs to be. I

PDF Manipulation on iPhone SDK

别来无恙 提交于 2019-11-30 14:15:30
问题 I have been reading Apple's docs and they recommend using UIWebView. This is all well and good until you want to go to a page number and also search PDF's. Is there any 3rd Party libraries, (free or paid) that do this at all? As a minimum I need to be able to Search and goto a page number in a PDF. I have looked and PDFKit is not available and the Quartz methods seem limited. This is obviously possible due to the amount of PDF readers available on the app store. 回答1: It's possible to do all

Compile error trying to use CAGradientLayer

旧巷老猫 提交于 2019-11-30 13:49:52
问题 I'm trying to use CAGradientLayer and getting an unhelpful compile error. Can't figure out whats wrong. All I'm doing so far is: CAGradientLayer *gradient = [CAGradientLayer layer]; I've imported <QuartzCore/QuartzCore.h> and I'm getting the warning > _OBJC_CLASS_$CAGradientLayer referenced from: objc-class-ref-to-CAGradientLayer symbol(s) not found. I've tried clean and build but no luck and I can't seem to target anything other than 4.1 in Xcode Cheers for any help. 回答1: You didn't

Saving and restoring CGContext

◇◆丶佛笑我妖孽 提交于 2019-11-30 13:04:15
I'm trying to save and restore a CGContext to avoid doing heavy drawing computations for a second time and I'm getting the error <Error>: CGGStackRestore: gstack underflow . What am I doing wrong? What is the correct way to do this? - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); if (initialized) { CGContextRestoreGState(context); //scale context return; } initialized = YES; //heavy drawing computation and drawing CGContextSaveGState(context); } Brad Larson I think you might be misinterpreting what CGContextSaveGState() and CGContextRestoreGState() do.

drawInRect: losing Quality of Image resolution

倾然丶 夕夏残阳落幕 提交于 2019-11-30 11:16:03
I am trying to erase image using following code CGColorRef strokeColor = [UIColor whiteColor].CGColor; UIGraphicsBeginImageContext(imgForeground.frame.size); CGContextRef context = UIGraphicsGetCurrentContext(); [imgForeground.image drawInRect:CGRectMake(0, 0, imgForeground.frame.size.width, imgForeground.frame.size.height)]; CGContextSetLineCap(context, kCGLineCapRound); CGContextSetLineWidth(context, 10); CGContextSetStrokeColorWithColor(context, strokeColor); CGContextSetBlendMode(context, kCGBlendModeClear); CGContextBeginPath(context); CGContextMoveToPoint(context, lastPoint.x, lastPoint

PDF Manipulation on iPhone SDK

感情迁移 提交于 2019-11-30 10:04:29
I have been reading Apple's docs and they recommend using UIWebView. This is all well and good until you want to go to a page number and also search PDF's. Is there any 3rd Party libraries, (free or paid) that do this at all? As a minimum I need to be able to Search and goto a page number in a PDF. I have looked and PDFKit is not available and the Quartz methods seem limited. This is obviously possible due to the amount of PDF readers available on the app store. It's possible to do all that just using the Quartz calls. Quartz is obviously C-based, so it takes a moment to adjust to the lack of

Compile error trying to use CAGradientLayer

本小妞迷上赌 提交于 2019-11-30 08:39:49
I'm trying to use CAGradientLayer and getting an unhelpful compile error. Can't figure out whats wrong. All I'm doing so far is: CAGradientLayer *gradient = [CAGradientLayer layer]; I've imported <QuartzCore/QuartzCore.h> and I'm getting the warning > _OBJC_CLASS_$CAGradientLayer referenced from: objc-class-ref-to-CAGradientLayer symbol(s) not found. I've tried clean and build but no luck and I can't seem to target anything other than 4.1 in Xcode Cheers for any help. You didn't correctly add the QuartzCore framework into your project: You have to add the QuartzCore-Framework to your project.

How to rotate text drawn by Quartz on iPhone

梦想的初衷 提交于 2019-11-30 07:41:58
I want to draw some texts using Quartz. Now the app draws , but I want it to show as "0123456789". Is there any way to show its normal orientation? Here is my code: //set image view drawImage = [[UIImageView alloc] initWithImage:nil]; drawImage.frame = self.view.frame; [self.view addSubview:drawImage]; UIGraphicsBeginImageContext(self.view.frame.size); // begin // current context CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSelectFont(context, "Courier", 40, kCGEncodingMacRoman); CGFloat white[] = {1.0, 1.0, 1.0, 1.0}; CGContextSetFillColor(context, white);