| Paste number 64594: | unique pixel values |
| Pasted by: | markusca |
| 3 months, 4 weeks ago | |
| None | |
| Paste contents: |
| int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; // NSImage *theImage = [[NSImage alloc] initByReferencingFile:@"/Users/markusca/Desktop/r-big.tiff"]; NSImage *theImage = [[NSImage alloc] initByReferencingFile:@"/Users/markusca/Desktop/Picture1.png"]; // NSImage *theImage = [[NSImage alloc] initByReferencingFile:@"/Users/markusca/Desktop/5x5.tif"]; 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++) { //[mySet addObject:[imageRep colorAtX:width y:height]]; } } 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; } |
Annotations for this paste:
| Annotation number 1: | Some other code |
| Pasted by: | Psy| |
| 3 months, 4 weeks ago | |
| Paste contents: |
| 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); |