Support for writing resolution

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@40491 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rmottola 2017-04-24 10:42:32 +00:00
parent f2fafee938
commit 2ae1f7d0d3
3 changed files with 24 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2017-04-24 Riccardo Mottola <rm@gnu.org>
* Source/tiff.m
* Source/NSBitmapImageRep.m
Support for writing resolution.
2017-04-22 Fred Kiefer <FredKiefer@gmx.de>
* Version: Correct required base version that has been off for a year.

View file

@ -2,7 +2,7 @@
<abstract>Bitmap image representation.</abstract>
Copyright (C) 1996-2014 Free Software Foundation, Inc.
Copyright (C) 1996-2017 Free Software Foundation, Inc.
Author: Adam Fedor <fedor@gnu.org>
Date: Feb 1996
@ -2015,6 +2015,16 @@ _set_bit_value(unsigned char *base, long msb_off, int bit_width,
info->bitsPerSample = _bitsPerSample;
info->samplesPerPixel = _numColors;
// resolution/density
if (_pixelsWide != (int)(_size.width) || _pixelsHigh != (int)(_size.height))
{
float x_density, y_density;
x_density = _pixelsWide * 72 / _size.width;
y_density = _pixelsHigh * 72 / _size.height;
info->xdpi = x_density;
info->ydpi = y_density;
}
if (_isPlanar)
info->planarConfig = PLANARCONFIG_SEPARATE;
else

View file

@ -3,7 +3,7 @@
Functions for dealing with tiff images.
Copyright (C) 1996,1999-2010 Free Software Foundation, Inc.
Copyright (C) 1996,1999-2010, 2017 Free Software Foundation, Inc.
Author: Adam Fedor <fedor@colorado.edu>
Date: Feb 1996
@ -488,6 +488,12 @@ NSTiffWrite(TIFF *image, NSTiffInfo *info, unsigned char *data)
TIFFSetField(image, TIFFTAG_IMAGEWIDTH, info->width);
TIFFSetField(image, TIFFTAG_IMAGELENGTH, info->height);
if (info->xdpi && info->ydpi)
{
TIFFSetField(image, TIFFTAG_XRESOLUTION, info->xdpi);
TIFFSetField(image, TIFFTAG_YRESOLUTION, info->ydpi);
TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, 2);
}
TIFFSetField(image, TIFFTAG_COMPRESSION, info->compression);
if (info->compression == COMPRESSION_JPEG)
{