cgimage

CGImage/UIImage lazily loading on UI thread causes stutter

My program displays a horizontal scrolling surface tiled with UIImageViews from left to right. Code runs on the UI thread to ensure that newly-visible UIImageViews have a freshly loaded UIImage assigned to them. The loading happens on a background thread. Everything works almost fine, except there is a stutter as each image becomes ...

The antialias of rotated CGImage/CGlayer seems jaggy, UIImageView's is not

I need to mask a "texture" image with a rotated greyscale image. I found out, that I have to do it with CGImages or CGlayers (if there is a simplier way using UIImageViews only, please let me know about it). My problem is simple: The antialias of any rotation-transformed CG stuff is quiet jaggy... ... but the antialias of a r...

Source of a malloc error when releasing a CGImage on iPhone OS 3.0?

I've identified a bug while developing against the iPhone OS 3.0 SDK. Basically, if I create a CGImage from a bitmap image context, I get the following error when I release it: malloc: *** error for object 0x1045000: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug Here's the relevant code: CG...

How do I blur a CGImage, or UIImageView

I have a UIImageView with a .png inside it. I want to blur the image during runtime. How do I do that? ...

Cocoa Touch - How to cache a CGImageRef or UIImage (not using imageNamed:)?

I have a lot of images in my app so I decided to do some loading in a background thread, and since UIKit isn't thread-safe, I filled arrays with CGImageRefs. However, they are not cached and I need to be able to access them fast so my question is: How to cache CGImageRef, or cache the UIImage derived from it later on in the main thread?...

How do i turn a UIImageVew or the image in it into a CGImage, and then back again?

I just don;t know how to do this. I want more flexibility to edit the image ...

UIImage created from CGImageRef fails with UIImagePNGRepresentation

I'm using the following code to crop and create a new UIImage out of a bigger one. I've isolated the issue to be with the function CGImageCreateWithImageInRect() which seem to not set some CGImage property the way I want. :-) The problem is that a call to function UIImagePNGRepresentation() fails returning a nil. CGImageRef origRef = [s...

Convert 32 bit CGImage to 24 bit?

Trying to convert a 32 bit CGImage to 24 bit and would like to avoid packing it byte-by-byte. Surely there must be a more efficient way ...? Have tried a couple of things like creating a 24 bpp NSBitmapImageRep like this: NSBitmapImageRep* image24 = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil pixelsWide:width ...

modify pixels of an CGImageRef

Hi, I am using the following code to modify pixels of an image. The issue I have is the color of the images are icorrect. Do you have any idea of the issue? CGImageRef inImage = img.CGImage; CGContextRef ctx; CFDataRef m_DataRef; m_DataRef = CGDataProviderCopyData(CGImageGetDataProvider(inImage)); UInt8 * m_Pix...

CGImage from byte array

Loading a CGImage or NSImage from a file using a standard image format (jpeg, gif, png et.) is all very simple. However, I now need to create a CGImage from an array in bytes in memory generated using libfreetype. Its really easy to create OpenGL textures from an array of formatted bytes, and I can see how to create a CGBitmapContext t...

Memory leak in CGImage

Hi everybody! I've got a memory leak i just don't know how to solve. This is the leaking code: [newImg release]; CGColorSpaceRef d_colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(Data, width, height, ...

iPhone: How to Maintain Original Image Size Thoughout Image Edits

hi, I am developing an iPhone app that resizes and merges images. I want to select two photos of size 1600x1200 from photo library and then merge both into a single image and save that new image back to the photo library. However, I can't get the right size for the merged image. I take two image views of frame 320x480 and set the v...

iPhone: Changing CGImageAlphaInfo of CGImage

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; ...

iPhone: CMYK Supported Pixel Formats woes

I am trying to create a image sized 1X1 in CMYK color space. as first step I am creating bitmapContext as CGColorSpaceRef cmykcolorSpace = CGColorSpaceCreateDeviceCMYK(); CGContextRef currentcontext = CGBitmapContextCreate(NULL, 1, 1, 8, //bitsPerComponent 4, // bytesPerRow cmykcolorSpa...

Turning an NSImage* into a CGImageRef?

Is there an easy way to do this that works in 10.5? In 10.6 I can use nsImage CGImageForProposedRect: NULL context: NULL hints: NULL If I'm not using 1b black and white images (Like Group 4 TIFF), I can use bitmaps, but cgbitmaps seem to not like that setup... Is there a general way of doing this? I need to do this because I have an ...

iPhone: CALayer Memory Leak question

Would the code bellow cause my code to leak? More specifically, am I responsible for releasing the newImage or the contents of mainPageLayer (which is a CALayer object)? I get a memory warning every 4th time that method is called, but cant figure out why... I also can't figure out why mainPageLayer.contents = [newImage CGImage]; throws ...

How create UIImage from bytes ?

Hello, all! I need in UIImage created from my colors (for example, i need in image 1x1 pixel with black color). I've got array: unsigned char *color[] = {0, 0, 0, 1}; How can i create UIImage from this array ? I've try unsigned char *bytes[4] = {0,0,0,1}; NSData *data = [NSData dataWithBytes:bytes length:4]; UIImage *img = [UII...

Strange crashes on the iPad device with core graphics functions

I am getting a lot of strange EXC_BAD_ACCESS crashes on the iPad that only happen on the device and not in the simulator. I am assuming that they are somehow memory related, but I am not sure. They all happen with image context related functions. One strange example is using CGImageCreateWithImageInRect. For example, if i run through a ...

NSMutableArray EXC_BAD_EXCESS SIGBUS

Hi, I've the following code which causes crashes after sometime as i've set the below code in a timer: CGImageRef cgImage = UIGetScreenImage(); [array addObject:(id)cgImage]; CGImageRelease(cgImage); Where initiallly i've declared array as: array = [[NSMutableArray alloc] init]; The timer goes well till 10 seconds as timer is of 1/...

How to- NSAttributedString to CGImageRef

Hello! I'm writing a QuickLook plugin. Well, everything works. Just want to try it make better ;). Thus the question. Here is a function that returns thumbnail image and that I'm using now. QLThumbnailRequestSetImageWithData( QLThumbnailRequestRef thumbnail, CFDataRef data, CFDictionaryRef properties); ); http://developer.apple.com/m...