Re: I want ALL my tiff pixels
Re: I want ALL my tiff pixels
- Subject: Re: I want ALL my tiff pixels
- From: "Clark S. Cox III" <email@hidden>
- Date: Wed, 12 Mar 2003 11:51:06 -0500
On Wednesday, Mar 12, 2003, at 10:40 US/Eastern, robert l clair wrote:
#import "ExtendBitchingAboutUselesslySparseDocumentation.h"
I want *ALL* my pixels. I have (let's say) a 1200 pixel
square tiff created in Photoshop with a "resolution"
of 600 dpi. I read it into an NSImage using something like
NSImage* myImage = [[NSImage alloc] initWithContentsOfFile:
@"myfile.tiff"];
I then draw it in a view with:
NSRect myRect = NSZeroRect;
NSPoint myPoint = NSZeroPoint;
myRect.size = [myImage size];
[myImage drawAtPoint: myPoint fromRect: myRect
operation: NSCompositeSourceAtop fraction: 1.0];
The result is an ugly 144 "pixels" square [really ugly
since my view bounds are scaled to give the real 101.4 dpi
of a powerbook, ie 72 points comes out an honest-measurable-
with-a-dimestore-ruler inch on the screen]. If I print it -
it prints 2 inches square with big blocky "pixels". If I
scaleup the view the ugliness scales.
A little investigation with the debugger reveals: The image has
a size of of 144 x 144. It has one representation with
a size of 144 x 144. pixelsHigh, pixelWide on the image rep admit
to being 1200.
What I want: I want all my 1200 x1200 pixels, and to know that the
resolution field says it's 600 dpi so that I can scale it
myself to what ever magnification I want and so that it will print
nicely.
Try something like:
NSImageRep *myImageRep = [myImage bestRepresentationForDevice: nil];
NSSize imageSize = [myImage size];
NSSize rawSize = {[myImageRep pixelsWide], [myImageRep pixelsHigh]};
NSSize trueDPI = {72 / imageSize.width * rawSize.width, 72 /
imageSize.height * rawSize.height};
[myImage setScalesWhenResized: YES];
[myImage setSize: rawSize];
Given your numbers (1200x1200, 600 dpi, automatically scaled to 144 x
144, 72 dpi):
72 / 144 * 1200 = 600
So, trueDPI should contain {600, 600};
--
http://homepage.mac.com/clarkcox3/
email@hidden
Clark S. Cox, III
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.