• 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: Heinrich Giesen <email@hidden>
  • Date: Mon, 29 Aug 2005 18:02:27 +0200


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
  • Follow-Ups:
    • Re: Setting the DPI of an NSBitmapImageRep
      • From: Robert Grant <email@hidden>
  • Prev by Date: Re: Can't Convert Image on Disk to NSData for Core Data
  • Next by Date: Re: Problem using NSSpliter, not able to Regain the size of Shrink Subviews, and how to get the previous changed Splitter Window on Relaunching
  • Previous by thread: Setting the DPI of an NSBitmapImageRep
  • Next by thread: Re: Setting the DPI of an NSBitmapImageRep
  • Index(es):
    • Date
    • Thread