Search Results

Search found 2 results on 1 pages for 'toastie'.

Page 1/1 | 1 

  • CGBitmapContextCreate on the iPhone/iPad

    - by toastie
    Hello, I have a method that needs to parse through a bunch of large PNG images pixel by pixel (the PNGs are 600x600 pixels each). It seems to work great on the Simulator, but on the device (iPad), i get an EXC_BAD_ACCESS in some internal memory copying function. It seems the size is the culprit because if I try it on smaller images, everything seems to work. Here's the memory related meat of method below. + (CGRect) getAlphaBoundsForUImage: (UIImage*) image { CGImageRef imageRef = [image CGImage]; NSUInteger width = CGImageGetWidth(imageRef); NSUInteger height = CGImageGetHeight(imageRef); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); unsigned char *rawData = malloc(height * width * 4); memset(rawData,0,height * width * 4); NSUInteger bytesPerPixel = 4; NSUInteger bytesPerRow = bytesPerPixel * width; NSUInteger bitsPerComponent = 8; CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGColorSpaceRelease(colorSpace); CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); CGContextRelease(context); /* non-memory related stuff */ free(rawData); When I run this on a bunch of images, it runs 12 times and then craps out, while on the simulator it runs no problem. Do you guys have any ideas?

    Read the article

  • Strange crashes on the iPad device with core graphics functions

    - by toastie
    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 bunch of UIImages and crop them with CGImageCreateWithImageInRect, it will always crash at specific arbitrary sizes. Like, if I crop them all to 200x200, it crashes out after processing 12 images. If i crop them to 210x210, it works no problem. The EXC_BAD_ACCESS happens inside of "memmove" called from "CGBlt_copyBytes". That is all the debugger shows me strangely enough. I can't see the callstack going up to any of my methods. All of this works fine in the simulator! I know this is all very vague, but if anyone has any ideas, they would be greatly appreciated.

    Read the article

1