cgcontext

iPhone CGContextRef CGBitmapContextCreate unsupported parameter combination

ε祈祈猫儿з 提交于 2019-11-26 23:21:45
问题 In my application I need to resize and crop some images, stored locally and online. I am using Trevor Harmon's tutorial which implements UIImage+Resize . On my iPhone 4(iOS 4.3.1) everything works OK, I have no problems. But on my iPhone 3G (iOS 3.2) the resizing and crop methods are not working for any picture (the locally stored ones are PNGs). This is the console output: Tue Apr 5 02:34:44 Andreis-MacBook-Pro.local Puzzle[12453] <Error>: CGBitmapContextCreate: unsupported parameter

‘invalid context 0x0’ error when using CGContext* functions

末鹿安然 提交于 2019-11-26 21:53:43
问题 /* Adding the Path */ UserGraphBuff = UIGraphicsGetCurrentContext(); CGContextSetRGBStrokeColor(UserGraphBuff,5,10,0,1); CGContextSetLineWidth(UserGraphBuff, 2 ); CGContextBeginPath(UserGraphBuff); //line to last user point CGContextAddLineToPoint(UserGraphBuff, (*xVal)[sizeof xVal / sizeof *xVal - 1], (*yNewVal)[sizeof yNewVal / sizeof *yNewVal - 1]); //line to rest of user points in reverse order for (int i = sizeof xVal / sizeof *xVal - 1; i > -1; i--){ CGContextAddLineToPoint

UIGraphicsGetImageFromCurrentImageContext memory leak with previews

佐手、 提交于 2019-11-26 20:43:51
I'm trying to create previews images of pages in a PDF but I have some problems with the release of memory. I wrote a simple test algorithm that cycles on the problem, the app crashes near the 40th iteration : NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:@"myPdf.pdf"]; CFURLRef url = CFURLCreateWithFileSystemPath( NULL, (CFStringRef)pdfPath, kCFURLPOSIXPathStyle, NO ); CGPDFDocumentRef myPdf =

Doing Undo and Redo with Cglayer Drawing

懵懂的女人 提交于 2019-11-26 18:37:49
问题 I am working with a drawing app, I am using CGlayers for drawing. On touches ended, I get image out of the layer and store it in a Array, which I use to undo operation. My touches ended function -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"Touches ended"); UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextDrawLayerInRect(context, self.bounds, self.drawingLayer); m_curImage =

Make 2 contradictory methods work in drawRect

a 夏天 提交于 2019-11-26 17:17:21
问题 I'm writing an app building elements consisting of CGPoints. I have 2 buttons: makeRectangle and makeTriangle . For building/drawing stage I use three methods for rectangle and three methods for triangle inside drawRect . I'm stuck with my code in drawRect . In if-else-statement each method swaps the building/drawing scheme for previous element every time a button pressed. If I already have built rectangle and then I click makeTriangle button, I get new triangle but my rectangle turns into

Cut transparent hole in UIView

有些话、适合烂在心里 提交于 2019-11-26 16:15:42
Looking to create a view that has a transparent frame inside of it so that the views behind the view can be seen through this transparent frame, but areas outside of this will not show through. So essentially a window within the view. Hoping to be able to do something like this: CGRect hole = CGRectMake(100, 100, 250, 250); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [UIColor blackColor].CGColor); CGContextFillRect(context, rect); CGContextAddRect(context, hole); CGContextClip(context); CGContextSetFillColorWithColor(context, [UIColor

Changing UIImage color

对着背影说爱祢 提交于 2019-11-26 11:51:24
问题 I\'m trying to change color of UIImage. My code: -(UIImage *)coloredImage:(UIImage *)firstImage withColor:(UIColor *)color { UIGraphicsBeginImageContext(firstImage.size); CGContextRef context = UIGraphicsGetCurrentContext(); [color setFill]; CGContextTranslateCTM(context, 0, firstImage.size.height); CGContextScaleCTM(context, 1.0, -1.0); CGContextSetBlendMode(context, kCGBlendModeCopy); CGRect rect = CGRectMake(0, 0, firstImage.size.width, firstImage.size.height); CGContextDrawImage(context,

UIGraphicsGetImageFromCurrentImageContext memory leak with previews

与世无争的帅哥 提交于 2019-11-26 07:42:16
问题 I\'m trying to create previews images of pages in a PDF but I have some problems with the release of memory. I wrote a simple test algorithm that cycles on the problem, the app crashes near the 40th iteration : NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:@\"myPdf.pdf\"]; CFURLRef url = CFURLCreateWithFileSystemPath

Cut transparent hole in UIView

柔情痞子 提交于 2019-11-26 04:45:41
问题 Looking to create a view that has a transparent frame inside of it so that the views behind the view can be seen through this transparent frame, but areas outside of this will not show through. So essentially a window within the view. Hoping to be able to do something like this: CGRect hole = CGRectMake(100, 100, 250, 250); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [UIColor blackColor].CGColor); CGContextFillRect(context, rect);