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/fxge/fx_dib.h" | 7 #include "core/include/fxge/fx_dib.h" |
8 | 8 |
9 #include <limits.h> | 9 #include <limits.h> |
10 | 10 |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 alpha = FXARGB_A(color); | 463 alpha = FXARGB_A(color); |
464 dst_color = FXARGB_TODIB(color); | 464 dst_color = FXARGB_TODIB(color); |
465 } | 465 } |
466 uint8_t* color_p = (uint8_t*)&dst_color; | 466 uint8_t* color_p = (uint8_t*)&dst_color; |
467 if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() && | 467 if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() && |
468 CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { | 468 CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { |
469 ICodec_IccModule* pIccModule = | 469 ICodec_IccModule* pIccModule = |
470 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | 470 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
471 pIccModule->TranslateScanline(pIccTransform, color_p, color_p, 1); | 471 pIccModule->TranslateScanline(pIccTransform, color_p, color_p, 1); |
472 } else { | 472 } else { |
473 if (alpha_flag >> 8 && !IsCmykImage()) | 473 if (alpha_flag >> 8 && !IsCmykImage()) { |
474 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), | 474 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), |
475 FXSYS_GetYValue(color), FXSYS_GetKValue(color), | 475 FXSYS_GetYValue(color), FXSYS_GetKValue(color), |
476 color_p[2], color_p[1], color_p[0]); | 476 color_p[2], color_p[1], color_p[0]); |
477 else if (!(alpha_flag >> 8) && IsCmykImage()) { | 477 } else if (!(alpha_flag >> 8) && IsCmykImage()) { |
478 return FALSE; | 478 return FALSE; |
479 } | 479 } |
480 } | 480 } |
481 if (!IsCmykImage()) { | 481 if (!IsCmykImage()) { |
482 color_p[3] = (uint8_t)alpha; | 482 color_p[3] = (uint8_t)alpha; |
483 } | 483 } |
484 if (GetFormat() == FXDIB_Argb) { | 484 if (GetFormat() == FXDIB_Argb) { |
485 for (int row = 0; row < height; row++) { | 485 for (int row = 0; row < height; row++) { |
486 FX_DWORD* dest_pos = | 486 FX_DWORD* dest_pos = |
487 (FX_DWORD*)(m_pBuffer + (dest_top + row) * m_Pitch + dest_left * 4); | 487 (FX_DWORD*)(m_pBuffer + (dest_top + row) * m_Pitch + dest_left * 4); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 return FALSE; | 696 return FALSE; |
697 } | 697 } |
698 if (GetBPP() < 24) { | 698 if (GetBPP() < 24) { |
699 if (HasAlpha()) { | 699 if (HasAlpha()) { |
700 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb)) { | 700 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb)) { |
701 if (pSrcClone != pSrcBitmap) { | 701 if (pSrcClone != pSrcBitmap) { |
702 delete pSrcClone; | 702 delete pSrcClone; |
703 } | 703 } |
704 return FALSE; | 704 return FALSE; |
705 } | 705 } |
706 } else | |
707 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 706 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
708 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb32)) { | 707 } else if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb32)) { |
709 #else | 708 #else |
710 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb)) { | 709 } else if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb)) { |
711 #endif | 710 #endif |
712 if (pSrcClone != pSrcBitmap) { | 711 if (pSrcClone != pSrcBitmap) { |
713 delete pSrcClone; | 712 delete pSrcClone; |
714 } | 713 } |
715 return FALSE; | 714 return FALSE; |
716 } | 715 } |
717 } | 716 } |
718 destOffset = g_ChannelOffset[destChannel]; | 717 destOffset = g_ChannelOffset[destChannel]; |
719 } | 718 } |
720 if (srcChannel == FXDIB_Alpha && pSrcClone->m_pAlphaMask) { | 719 if (srcChannel == FXDIB_Alpha && pSrcClone->m_pAlphaMask) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 } | 789 } |
791 } else { | 790 } else { |
792 if (IsAlphaMask()) { | 791 if (IsAlphaMask()) { |
793 return FALSE; | 792 return FALSE; |
794 } | 793 } |
795 if (GetBPP() < 24) { | 794 if (GetBPP() < 24) { |
796 if (HasAlpha()) { | 795 if (HasAlpha()) { |
797 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb)) { | 796 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb)) { |
798 return FALSE; | 797 return FALSE; |
799 } | 798 } |
800 } else | |
801 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 799 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
802 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb)) { | 800 } else if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb)) { |
| 801 #else |
| 802 } else if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb32)) { |
| 803 #endif |
803 return FALSE; | 804 return FALSE; |
804 } | 805 } |
805 #else | |
806 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb32)) { | |
807 return FALSE; | |
808 } | |
809 #endif | |
810 } | 806 } |
811 destOffset = g_ChannelOffset[destChannel]; | 807 destOffset = g_ChannelOffset[destChannel]; |
812 } | 808 } |
813 int Bpp = GetBPP() / 8; | 809 int Bpp = GetBPP() / 8; |
814 if (Bpp == 1) { | 810 if (Bpp == 1) { |
815 FXSYS_memset(m_pBuffer, value, m_Height * m_Pitch); | 811 FXSYS_memset(m_pBuffer, value, m_Height * m_Pitch); |
816 return TRUE; | 812 return TRUE; |
817 } | 813 } |
818 if (destChannel == FXDIB_Alpha && m_pAlphaMask) { | 814 if (destChannel == FXDIB_Alpha && m_pAlphaMask) { |
819 FXSYS_memset(m_pAlphaMask->GetBuffer(), value, | 815 FXSYS_memset(m_pAlphaMask->GetBuffer(), value, |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 uint8_t b, g, r; | 1253 uint8_t b, g, r; |
1258 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(m_pPalette[i]), | 1254 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(m_pPalette[i]), |
1259 FXSYS_GetMValue(m_pPalette[i]), | 1255 FXSYS_GetMValue(m_pPalette[i]), |
1260 FXSYS_GetYValue(m_pPalette[i]), | 1256 FXSYS_GetYValue(m_pPalette[i]), |
1261 FXSYS_GetKValue(m_pPalette[i]), r, g, b); | 1257 FXSYS_GetKValue(m_pPalette[i]), r, g, b); |
1262 int gray = 255 - FXRGB2GRAY(r, g, b); | 1258 int gray = 255 - FXRGB2GRAY(r, g, b); |
1263 m_pPalette[i] = CmykEncode( | 1259 m_pPalette[i] = CmykEncode( |
1264 bc + (fc - bc) * gray / 255, bm + (fm - bm) * gray / 255, | 1260 bc + (fc - bc) * gray / 255, bm + (fm - bm) * gray / 255, |
1265 by + (fy - by) * gray / 255, bk + (fk - bk) * gray / 255); | 1261 by + (fy - by) * gray / 255, bk + (fk - bk) * gray / 255); |
1266 } | 1262 } |
1267 } else | 1263 } else { |
1268 for (int i = 0; i < size; i++) { | 1264 for (int i = 0; i < size; i++) { |
1269 int gray = FXRGB2GRAY(FXARGB_R(m_pPalette[i]), FXARGB_G(m_pPalette[i]), | 1265 int gray = FXRGB2GRAY(FXARGB_R(m_pPalette[i]), FXARGB_G(m_pPalette[i]), |
1270 FXARGB_B(m_pPalette[i])); | 1266 FXARGB_B(m_pPalette[i])); |
1271 m_pPalette[i] = FXARGB_MAKE(0xff, br + (fr - br) * gray / 255, | 1267 m_pPalette[i] = FXARGB_MAKE(0xff, br + (fr - br) * gray / 255, |
1272 bg + (fg - bg) * gray / 255, | 1268 bg + (fg - bg) * gray / 255, |
1273 bb + (fb - bb) * gray / 255); | 1269 bb + (fb - bb) * gray / 255); |
1274 } | 1270 } |
| 1271 } |
1275 return TRUE; | 1272 return TRUE; |
1276 } | 1273 } |
1277 if (isCmykImage) { | 1274 if (isCmykImage) { |
1278 if (forecolor == 0xff && backcolor == 0x00) { | 1275 if (forecolor == 0xff && backcolor == 0x00) { |
1279 for (int row = 0; row < m_Height; row++) { | 1276 for (int row = 0; row < m_Height; row++) { |
1280 uint8_t* scanline = m_pBuffer + row * m_Pitch; | 1277 uint8_t* scanline = m_pBuffer + row * m_Pitch; |
1281 for (int col = 0; col < m_Width; col++) { | 1278 for (int col = 0; col < m_Width; col++) { |
1282 uint8_t b, g, r; | 1279 uint8_t b, g, r; |
1283 AdobeCMYK_to_sRGB1(scanline[0], scanline[1], scanline[2], scanline[3], | 1280 AdobeCMYK_to_sRGB1(scanline[0], scanline[1], scanline[2], scanline[3], |
1284 r, g, b); | 1281 r, g, b); |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 if (!m_pBitmap->Create(width, height, src_format)) { | 1712 if (!m_pBitmap->Create(width, height, src_format)) { |
1716 delete m_pBitmap; | 1713 delete m_pBitmap; |
1717 m_pBitmap = NULL; | 1714 m_pBitmap = NULL; |
1718 return FALSE; | 1715 return FALSE; |
1719 } | 1716 } |
1720 if (pSrcPalette) { | 1717 if (pSrcPalette) { |
1721 m_pBitmap->CopyPalette(pSrcPalette); | 1718 m_pBitmap->CopyPalette(pSrcPalette); |
1722 } | 1719 } |
1723 return TRUE; | 1720 return TRUE; |
1724 } | 1721 } |
OLD | NEW |