cgbitmapcontextcreate

How do I create an alpha only bitmap context

廉价感情. 提交于 2019-11-30 23:44:13
问题 Apple tech note QA1037 says "To create an alpha-only bitmap context simply pass NULL for the colorspace parameter." However, I am not sure what to pass for the bitmapInfo parameter. I was trying something like this, with kCGImageAlphaOnly: CGContextRef ctx = CGBitmapContextCreate(NULL, scaledSize.width, scaledSize.height, 8, scaledSize.width, NULL, kCGImageAlphaOnly); But this gives me an warning about the enum being wrong. What should I put there instead? 回答1: The docs clearly state you can

UIGraphicsBeginImageContext vs CGBitmapContextCreate

爷,独闯天下 提交于 2019-11-30 10:15:45
I'm trying to change color of an image in a background thread. Apple doc says UIGraphicsBeginImageContext can only be called from main thread, and I'm trying to use CGBitmapContextCreate: context = CGBitmapContextCreate (bitmapData, pixelsWide, pixelsHigh, 8, // bits per component bitmapBytesPerRow, colorSpace, kCGImageAlphaPremultipliedFirst); I have two versions of "changeColor" first one using UIGraphisBeginImageContext, second one using CGBitmapContextCreate. The first one correctly changes color, but second one doesn't. Why is that? - (UIImage*) changeColor: (UIColor*) aColor { if(aColor

iPhone: Changing CGImageAlphaInfo of CGImage

淺唱寂寞╮ 提交于 2019-11-28 17:16:01
I have a PNG image that has an unsupported bitmap graphics context pixel format. Whenever I attempt to resize the image, CGBitmapContextCreate() chokes on the unsupported format I receive the following error (error formatted for easy reading): CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component colorspace; kCGImageAlphaLast; 1344 bytes/row. The list of supported pixel formats definitely does not support this combination. It appears I need to redraw the image and move the alpha channel information to kCGImageAlphaPremultipliedFirst or

UIView: how to do non-destructive drawing?

拈花ヽ惹草 提交于 2019-11-28 05:28:34
My original question: I'm creating a simple drawing application and need to be able to draw over existing, previously drawn content in my drawRect . What is the proper way to draw on top of existing content without entirely replacing it? Based on answers received here and elsewhere, here is the deal. You should be prepared to redraw the entire rectangle whenever drawRect is called. You cannot prevent the contents from being erased by doing the following: [self setClearsContextBeforeDrawing: NO]; This is merely a hint to the graphics engine that there is no point in having it pre-clear the view

iPhone CGContextRef CGBitmapContextCreate unsupported parameter combination

匆匆过客 提交于 2019-11-27 23:47:18
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 combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaLast; 288 bytes

iPhone: Changing CGImageAlphaInfo of CGImage

﹥>﹥吖頭↗ 提交于 2019-11-27 10:21:43
问题 I have a PNG image that has an unsupported bitmap graphics context pixel format. Whenever I attempt to resize the image, CGBitmapContextCreate() chokes on the unsupported format I receive the following error (error formatted for easy reading): CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component colorspace; kCGImageAlphaLast; 1344 bytes/row. The list of supported pixel formats definitely does not support this combination. It appears I

How to create a CGBitmapContext which works for Retina display and not wasting space for regular display?

随声附和 提交于 2019-11-27 01:02:41
问题 Is it true that if it is in UIKit, including drawRect , the HD aspect of Retina display is automatically handled? So does that mean in drawRect , the current graphics context for a 1024 x 768 view is actually a 2048 x 1536 pixel Bitmap context? ( Update: if I create an image using the current context in drawRect and print its size: CGContextRef context = UIGraphicsGetCurrentContext(); CGImageRef image = CGBitmapContextCreateImage(context); NSLog(@"width of context %i", (int) CGImageGetWidth

UIView: how to do non-destructive drawing?

霸气de小男生 提交于 2019-11-27 00:57:13
问题 My original question: I'm creating a simple drawing application and need to be able to draw over existing, previously drawn content in my drawRect . What is the proper way to draw on top of existing content without entirely replacing it? Based on answers received here and elsewhere, here is the deal. You should be prepared to redraw the entire rectangle whenever drawRect is called. You cannot prevent the contents from being erased by doing the following: [self setClearsContextBeforeDrawing:

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

CGBitmapContextCreate with kCGImageAlphaNone

╄→尐↘猪︶ㄣ 提交于 2019-11-26 22:50:42
问题 I desperately need to create a CGContextRef WITHOUT an alpha channel. Unfortunately, with Core Graphics you CANNOT specify kCGImageAlphaNone with CGBitmapCreateContext. Can someone PLEASE post a working example of how I can create a CGContextRef WITHOUT an alpha channel? The reason I need this is because I'm ultimately trying to call CGImageCreateWithMaskingColors, which, of course, will NOT work if the CGImageRef provided has an alpha channel. Please post a working example. If you do you can