int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSImage *theImage = [[NSImage alloc] initByReferencingFile:@"/Users/markusca/Desktop/Picture1.png"];
NSBitmapImageRep *imageRep = (NSBitmapImageRep *)[theImage bestRepresentationForDevice:nil];
int imageWidth = [imageRep pixelsWide];
int imageHeight = [imageRep pixelsHigh];
NSMutableSet *mySet = [[NSMutableSet alloc] initWithCapacity:(imageWidth*imageHeight) *.5];
NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate];
unsigned short height, width;
for (height = 0; height < imageHeight; height++) {
for (width = 0; width < imageWidth; width++) {
}
}
NSTimeInterval endTime = [NSDate timeIntervalSinceReferenceDate];
NSLog(@"Size of image is %i x %i (%i pixels)", imageWidth, imageHeight, (imageHeight * imageWidth));
NSLog(@"Time to get all values was %f", (endTime - startTime));
NSLog(@"The Set size is %i", [mySet count]);
[pool drain];
return 0;
}
NSImage *theImage = [[[NSImage alloc] initWithContentsOfFile:[openPanel filename]] autorelease];
NSBitmapImageRep *imageRep = (NSBitmapImageRep *)[theImage bestRepresentationForDevice:nil];
NSSize size = imageRep.size;
NSLog(@"{%d, %d}, %d", [imageRep pixelsWide], [imageRep pixelsHigh], [imageRep pixelsWide] * [imageRep pixelsHigh]);
int imageWidth = [imageRep pixelsWide];
int imageHeight = [imageRep pixelsHigh];
CFMutableSetRef mySet = CFSetCreateMutable(NULL, (imageWidth*imageHeight) *.5, NULL);
NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate];
unsigned short height, width;
for (height = 0; height < imageHeight; height++)
for (width = 0; width < imageWidth; width++)
CFSetAddValue(mySet, [imageRep colorAtX:width y:height]);
NSTimeInterval endTime = [NSDate timeIntervalSinceReferenceDate];
NSLog(@"time : %f", endTime - startTime);