| 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 <setjmp.h> | 7 #include <setjmp.h> |
| 8 | 8 |
| 9 #include "../../../include/fxcodec/fx_codec.h" | 9 #include "../../../include/fxcodec/fx_codec.h" |
| 10 #include "../../../include/fxcrt/fx_safe_types.h" | 10 #include "../../../include/fxcrt/fx_safe_types.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 186 } |
| 187 jpeg_start_compress(&cinfo, TRUE); | 187 jpeg_start_compress(&cinfo, TRUE); |
| 188 _JpegEmbedIccProfile(&cinfo, icc_buf, icc_length); | 188 _JpegEmbedIccProfile(&cinfo, icc_buf, icc_length); |
| 189 JSAMPROW row_pointer[1]; | 189 JSAMPROW row_pointer[1]; |
| 190 JDIMENSION row; | 190 JDIMENSION row; |
| 191 while (cinfo.next_scanline < cinfo.image_height) { | 191 while (cinfo.next_scanline < cinfo.image_height) { |
| 192 const uint8_t* src_scan = pSource->GetScanline(cinfo.next_scanline); | 192 const uint8_t* src_scan = pSource->GetScanline(cinfo.next_scanline); |
| 193 if (nComponents > 1) { | 193 if (nComponents > 1) { |
| 194 uint8_t* dest_scan = line_buf; | 194 uint8_t* dest_scan = line_buf; |
| 195 if (nComponents == 3) { | 195 if (nComponents == 3) { |
| 196 for (int i = 0; i < width; i++) { | 196 for (FX_DWORD i = 0; i < width; i++) { |
| 197 dest_scan[0] = src_scan[2]; | 197 dest_scan[0] = src_scan[2]; |
| 198 dest_scan[1] = src_scan[1]; | 198 dest_scan[1] = src_scan[1]; |
| 199 dest_scan[2] = src_scan[0]; | 199 dest_scan[2] = src_scan[0]; |
| 200 dest_scan += 3; | 200 dest_scan += 3; |
| 201 src_scan += Bpp; | 201 src_scan += Bpp; |
| 202 } | 202 } |
| 203 } else { | 203 } else { |
| 204 for (int i = 0; i < pitch; i++) { | 204 for (FX_DWORD i = 0; i < pitch; i++) { |
| 205 *dest_scan++ = ~*src_scan++; | 205 *dest_scan++ = ~*src_scan++; |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 row_pointer[0] = line_buf; | 208 row_pointer[0] = line_buf; |
| 209 } else { | 209 } else { |
| 210 row_pointer[0] = (uint8_t*)src_scan; | 210 row_pointer[0] = (uint8_t*)src_scan; |
| 211 } | 211 } |
| 212 row = cinfo.next_scanline; | 212 row = cinfo.next_scanline; |
| 213 jpeg_write_scanlines(&cinfo, row_pointer, 1); | 213 jpeg_write_scanlines(&cinfo, row_pointer, 1); |
| 214 if (cinfo.next_scanline == row) { | 214 if (cinfo.next_scanline == row) { |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 } | 707 } |
| 708 if (avail_buf_ptr != NULL) { | 708 if (avail_buf_ptr != NULL) { |
| 709 *avail_buf_ptr = NULL; | 709 *avail_buf_ptr = NULL; |
| 710 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { | 710 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { |
| 711 *avail_buf_ptr = | 711 *avail_buf_ptr = |
| 712 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; | 712 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; |
| 713 } | 713 } |
| 714 } | 714 } |
| 715 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; | 715 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; |
| 716 } | 716 } |
| OLD | NEW |