OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "../../../../third_party/lcms2-2.6/include/lcms2.h" | 10 #include "../../../../third_party/lcms2-2.6/include/lcms2.h" |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 FX_BOOL Decode(uint8_t* dest_buf, | 620 FX_BOOL Decode(uint8_t* dest_buf, |
621 int pitch, | 621 int pitch, |
622 uint8_t* offsets); | 622 uint8_t* offsets); |
623 | 623 |
624 private: | 624 private: |
625 const uint8_t* m_SrcData; | 625 const uint8_t* m_SrcData; |
626 int m_SrcSize; | 626 int m_SrcSize; |
627 opj_image_t* image; | 627 opj_image_t* image; |
628 opj_codec_t* l_codec; | 628 opj_codec_t* l_codec; |
629 opj_stream_t* l_stream; | 629 opj_stream_t* l_stream; |
630 bool m_UseColorSpace; | 630 const bool m_UseColorSpace; |
631 }; | 631 }; |
632 | 632 |
633 CJPX_Decoder::CJPX_Decoder(bool use_colorspace) | 633 CJPX_Decoder::CJPX_Decoder(bool use_colorspace) |
634 : image(nullptr), | 634 : image(nullptr), |
635 l_codec(nullptr), | 635 l_codec(nullptr), |
636 l_stream(nullptr), | 636 l_stream(nullptr), |
637 m_UseColorSpace(use_colorspace) { | 637 m_UseColorSpace(use_colorspace) { |
638 } | 638 } |
639 | 639 |
640 CJPX_Decoder::~CJPX_Decoder() { | 640 CJPX_Decoder::~CJPX_Decoder() { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 opj_set_info_handler(l_codec, fx_info_callback, 00); | 680 opj_set_info_handler(l_codec, fx_info_callback, 00); |
681 opj_set_warning_handler(l_codec, fx_warning_callback, 00); | 681 opj_set_warning_handler(l_codec, fx_warning_callback, 00); |
682 opj_set_error_handler(l_codec, fx_error_callback, 00); | 682 opj_set_error_handler(l_codec, fx_error_callback, 00); |
683 if (!opj_setup_decoder(l_codec, ¶meters)) { | 683 if (!opj_setup_decoder(l_codec, ¶meters)) { |
684 return FALSE; | 684 return FALSE; |
685 } | 685 } |
686 if (!opj_read_header(l_stream, l_codec, &image)) { | 686 if (!opj_read_header(l_stream, l_codec, &image)) { |
687 image = NULL; | 687 image = NULL; |
688 return FALSE; | 688 return FALSE; |
689 } | 689 } |
| 690 image->pdfium_use_colorspace = m_UseColorSpace; |
| 691 |
690 if (!parameters.nb_tile_to_decode) { | 692 if (!parameters.nb_tile_to_decode) { |
691 if (!opj_set_decode_area(l_codec, image, parameters.DA_x0, parameters.DA_y0, | 693 if (!opj_set_decode_area(l_codec, image, parameters.DA_x0, parameters.DA_y0, |
692 parameters.DA_x1, parameters.DA_y1)) { | 694 parameters.DA_x1, parameters.DA_y1)) { |
693 opj_image_destroy(image); | 695 opj_image_destroy(image); |
694 image = NULL; | 696 image = NULL; |
695 return FALSE; | 697 return FALSE; |
696 } | 698 } |
697 if (!(opj_decode(l_codec, l_stream, image) && | 699 if (!(opj_decode(l_codec, l_stream, image) && |
698 opj_end_decompress(l_codec, l_stream))) { | 700 opj_end_decompress(l_codec, l_stream))) { |
699 opj_image_destroy(image); | 701 opj_image_destroy(image); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 FX_BOOL CCodec_JpxModule::Decode(CJPX_Decoder* pDecoder, | 844 FX_BOOL CCodec_JpxModule::Decode(CJPX_Decoder* pDecoder, |
843 uint8_t* dest_data, | 845 uint8_t* dest_data, |
844 int pitch, | 846 int pitch, |
845 uint8_t* offsets) { | 847 uint8_t* offsets) { |
846 return pDecoder->Decode(dest_data, pitch, offsets); | 848 return pDecoder->Decode(dest_data, pitch, offsets); |
847 } | 849 } |
848 | 850 |
849 void CCodec_JpxModule::DestroyDecoder(CJPX_Decoder* pDecoder) { | 851 void CCodec_JpxModule::DestroyDecoder(CJPX_Decoder* pDecoder) { |
850 delete pDecoder; | 852 delete pDecoder; |
851 } | 853 } |
OLD | NEW |