Tag: cgbitmapcontextcreate

崩溃CGDataProviderCreateWithCopyOfData:vm_copy失败:状态1

我遇到以下错误崩溃: “CGDataProviderCreateWithCopyOfData:vm_copy失败:状态1”。 我有多个问题,你可以帮忙。 状态1在vm_copy中的含义是什么? 只有当我在数据拷贝的内部循环中设置一个断点时,才会发生这种崩溃。 然后恢复并删除断点。 如果没有断点,函数执行,但是我得到一个空白的图像。 我如何确保即使我没有设置断点,这样的崩溃被捕获,应用程序停止执行? 当我执行CGBitmapContextCreateImage时出现这个错误。 有谁知道如何解决这个问题? -(UIImage *) convertBitmapRGBA8ToUIImage:(UInt8**)img :(int) width :(int) height { CGImageRef inImage = m_inFace.img.CGImage; UInt8*piData = calloc( width*height*4,sizeof(UInt8)); int iStep,jStep; for (int i = 0; i < height; i++) { iStep = i*width*4; for (int j = 0; j < width; j++) { jStep = j*4; piData[iStep+jStep] […]

我如何创build一个仅有alpha的位图上下文

苹果技术说明QA1037说:“要创build一个仅alpha的位图上下文简单地通过NULL的颜色空间参数。” 但是,我不知道要传递给bitmapInfo参数。 我正在尝试这样的事情,与kCGImageAlphaOnly: CGContextRef ctx = CGBitmapContextCreate(NULL, scaledSize.width, scaledSize.height, 8, scaledSize.width, NULL, kCGImageAlphaOnly); 但是这给了我一个关于枚举错误的警告。 我应该放什么呢?

UIGraphicsBeginImageContext与CGBitmapContextCreate

我试图改变后台线程中的图像的颜色。 苹果文档说UIGraphicsBeginImageContext只能从主线程调用,我试图使用CGBitmapContextCreate: context = CGBitmapContextCreate(bitmapData,pixelsWide,pixelsHigh,8,// bits per component bitmapBytesPerRow, colorSpace, kCGImageAlphaPremultipliedFirst); 我有两个版本的“changeColor”第一个使用UIGraphisBeginImageContext,第二个使用CGBitmapContextCreate。 第一个正确地改变颜色,但第二个不是。 这是为什么? – (UIImage*) changeColor: (UIColor*) aColor { if(aColor == nil) return self; UIGraphicsBeginImageContext(self.size); CGRect bounds; bounds.origin = CGPointMake(0,0); bounds.size = self.size; [aColor set]; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextTranslateCTM(context, 0, self.size.height); CGContextScaleCTM(context, 1.0, -1.0); CGContextClipToMask(context, bounds, [self CGImage]); CGContextFillRect(context, bounds); UIImage *img = […]

如何创build一个适用于视网膜显示的CGBitmapContext,而不是为正常显示浪费空间?

如果是在UIKit,包括drawRect ,Retina显示的高清方面是自动处理的吗? 那么这是否意味着在drawRect ,1024 x 768视图的当前graphics上下文实际上是2048 x 1536像素的位图上下文? ( 更新:如果我使用drawRect的当前上下文创build图像并打印其大小: CGContextRef context = UIGraphicsGetCurrentContext(); CGImageRef image = CGBitmapContextCreateImage(context); NSLog(@"width of context %i", (int) CGImageGetWidth(image)); NSLog(@"height of context %i", (int) CGImageGetHeight(image)); 然后在新的iPad上,禁用状态栏,打印2048和1536,iPad 2将显示1024和768) 实际上,我们享受了为我们自动处理的1点= 4像素的奢华。 但是,如果我们使用CGBitmapContextCreate ,那么这些将是像素,而不是点? (至less如果我们为该位图提供数据缓冲区,则缓冲区的大小(字节数)显然不是为了更高的分辨率,而是用于标准分辨率,即使我们将NULL作为缓冲区,以便CGBitmapContextCreate处理缓冲区对于我们来说,大小可能与传入数据缓冲区的大小相同,只是标准分辨率,而不是Retina的分辨率)。 我们总是可以为iPad 1和iPad 2以及新iPad创build2048 x 1536,但是这会浪费内存,处理器和GPU功耗,因为只有新iPad需要。 所以我们必须使用if () { } else { }来创build这样一个位图上下文,我们该怎么做呢? 我们所有的代码CGContextMoveToPoint必须调整Retina显示使用x * 2和y * 2与非视网膜显示只使用x, y […]