var createMappedImageRefFrom = function(imageRef)
{
var scale = 1.0
var width = CGImageGetWidth(imageRef);
var height = CGImageGetHeight(imageRef);
var bitsPerComponent = 8;
var bytesPerPixel = 4;
var bytesPerRow = CGImageGetBytesPerRow(imageRef);
var bytesInTotal = height * bytesPerRow;
var inputData = []; /* since cannot use malloc(bytesInTotal); */
var outputData = []; /* since cannot use malloc(bytesInTotal); */
for (var ii = 0 ; ii < bytesInTotal; ++ii)
{
outputData[ii] = 0;
inputData[ii] = 0;
}
var colorSpace = CGColorSpaceCreateDeviceRGB();
var context = CGBitmapContextCreate(inputData, // cause crash when CGContextDrawImage is triggered unless i put `'nil` for inputData
width,
height,
bitsPerComponent,
bytesPerRow,
colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);
CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef);
CGContextRelease(context);
CGContextRef ctx;
/* Do some stuffs with inputData -> outputData */
imageRef = CGBitmapContextCreateImage(ctx);
CGContextRelease(ctx);
return imageRef
}
I'm running into a crash issue when I tried to execute the draw method in the following Objective-C to Cocoascript code.
Here's the crash log:
I am not sure why went to some kind of AutoreleasePool thing, I suspect might be some syntax issue. Would appreciate anyone for pointers. Thanks!