I have following question: How can I scan a complete image to get for every pixel it's color.
I use this library https://github.com/unixpickle/ANImageBitmapRep.
I have this code:
- (void)executeImageScanProcessWithImage:(UIImage *)image{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
(unsigned long)NULL), ^(void) {
NSString *rowString = @"";
NSMutableArray *array = [[NSMutableArray alloc] init];
ANImageBitmapRep *imageBitmap;
UIColor *color;
// Loop für die Spalten (y)
for (int y = 0; y < 320; y += 20) {
rowString = @""; // rowString zurücksetzen
// Loop für die Reihe (x)
for (int x = 0; x < image.size.width; x += 20) {
BMPoint pixelPoint = BMPointMake(x, y);
imageBitmap = [ANImageBitmapRep imageBitmapRepWithImage:image];
BMPixel pixel = [imageBitmap getPixelAtPoint:pixelPoint];
color = UIColorFromBMPixel(pixel);
if ([color isEqual:[UIColor redColor]]) {
rowString = [rowString stringByAppendingFormat:@"0"];
}
else {
rowString = [rowString stringByAppendingFormat:@"1"];
}
// Wenn der letzte "Run" vollzogen ist, wird die rowString in den Array hinzugefügt
if ([rowString length] == image.size.width / 20) {
[array addObject:rowString];
}
}
[array addObject:rowString];
}
NSLog(@"content of array = %@",array);
});
}
The Problem is that I get this error, when the image gets too big.
Malloc failed which is too bad. I was hoping to use this memory. Jul 24 18:31:41 Christians-MacBook-Pro.local Bitmap_Test[2374] : CGBitmapContextGetData: invalid context 0x0 Jul 24 18:31:41 Christians-MacBook-Pro.local Bitmap_Test[2374] : CGBitmapContextCreateImage: invalid context 0x0 Jul 24 18:31:41 Christians-MacBook-Pro.local Bitmap_Test[2374] : CGBitmapContextGetWidth: invalid context 0x0 Bitmap_Test(2374,0xb0103000) malloc: * mmap(size=2265088) failed (error code=12)
Do you know another approach to deal with this plan?
Best regards from Germany, Chris