* Source/NSBitmapImageRep+PNG.m: Read DPI metadata in PNG files

and use this to set the point size of the image rep


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32916 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Eric Wasylishen 2011-04-20 21:41:17 +00:00
parent dd335948b1
commit 96450245fe
2 changed files with 19 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2011-04-20 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSBitmapImageRep+PNG.m: Read DPI metadata in PNG files
and use this to set the point size of the image rep
2011-04-19 Eric Wasylishen <ewasylishen@gmail.com>
* ColorPickers/GSWheelColorPicker.m: Choose the color wheel bitmap size

View file

@ -256,6 +256,20 @@ static void reader_func(png_structp png_struct, png_bytep data,
//NSLog(@"PNG file gamma: %f", file_gamma);
}
if (png_get_valid(png_struct, png_info, PNG_INFO_pHYs))
{
png_uint_32 xppm = png_get_x_pixels_per_meter(png_struct, png_info);
png_uint_32 yppm = png_get_y_pixels_per_meter(png_struct, png_info);
if (xppm != 0 && yppm != 0)
{
const CGFloat pointsPerMeter = 39.3700787 * 72.0;
NSSize sizeInPoints = NSMakeSize((width / (CGFloat)xppm) * pointsPerMeter,
(height / (CGFloat)yppm) * pointsPerMeter);
[self setSize: sizeInPoints];
}
}
png_destroy_read_struct(&png_struct, &png_info, &png_end_info);
return self;