I am facing a crash with following error:
"CGDataProviderCreateWithCopyOfData: vm_copy failed: status 1."
I have multiple questions and you can help.
What does status 1 stand for in vm_copy failed?
This crash happens only when I set a break point in the inner for loop of data copy. And then resume and remove the breakpoint. If there is no breakpoint, function executes but I get a blank image. How do I ensure that even if I don't set a break point, such crashes are caught and application stops execution?
This error comes when I execute CGBitmapContextCreateImage. Does anyone know how to resolve this?
-(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] =img[i][j];
piData[iStep+jStep+1] =img[i][j];
piData[iStep+jStep+2] = img[i][j];
}
}
CGContextRef ctx = CGBitmapContextCreate(piData,
CGImageGetWidth(inImage),
CGImageGetHeight(inImage),
CGImageGetBitsPerComponent(inImage),
CGImageGetBytesPerRow(inImage),
CGImageGetColorSpace(inImage),
CGImageGetBitmapInfo(inImage)
);
CGImageRef imageRef = CGBitmapContextCreateImage(ctx);
UIImage *finalImage = [UIImage imageWithCGImage:imageRef];
CGContextRelease(ctx);
CGImageRelease(imageRef);
free(piData);
return finalImage;
}