Fallo al procesar píxel después de recortar una imagen
Después de usar esta función para recortar la imagen:
CGImageRef imageRef = CGImageCreateWithImageInRect([self.imageInput CGImage], rect);
UIImage *result = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
Traigo el "resultado" para usar en el proceso con un píxel como ese:
......
CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef);
CGContextRelease(context);
// Now your rawData contains the image data in the RGBA8888 pixel format.
int byteIndex = 0;
for (NSInteger i = 0 ; i < width * height; i++) {
int R = rawData[byteIndex];
int G = rawData[byteIndex + 1];
int B = rawData[byteIndex + 2];
int test = [self getValueof:0.3* R + 0.59* G + 0.11 * B inRange:0 to:255];
rawData[byteIndex] = (char)(test);
rawData[byteIndex + 1] = (char)(test);
rawData[byteIndex + 2] = (char)(test);
byteIndex += 4;
}
ctx = CGBitmapContextCreate(rawData,
CGImageGetWidth( imageRef ),
CGImageGetHeight( imageRef ),
8,
CGImageGetBytesPerRow( imageRef ),
CGImageGetColorSpace( imageRef ),
kCGImageAlphaPremultipliedLast );
imageRef = CGBitmapContextCreateImage (ctx);
UIImage* rawImage = [UIImage imageWithCGImage:imageRef];
CGContextRelease(ctx);
CGImageRelease(imageRef);
free(rawData);
Tendré crash? Alguien lo sepa, por favor ayúdame.
informe de bloqueo de actualización:: copy_read_only: vm_copy falló: estado 1.