| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "SkImageDecoder.h" | 9 #include "SkImageDecoder.h" |
| 10 #include "SkImageEncoder.h" | 10 #include "SkImageEncoder.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 return false; | 278 return false; |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 return true; | 281 return true; |
| 282 } | 282 } |
| 283 #endif | 283 #endif |
| 284 | 284 |
| 285 // This guy exists just to aid in debugging, as it allows debuggers to just | 285 // This guy exists just to aid in debugging, as it allows debuggers to just |
| 286 // set a break-point in one place to see all error exists. | 286 // set a break-point in one place to see all error exists. |
| 287 static bool return_false(const jpeg_decompress_struct& cinfo, | 287 static bool return_false(const jpeg_decompress_struct& cinfo, |
| 288 const SkBitmap& bm, const char msg[]) { | 288 const SkBitmap& bm, const char caller[]) { |
| 289 #ifdef SK_DEBUG | 289 #ifdef SK_DEBUG |
| 290 char buffer[JMSG_LENGTH_MAX]; |
| 291 cinfo.err->format_message((const j_common_ptr)&cinfo, buffer); |
| 290 SkDebugf("libjpeg error %d <%s> from %s [%d %d]\n", cinfo.err->msg_code, | 292 SkDebugf("libjpeg error %d <%s> from %s [%d %d]\n", cinfo.err->msg_code, |
| 291 cinfo.err->jpeg_message_table[cinfo.err->msg_code], msg, | 293 buffer, caller, bm.width(), bm.height()); |
| 292 bm.width(), bm.height()); | |
| 293 #endif | 294 #endif |
| 294 return false; // must always return false | 295 return false; // must always return false |
| 295 } | 296 } |
| 296 | 297 |
| 297 // Convert a scanline of CMYK samples to RGBX in place. Note that this | 298 // Convert a scanline of CMYK samples to RGBX in place. Note that this |
| 298 // method moves the "scanline" pointer in its processing | 299 // method moves the "scanline" pointer in its processing |
| 299 static void convert_CMYK_to_RGB(uint8_t* scanline, unsigned int width) { | 300 static void convert_CMYK_to_RGB(uint8_t* scanline, unsigned int width) { |
| 300 // At this point we've received CMYK pixels from libjpeg. We | 301 // At this point we've received CMYK pixels from libjpeg. We |
| 301 // perform a crude conversion to RGB (based on the formulae | 302 // perform a crude conversion to RGB (based on the formulae |
| 302 // from easyrgb.com): | 303 // from easyrgb.com): |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 } | 1152 } |
| 1152 | 1153 |
| 1153 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { | 1154 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { |
| 1154 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; | 1155 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; |
| 1155 } | 1156 } |
| 1156 | 1157 |
| 1157 | 1158 |
| 1158 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); | 1159 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); |
| 1159 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); | 1160 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); |
| 1160 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); | 1161 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); |
| OLD | NEW |