| 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 "core/include/fxcodec/fx_codec.h" | 7 #include "core/include/fxcodec/fx_codec.h" |
| 8 #include "core/include/fxge/fx_dib.h" | 8 #include "core/include/fxge/fx_dib.h" |
| 9 #include "core/include/fxge/fx_ge.h" | 9 #include "core/include/fxge/fx_ge.h" |
| 10 | 10 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 256); | 382 256); |
| 383 } else { | 383 } else { |
| 384 if (pSrcBitmap->IsCmykImage()) { | 384 if (pSrcBitmap->IsCmykImage()) { |
| 385 uint8_t r, g, b; | 385 uint8_t r, g, b; |
| 386 for (int i = 0; i < 256; i++) { | 386 for (int i = 0; i < 256; i++) { |
| 387 AdobeCMYK_to_sRGB1( | 387 AdobeCMYK_to_sRGB1( |
| 388 FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(src_plt[i]), | 388 FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(src_plt[i]), |
| 389 FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]), r, g, b); | 389 FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]), r, g, b); |
| 390 gray[i] = FXRGB2GRAY(r, g, b); | 390 gray[i] = FXRGB2GRAY(r, g, b); |
| 391 } | 391 } |
| 392 } else | 392 } else { |
| 393 for (int i = 0; i < 256; i++) { | 393 for (int i = 0; i < 256; i++) { |
| 394 gray[i] = FXRGB2GRAY(FXARGB_R(src_plt[i]), FXARGB_G(src_plt[i]), | 394 gray[i] = FXRGB2GRAY(FXARGB_R(src_plt[i]), FXARGB_G(src_plt[i]), |
| 395 FXARGB_B(src_plt[i])); | 395 FXARGB_B(src_plt[i])); |
| 396 } | 396 } |
| 397 } |
| 397 } | 398 } |
| 398 for (int row = 0; row < height; row++) { | 399 for (int row = 0; row < height; row++) { |
| 399 uint8_t* dest_scan = dest_buf + row * dest_pitch; | 400 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
| 400 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left; | 401 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left; |
| 401 for (int col = 0; col < width; col++) { | 402 for (int col = 0; col < width; col++) { |
| 402 *dest_scan++ = gray[*src_scan++]; | 403 *dest_scan++ = gray[*src_scan++]; |
| 403 } | 404 } |
| 404 } | 405 } |
| 405 return TRUE; | 406 return TRUE; |
| 406 } | 407 } |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 FX_BOOL ret = TRUE; | 1098 FX_BOOL ret = TRUE; |
| 1098 CFX_DIBitmap* pSrcAlpha = NULL; | 1099 CFX_DIBitmap* pSrcAlpha = NULL; |
| 1099 if (HasAlpha()) { | 1100 if (HasAlpha()) { |
| 1100 pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask; | 1101 pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask; |
| 1101 if (!pSrcAlpha) { | 1102 if (!pSrcAlpha) { |
| 1102 delete pClone; | 1103 delete pClone; |
| 1103 return NULL; | 1104 return NULL; |
| 1104 } | 1105 } |
| 1105 } | 1106 } |
| 1106 if (dest_format & 0x0200) { | 1107 if (dest_format & 0x0200) { |
| 1107 if (dest_format == FXDIB_Argb) | 1108 if (dest_format == FXDIB_Argb) { |
| 1108 ret = pSrcAlpha ? pClone->LoadChannel(FXDIB_Alpha, pSrcAlpha, FXDIB_Alpha) | 1109 ret = pSrcAlpha ? pClone->LoadChannel(FXDIB_Alpha, pSrcAlpha, FXDIB_Alpha) |
| 1109 : pClone->LoadChannel(FXDIB_Alpha, 0xff); | 1110 : pClone->LoadChannel(FXDIB_Alpha, 0xff); |
| 1110 else { | 1111 } else { |
| 1111 ret = pClone->CopyAlphaMask(pSrcAlpha); | 1112 ret = pClone->CopyAlphaMask(pSrcAlpha); |
| 1112 } | 1113 } |
| 1113 } | 1114 } |
| 1114 if (pSrcAlpha && pSrcAlpha != m_pAlphaMask) { | 1115 if (pSrcAlpha && pSrcAlpha != m_pAlphaMask) { |
| 1115 delete pSrcAlpha; | 1116 delete pSrcAlpha; |
| 1116 pSrcAlpha = NULL; | 1117 pSrcAlpha = NULL; |
| 1117 } | 1118 } |
| 1118 if (!ret) { | 1119 if (!ret) { |
| 1119 delete pClone; | 1120 delete pClone; |
| 1120 return NULL; | 1121 return NULL; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 if (!m_bExtBuf) { | 1218 if (!m_bExtBuf) { |
| 1218 FX_Free(m_pBuffer); | 1219 FX_Free(m_pBuffer); |
| 1219 } | 1220 } |
| 1220 m_bExtBuf = FALSE; | 1221 m_bExtBuf = FALSE; |
| 1221 m_pBuffer = dest_buf; | 1222 m_pBuffer = dest_buf; |
| 1222 m_bpp = (uint8_t)dest_format; | 1223 m_bpp = (uint8_t)dest_format; |
| 1223 m_AlphaFlag = (uint8_t)(dest_format >> 8); | 1224 m_AlphaFlag = (uint8_t)(dest_format >> 8); |
| 1224 m_Pitch = dest_pitch; | 1225 m_Pitch = dest_pitch; |
| 1225 return TRUE; | 1226 return TRUE; |
| 1226 } | 1227 } |
| OLD | NEW |