| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 cinfo.input_components = nComponents; | 208 cinfo.input_components = nComponents; |
| 209 if (nComponents == 1) { | 209 if (nComponents == 1) { |
| 210 cinfo.in_color_space = JCS_GRAYSCALE; | 210 cinfo.in_color_space = JCS_GRAYSCALE; |
| 211 } else if (nComponents == 3) { | 211 } else if (nComponents == 3) { |
| 212 cinfo.in_color_space = JCS_RGB; | 212 cinfo.in_color_space = JCS_RGB; |
| 213 } else { | 213 } else { |
| 214 cinfo.in_color_space = JCS_CMYK; | 214 cinfo.in_color_space = JCS_CMYK; |
| 215 } | 215 } |
| 216 FX_LPBYTE line_buf = NULL; | 216 FX_LPBYTE line_buf = NULL; |
| 217 if (nComponents > 1) { | 217 if (nComponents > 1) { |
| 218 line_buf = FX_Alloc(FX_BYTE, width * nComponents); | 218 line_buf = FX_Alloc2D(FX_BYTE, width, nComponents); |
| 219 if (line_buf == NULL) { | |
| 220 return; | |
| 221 } | |
| 222 } | 219 } |
| 223 jpeg_set_defaults(&cinfo); | 220 jpeg_set_defaults(&cinfo); |
| 224 if(quality != 75) { | 221 if(quality != 75) { |
| 225 jpeg_set_quality(&cinfo, quality, TRUE); | 222 jpeg_set_quality(&cinfo, quality, TRUE); |
| 226 } | 223 } |
| 227 jpeg_start_compress(&cinfo, TRUE); | 224 jpeg_start_compress(&cinfo, TRUE); |
| 228 _JpegEmbedIccProfile(&cinfo, icc_buf, icc_length); | 225 _JpegEmbedIccProfile(&cinfo, icc_buf, icc_length); |
| 229 JSAMPROW row_pointer[1]; | 226 JSAMPROW row_pointer[1]; |
| 230 JDIMENSION row; | 227 JDIMENSION row; |
| 231 while (cinfo.next_scanline < cinfo.image_height) { | 228 while (cinfo.next_scanline < cinfo.image_height) { |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 return m_pExtProvider->GetAvailInput(pContext, avail_buf_ptr); | 732 return m_pExtProvider->GetAvailInput(pContext, avail_buf_ptr); |
| 736 } | 733 } |
| 737 if(avail_buf_ptr != NULL) { | 734 if(avail_buf_ptr != NULL) { |
| 738 *avail_buf_ptr = NULL; | 735 *avail_buf_ptr = NULL; |
| 739 if(((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { | 736 if(((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { |
| 740 *avail_buf_ptr = (FX_LPBYTE)((FXJPEG_Context*)pContext)->m_SrcMgr.ne
xt_input_byte; | 737 *avail_buf_ptr = (FX_LPBYTE)((FXJPEG_Context*)pContext)->m_SrcMgr.ne
xt_input_byte; |
| 741 } | 738 } |
| 742 } | 739 } |
| 743 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; | 740 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; |
| 744 } | 741 } |
| OLD | NEW |