• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Setting the DPI of an NSBitmapImageRep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Re: Setting the DPI of an NSBitmapImageRep (From: Heinrich Giesen <email@hidden>)

  • Prev by Date: Re: NSTimeInterval
  • Next by Date: static functions in Objective-C
  • Previous by thread: Re: Setting the DPI of an NSBitmapImageRep
  • Next by thread: Can't Convert Image on Disk to NSData for Core Data
  • Index(es):
    • Date
    • Thread