Re: Setting the DPI of an NSBitmapImageRep
Re: Setting the DPI of an NSBitmapImageRep
- Subject: Re: Setting the DPI of an NSBitmapImageRep
- From: Robert Grant <email@hidden>
- Date: Mon, 29 Aug 2005 18:00:55 -0400
Hi Heinrich,
That did it thanks. I was trying something similar - but got it
messed up somewhere I guess!
Best,
Robert.
On Aug 29, 2005, at 12:02 PM, Heinrich Giesen wrote:
On 29.08.2005, at 16:53, Robert Grant wrote:
My app is producing bitmaps at various DPIs, 72 -> 1200 but when the
bitmaps are loaded into an app they are reported to have 72 DPI.
I've tried setting the "size" of the bitmap before getting its
representation as NSData, but that doesn't seem to help.
This is the correct way and works if you use the correct relationship
between resolution, imagesize (the size it is depicted) and pixelSize:
@implementation NSImageRep (NSImageRep)
- (float) dpiX { return 72.0*[self pixelsWide]/[self size].width; }
- (float) dpiY { return 72.0*[self pixelsHigh]/[self size].height; }
- (void) setdpiX:(int)dpi
{
NSSize size = [self size];
size.width = 72.0*[self pixelsWide] / dpi;
[self setSize:size];
}
- (void) setdpiY:(int)dpi
{
NSSize size = [self size];
size.height = 72.0*[self pixelsHigh] / dpi;
[self setSize:size];
}
@end
--
Heinrich Giesen
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden