Re: Strange issue with PNG files

Avi Drissman <avi-wYYLmqtpiAJWk0Htik3J/[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
It's apparently not a 72ppi picture. Even though the image is 16x14 pixels,
at ~200ppi something 14 pixels high is only 5 points high.

You are getting the full image, and I bet if you took the NSImageRep and
asked *it* for -pixelsHigh or -pixelsWide you'd get the 14 and 16.

If you want to draw it pixel for pixel despite the high ppi, use
-pixelsHigh/-pixelsWide, create an NSSize of that size, and draw it
"scaled".

Avi

On Thu, Mar 4, 2010 at 1:58 PM, Eric Gorr <[email protected]> wrote:

> I am working with a PNG file and noticed something odd with it that I am
> hoping someone can explain since I am not familiar enough with the PNG file
> format at this time.
>
> Basically, when I use:
>
> fileImage = [[[NSImage alloc] initWithContentsOfFile:filePath]
> autorelease];
> NSSize imageSize = [fileImage size];
> NSLog( @"Have Image of size - %@", NSStringFromSize( imageSize ) );
>
> to read the image and then take a look at the result of [fileImage size], I
> am told the image is {5.76086, 5}.
>
> Now, the odd thing is that I know the image is 16x14. I can confirm this by
> opening the image with GraphicConverter.
>
> However, when I open the image with GraphicConverter, it opens the image up
> at ~36% of it's normal size. Now, ~36% of the normal size is {5.76086, 5} -
> at least I am assuming this isn't a coincidence.
>
> So, the question is, does anyone know what is going on here? How can I get
> NSImage to read the image in at the normal size instead of the smaller one?
>
> _______________________________________________
> MacOSX-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/macosx-dev
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.