mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Save resolution information if it is different from 72 dpi
This commit is contained in:
parent
fc8c034aca
commit
4ba0fa25cc
2 changed files with 21 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
2017-06-17 Riccardo Mottola <rm@gnu.org>
|
||||
|
||||
* Source/NSBitmapImageRep+JPEG.m
|
||||
Save resolution information if it is different from 72 dpi.
|
||||
|
||||
|
||||
2017-06-13 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/externs.m: Added semicolons missing in last commit.
|
||||
|
|
|
@ -552,6 +552,7 @@ static void gs_jpeg_memory_dest_destroy (j_compress_ptr cinfo)
|
|||
int sPP;
|
||||
int width;
|
||||
int height;
|
||||
NSSize size;
|
||||
int row_stride;
|
||||
int quality = 90;
|
||||
NSNumber *qualityNumber;
|
||||
|
@ -639,6 +640,20 @@ static void gs_jpeg_memory_dest_destroy (j_compress_ptr cinfo)
|
|||
|
||||
jpeg_set_defaults (&cinfo);
|
||||
|
||||
// resolution/density
|
||||
size = [self size];
|
||||
if (width != (int)(size.width) || height != (int)(size.height))
|
||||
{
|
||||
unsigned x_density, y_density;
|
||||
|
||||
x_density = (unsigned)floorf(width * 72 / size.width + 0.5);
|
||||
y_density = (unsigned)floorf(height * 72 / size.height + 0.5);
|
||||
cinfo.X_density = x_density;
|
||||
cinfo.Y_density = y_density;
|
||||
cinfo.density_unit = 1;
|
||||
}
|
||||
|
||||
|
||||
// set quality
|
||||
// we expect a value between 0..1, 0 being lowest, 1 highest quality
|
||||
qualityNumber = [properties objectForKey: NSImageCompressionFactor];
|
||||
|
|
Loading…
Reference in a new issue