* Source/tiff.m:

* Source/nsimage-tiff.h:
* Source/NSBitmapImageRep.m: Read DPI metadata in TIFF 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@32920 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Eric Wasylishen 2011-04-21 22:19:06 +00:00
parent 50e9a10212
commit 76d30190e9
4 changed files with 36 additions and 0 deletions

View file

@ -1,3 +1,10 @@
2011-04-21 Eric Wasylishen <ewasylishen@gmail.com>
* Source/tiff.m:
* Source/nsimage-tiff.h:
* Source/NSBitmapImageRep.m: Read DPI metadata in TIFF files and use this
to set the point size of the image rep
2011-04-20 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSImage.m (-nativeDrawInRect:...): Make the cache window

View file

@ -1930,6 +1930,13 @@ _set_bit_value(unsigned char *base, long msb_off, int bit_width,
[_properties setObject: [NSNumber numberWithFloat: _comp_factor]
forKey: NSImageCompressionFactor];
if (info->xdpi > 0 && info->ydpi > 0)
{
NSSize pointSize = NSMakeSize((info->width / info->xdpi) * 72.0,
(info->height / info->ydpi) * 72.0);
[self setSize: pointSize];
}
if (NSTiffRead(image, info, [self bitmapData]))
{
free(info);

View file

@ -55,6 +55,8 @@ typedef struct {
int quality; /* compression quality (for jpeg) 1 to 255 */
int numImages; /* number of images in tiff */
int error;
float xdpi;
float ydpi;
} NSTiffInfo;
typedef struct {

View file

@ -320,6 +320,26 @@ NSTiffGetInfo(int imageNumber, TIFF* image)
info->photoInterp == PHOTOMETRIC_RGB ? "RGB" : "min-is-black");
}
{
uint16 resolution_unit;
float xres, yres;
if (TIFFGetField(image, TIFFTAG_XRESOLUTION, &xres)
&& TIFFGetField(image, TIFFTAG_YRESOLUTION, &yres))
{
TIFFGetFieldDefaulted(image, TIFFTAG_RESOLUTIONUNIT, &resolution_unit);
if (resolution_unit == 2) // Inch
{
info->xdpi = xres;
info->ydpi = yres;
}
else if (resolution_unit == 3) // Centimeter
{
info->xdpi = xres * 2.54;
info->ydpi = yres * 2.54;
}
}
}
return info;
}