OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
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 #include "SkJpegDecoderMgr.h" | 8 #include "SkJpegDecoderMgr.h" |
9 #include "SkJpegUtility_codec.h" | 9 #include "SkJpegUtility_codec.h" |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 return false; | 32 return false; |
33 } | 33 } |
34 | 34 |
35 SkCodec::Result JpegDecoderMgr::returnFailure(const char caller[], SkCodec::Resu
lt result) { | 35 SkCodec::Result JpegDecoderMgr::returnFailure(const char caller[], SkCodec::Resu
lt result) { |
36 print_message((j_common_ptr) &fDInfo, caller); | 36 print_message((j_common_ptr) &fDInfo, caller); |
37 return result; | 37 return result; |
38 } | 38 } |
39 | 39 |
40 SkColorType JpegDecoderMgr::getColorType() { | 40 SkColorType JpegDecoderMgr::getColorType() { |
41 switch (fDInfo.jpeg_color_space) { | 41 switch (fDInfo.jpeg_color_space) { |
42 case JCS_CMYK: | |
43 case JCS_YCCK: | |
44 // libjpeg cannot convert from CMYK or YCCK to RGB. | |
45 // Here, we ask libjpeg to give us CMYK samples back and | |
46 // we will later manually convert them to RGB. | |
47 fDInfo.out_color_space = JCS_CMYK; | |
48 return kN32_SkColorType; | |
49 case JCS_GRAYSCALE: | 42 case JCS_GRAYSCALE: |
50 fDInfo.out_color_space = JCS_GRAYSCALE; | |
51 return kGray_8_SkColorType; | 43 return kGray_8_SkColorType; |
52 default: | 44 default: |
53 #ifdef ANDROID_RGB | |
54 fDInfo.out_color_space = JCS_RGBA_8888; | |
55 #else | |
56 fDInfo.out_color_space = JCS_RGB; | |
57 #endif | |
58 return kN32_SkColorType; | 45 return kN32_SkColorType; |
59 } | 46 } |
60 } | 47 } |
61 | 48 |
62 JpegDecoderMgr::JpegDecoderMgr(SkStream* stream) | 49 JpegDecoderMgr::JpegDecoderMgr(SkStream* stream) |
63 : fSrcMgr(stream) | 50 : fSrcMgr(stream) |
64 , fInit(false) | 51 , fInit(false) |
65 { | 52 { |
66 // Error manager must be set before any calls to libjeg in order to handle f
ailures | 53 // Error manager must be set before any calls to libjeg in order to handle f
ailures |
67 fDInfo.err = jpeg_std_error(&fErrorMgr); | 54 fDInfo.err = jpeg_std_error(&fErrorMgr); |
(...skipping 14 matching lines...) Expand all Loading... |
82 } | 69 } |
83 } | 70 } |
84 | 71 |
85 jmp_buf& JpegDecoderMgr::getJmpBuf() { | 72 jmp_buf& JpegDecoderMgr::getJmpBuf() { |
86 return fErrorMgr.fJmpBuf; | 73 return fErrorMgr.fJmpBuf; |
87 } | 74 } |
88 | 75 |
89 jpeg_decompress_struct* JpegDecoderMgr::dinfo() { | 76 jpeg_decompress_struct* JpegDecoderMgr::dinfo() { |
90 return &fDInfo; | 77 return &fDInfo; |
91 } | 78 } |
OLD | NEW |