mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-24 18:31:20 +00:00
Parse density data and set size accordingly
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@40425 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9a51b8d789
commit
75d6263068
2 changed files with 31 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
2017-03-28 Riccardo Mottola <rm@gnu.org>
|
||||
|
||||
* Source/NSBitmapImageRep+JPEG.m (-_initBitmapFromJPEG:errorMessage:)
|
||||
Parse density data and set size accordingly.
|
||||
|
||||
2017-03-24 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSBitmapImageRep+JPEG.m(-_JPEGRepresentationWithProperties:errorMessage:):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Methods for reading jpeg images
|
||||
|
||||
Copyright (C) 2003-2014 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2017 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Stefan Kleine Stegemann <stefan@wms-network.de>
|
||||
Date: Nov 2003
|
||||
|
@ -393,6 +393,7 @@ static void gs_jpeg_memory_dest_destroy (j_compress_ptr cinfo)
|
|||
JSAMPARRAY sclbuffer = NULL;
|
||||
unsigned char *imgbuffer = NULL;
|
||||
BOOL isProgressive;
|
||||
unsigned x_density, y_density;
|
||||
|
||||
if (!(self = [super init]))
|
||||
return nil;
|
||||
|
@ -506,6 +507,30 @@ static void gs_jpeg_memory_dest_destroy (j_compress_ptr cinfo)
|
|||
[self setProperty: NSImageProgressive
|
||||
withValue: [NSNumber numberWithBool: isProgressive]];
|
||||
|
||||
x_density = cinfo.X_density;
|
||||
y_density = cinfo.Y_density;
|
||||
if (x_density > 0 && y_density > 0)
|
||||
{
|
||||
unsigned short d_unit;
|
||||
|
||||
d_unit = cinfo.density_unit;
|
||||
/* we have dots/cm, convert to dots/inch*/
|
||||
if (d_unit == 2)
|
||||
{
|
||||
x_density = (x_density * 254)/100;
|
||||
y_density = (y_density * 254)/100;
|
||||
}
|
||||
|
||||
if (!(x_density == 72 && y_density == 72))
|
||||
{
|
||||
NSSize pointSize;
|
||||
|
||||
pointSize = NSMakeSize((double)cinfo.output_width * (72.0 / (double)x_density),
|
||||
(double)cinfo.output_height * (72.0 / (double)y_density));
|
||||
[self setSize: pointSize];
|
||||
}
|
||||
}
|
||||
|
||||
_imageData = [[NSData alloc]
|
||||
initWithBytesNoCopy: imgbuffer
|
||||
length: (rowSize * cinfo.output_height)];
|
||||
|
|
Loading…
Reference in a new issue