diff --git a/ChangeLog b/ChangeLog index 3732968b7..72e035997 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-11-06 Eric Wasylishen + + * Source/NSBitmapImageRep+PNG.m: + HACK: PNG can not represent 72DPI exactly. If the pixels-per-meter value is + near 72DPI, assume it is exactly 72 DPI. Note that the same problem occurrs + at 144DPI, or 288DPI... so don't use PNG for resolution independent graphics. + 2011-11-06 Fred Kiefer * Source/NSPopUpButtonCell.m (-insertItemWithTitle:atIndex:): Set diff --git a/Source/NSBitmapImageRep+PNG.m b/Source/NSBitmapImageRep+PNG.m index e031a34b4..0011da037 100644 --- a/Source/NSBitmapImageRep+PNG.m +++ b/Source/NSBitmapImageRep+PNG.m @@ -266,6 +266,19 @@ static void reader_func(png_structp png_struct, png_bytep data, const CGFloat pointsPerMeter = 39.3700787 * 72.0; NSSize sizeInPoints = NSMakeSize((width / (CGFloat)xppm) * pointsPerMeter, (height / (CGFloat)yppm) * pointsPerMeter); + + // HACK: PNG can not represent 72DPI exactly. If the ppm value is near 72DPI, + // assume it is exactly 72 DPI. Note that the same problem occurrs at 144DPI... + // so don't use PNG for resolution independent graphics. + if (xppm == 2834 || xppm == 2835) + { + sizeInPoints.width = width; + } + if (yppm == 2834 || yppm == 2835) + { + sizeInPoints.height = height; + } + [self setSize: sizeInPoints]; } }