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 "../../../include/fxcodec/fx_codec.h" | 7 #include "../../../include/fxcodec/fx_codec.h" |
8 #include "../../../include/fxge/fx_dib.h" | 8 #include "../../../include/fxge/fx_dib.h" |
9 #include "codec_int.h" | 9 #include "codec_int.h" |
10 extern "C" { | 10 extern "C" { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 cinfo.input_components = nComponents; | 146 cinfo.input_components = nComponents; |
147 if (nComponents == 1) { | 147 if (nComponents == 1) { |
148 cinfo.in_color_space = JCS_GRAYSCALE; | 148 cinfo.in_color_space = JCS_GRAYSCALE; |
149 } else if (nComponents == 3) { | 149 } else if (nComponents == 3) { |
150 cinfo.in_color_space = JCS_RGB; | 150 cinfo.in_color_space = JCS_RGB; |
151 } else { | 151 } else { |
152 cinfo.in_color_space = JCS_CMYK; | 152 cinfo.in_color_space = JCS_CMYK; |
153 } | 153 } |
154 FX_LPBYTE line_buf = NULL; | 154 FX_LPBYTE line_buf = NULL; |
155 if (nComponents > 1) { | 155 if (nComponents > 1) { |
156 line_buf = FX_Alloc(FX_BYTE, width * nComponents); | 156 line_buf = FX_Alloc2D(FX_BYTE, width, nComponents); |
157 if (line_buf == NULL) { | |
158 return; | |
159 } | |
160 } | 157 } |
161 jpeg_set_defaults(&cinfo); | 158 jpeg_set_defaults(&cinfo); |
162 if(quality != 75) { | 159 if(quality != 75) { |
163 jpeg_set_quality(&cinfo, quality, TRUE); | 160 jpeg_set_quality(&cinfo, quality, TRUE); |
164 } | 161 } |
165 jpeg_start_compress(&cinfo, TRUE); | 162 jpeg_start_compress(&cinfo, TRUE); |
166 _JpegEmbedIccProfile(&cinfo, icc_buf, icc_length); | 163 _JpegEmbedIccProfile(&cinfo, icc_buf, icc_length); |
167 JSAMPROW row_pointer[1]; | 164 JSAMPROW row_pointer[1]; |
168 JDIMENSION row; | 165 JDIMENSION row; |
169 while (cinfo.next_scanline < cinfo.image_height) { | 166 while (cinfo.next_scanline < cinfo.image_height) { |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 return m_pExtProvider->GetAvailInput(pContext, avail_buf_ptr); | 658 return m_pExtProvider->GetAvailInput(pContext, avail_buf_ptr); |
662 } | 659 } |
663 if(avail_buf_ptr != NULL) { | 660 if(avail_buf_ptr != NULL) { |
664 *avail_buf_ptr = NULL; | 661 *avail_buf_ptr = NULL; |
665 if(((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { | 662 if(((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { |
666 *avail_buf_ptr = (FX_LPBYTE)((FXJPEG_Context*)pContext)->m_SrcMgr.ne
xt_input_byte; | 663 *avail_buf_ptr = (FX_LPBYTE)((FXJPEG_Context*)pContext)->m_SrcMgr.ne
xt_input_byte; |
667 } | 664 } |
668 } | 665 } |
669 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; | 666 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; |
670 } | 667 } |
OLD | NEW |