Bug 444898 – JPEG writer uses poor quality default options for compression. r=tor, sr=pavlov

This commit is contained in:
Glenn Randers-Pehrson 2008-08-19 10:07:09 +02:00
parent 7708e3dc71
commit 4c06ce90fa
2 changed files with 10 additions and 2 deletions

View File

@ -106,7 +106,7 @@ NS_IMETHODIMP nsJPEGEncoder::InitFromData(const PRUint8* aData,
return NS_ERROR_ALREADY_INITIALIZED;
// options: we only have one option so this is easy
int quality = 50;
int quality = 92;
if (aOutputOptions.Length() > 0) {
// have options string
const nsString qualityPrefix(NS_LITERAL_STRING("quality="));
@ -154,6 +154,13 @@ NS_IMETHODIMP nsJPEGEncoder::InitFromData(const PRUint8* aData,
jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, quality, 1); // quality here is 0-100
if (quality >= 90) {
int i;
for (i=0; i < MAX_COMPONENTS; i++) {
cinfo.comp_info[i].h_samp_factor=1;
cinfo.comp_info[i].v_samp_factor=1;
}
}
// set up the destination manager
jpeg_destination_mgr destmgr;

View File

@ -88,8 +88,9 @@ interface imgIEncoder : nsIInputStream
// JPEG:
// -----
//
// quality=# -- default: "50"
// quality=# -- default: "92"
// Quality of compression, 0-100 (worst-best).
// Quality >= 90 prevents down-sampling of the color channels.
// Possible values for input format (note that not all image formats