Author: rmottola
Date: Wed May 21 16:52:09 2014
New Revision: 37898
URL: http://svn.gna.org/viewcvs/gnustep?rev=37898&view=rev
Log:
Transform 0..255 compression factor to 0..1 quality to match Cocoa specs
Modified:
libs/gui/trunk/ChangeLog
libs/gui/trunk/Source/NSBitmapImageRep+JPEG.m
libs/gui/trunk/Source/NSBitmapImageRep.m
Modified: libs/gui/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/ChangeLog?rev=37898&r1=37897&r2=37898&view=diff
==============================================================================
--- libs/gui/trunk/ChangeLog (original)
+++ libs/gui/trunk/ChangeLog Wed May 21 16:52:09 2014
@@ -1,3 +1,9 @@
+2014-05-21 Riccardo Mottola <[email protected]>
+
+ * Source/NSBitmapImageRep+JPEG.m
+ * Source/NSBitmapImageRep.m
+ Transform 0..255 compression factor to 0..1 quality to match Cocoa
specs.
+
2014-05-04 Ivan Vucica <[email protected]>
* Tests/GNUmakefile: Don't fail if 'gnustep-tests --clean' fails.
Modified: libs/gui/trunk/Source/NSBitmapImageRep+JPEG.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSBitmapImageRep%2BJPEG.m?rev=37898&r1=37897&r2=37898&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSBitmapImageRep+JPEG.m (original)
+++ libs/gui/trunk/Source/NSBitmapImageRep+JPEG.m Wed May 21 16:52:09 2014
@@ -2,7 +2,7 @@
Methods for reading jpeg images
- Copyright (C) 2003-2010 Free Software Foundation, Inc.
+ Copyright (C) 2003-2014 Free Software Foundation, Inc.
Written by: Stefan Kleine Stegemann <[email protected]>
Date: Nov 2003
@@ -600,11 +600,12 @@
jpeg_set_defaults (&cinfo);
// set quality
-
+ // we expect a value between 0..1, 0 being lowest, 1 highest quality
+
qualityNumber = [properties objectForKey: NSImageCompressionFactor];
if (qualityNumber != nil)
{
- quality = (int) ((1-[qualityNumber floatValue] / 255.0) * 100.0);
+ quality = (int) ([qualityNumber floatValue] * 100.0);
}
// set progressive mode
Modified: libs/gui/trunk/Source/NSBitmapImageRep.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSBitmapImageRep.m?rev=37898&r1=37897&r2=37898&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSBitmapImageRep.m (original)
+++ libs/gui/trunk/Source/NSBitmapImageRep.m Wed May 21 16:52:09 2014
@@ -2,7 +2,7 @@
<abstract>Bitmap image representation.</abstract>
- Copyright (C) 1996, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1996-2014 Free Software Foundation, Inc.
Author: Adam Fedor <[email protected]>
Date: Feb 1996
@@ -1498,9 +1498,9 @@
info.compression = [NSBitmapImageRep _localFromCompressionType: type];
if (factor < 0)
factor = 0;
- if (factor > 255)
- factor = 255;
- info.quality = (1 - ((float)factor)/255.0) * 100;
+ if (factor > 1)
+ factor = 1;
+ info.quality = factor * 100;
info.numImages = 1;
info.error = 0;
@@ -1685,8 +1685,8 @@
/** Returns the receivers compression and compression factor, which is
set either when the image is read in or by -setCompression:factor:.
Factor is ignored in many compression schemes. For JPEG compression,
- factor can be any value from 0 to 255, with 255 being the maximum
- compression. */
+ factor can be any value from 0 to 1, with 1 being the maximum
+ quality. */
- (void) getCompression: (NSTIFFCompression*)compression
factor: (float*)factor
{
@@ -1712,7 +1712,7 @@
<term> NSImageCompressionMethod </term>
<desc> NSNumber; automatically set when reading TIFF data; writing TIFF
data </desc>
<term> NSImageCompressionFactor </term>
- <desc> NSNumber 0.0 to 255.0; writing JPEG data
+ <desc> NSNumber 0.0 to 1.0; writing JPEG data
(GNUstep extension: JPEG-compressed TIFFs too) </desc>
<term> NSImageProgressive </term>
<desc> NSNumber boolean; automatically set when reading JPEG data; writing
JPEG data.
@@ -1911,7 +1911,7 @@
bytesPerRow: 0
bitsPerPixel: 0];
_compression = [NSBitmapImageRep _compressionTypeFromLocal:
info->compression];
- _comp_factor = 255 * (1 - ((float)info->quality)/100.0);
+ _comp_factor = (((float)info->quality)/100.0);
// Note that Cocoa does not do this, even though the docs say it should
[_properties setObject: [NSNumber numberWithUnsignedShort: _compression]
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs