how to initialize and implement the matrix inside the function in objective-C?
Posted
by Rajendra Bhole
on Stack Overflow
See other posts from Stack Overflow
or by Rajendra Bhole
Published on 2010-03-22T05:18:57Z
Indexed on
2010/03/22
5:21 UTC
Read the original article
Hit count: 352
iphone
Hi, I want to develop an application in which i want to be initialize the matrix for manipulation. The code as follows, struct pixel { Byte r, g, b,a; int count; };
(NSInteger) processImage1: (UIImage*) image {
struct pixel* pixels = (struct pixel*) calloc(1, image.size.width * image.size.height * sizeof(struct pixel)); if (pixels != nil) { // Create a new bitmap CGContextRef context = CGBitmapContextCreate( (void*) pixels, image.size.width, image.size.height, 8, image.size.width * 4, CGImageGetColorSpace(image.CGImage), kCGImageAlphaPremultipliedLast );
if (context != NULL) { // Draw the image in the bitmap CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, image.size.width, image.size.height), image.CGImage); NSUInteger numberOfPixels = image.size.width * image.size.height;
if (pixels->r == 254 || pixels->g == 77 || pixels->b==254) { numberOfRedPixels++; }while (numberOfPixels > 0) {
} free(pixels);pixels++; numberOfPixels--; } CGContextRelease(context);
}
return 1; }
I want to implement the matrix inside the function of - (NSInteger) processImage1: (UIImage*) image {} The matrix should have be row = image.size.width and column = image.size.height.
© Stack Overflow or respective owner