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/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
8 #include "../../../include/fxcodec/fx_codec.h" | 8 #include "../../../include/fxcodec/fx_codec.h" |
9 #include "../../../include/fpdfapi/fpdf_module.h" | 9 #include "../../../include/fpdfapi/fpdf_module.h" |
10 #include "../../../include/fpdfapi/fpdf_render.h" | 10 #include "../../../include/fpdfapi/fpdf_render.h" |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 } | 904 } |
905 m_pColorSpace->GetRGB(temp_buf, R, G, B); | 905 m_pColorSpace->GetRGB(temp_buf, R, G, B); |
906 FX_Free(temp_buf); | 906 FX_Free(temp_buf); |
907 } else { | 907 } else { |
908 m_pColorSpace->GetRGB(color_value, R, G, B); | 908 m_pColorSpace->GetRGB(color_value, R, G, B); |
909 } | 909 } |
910 SetPaletteArgb(i, ArgbEncode(255, FXSYS_round(R * 255), FXSYS_round(
G * 255), FXSYS_round(B * 255))); | 910 SetPaletteArgb(i, ArgbEncode(255, FXSYS_round(R * 255), FXSYS_round(
G * 255), FXSYS_round(B * 255))); |
911 } | 911 } |
912 } | 912 } |
913 } | 913 } |
914 | |
915 FX_DWORD CPDF_DIBSource::GetValidBpp() const | 914 FX_DWORD CPDF_DIBSource::GetValidBpp() const |
916 { | 915 { |
917 FX_DWORD bpc = m_bpc; | 916 FX_DWORD bpc = m_bpc; |
918 CPDF_Object * pFilter = m_pDict->GetElementValue(FX_BSTRC("Filter")); | 917 CPDF_Object * pFilter = m_pDict->GetElementValue(FX_BSTRC("Filter")); |
919 if(pFilter) | 918 if (pFilter) { |
920 { | 919 if (pFilter->GetType() == PDFOBJ_NAME) { |
921 if(pFilter->GetType() == PDFOBJ_NAME) | |
922 { | |
923 CFX_ByteString filter = pFilter->GetString(); | 920 CFX_ByteString filter = pFilter->GetString(); |
924 if(filter == FX_BSTRC("CCITTFaxDecode") || filter == FX_BSTRC("JBIG2
Decode") ) | 921 if (filter == FX_BSTRC("CCITTFaxDecode") || filter == FX_BSTRC("JBIG
2Decode")) { |
925 bpc = 1; | 922 bpc = 1; |
926 if(filter == FX_BSTRC("RunLengthDecode") || filter == FX_BSTRC("DCTD
ecode") ) | 923 } |
| 924 if (filter == FX_BSTRC("RunLengthDecode") || filter == FX_BSTRC("DCT
Decode")) { |
927 bpc = 8; | 925 bpc = 8; |
| 926 } |
| 927 } else if (pFilter->GetType() == PDFOBJ_ARRAY) { |
| 928 CPDF_Array *pArray = (CPDF_Array *)pFilter; |
| 929 if (pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("CCITTFacD
ecode") || |
| 930 pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("JBIG2
Decode")) { |
| 931 bpc = 1; |
| 932 } |
| 933 if (pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("RunLength
Decode") || |
| 934 pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("DCTDe
code")) { |
| 935 bpc = 8; |
| 936 } |
928 } | 937 } |
929 else if (pFilter->GetType() == PDFOBJ_ARRAY) | 938 } |
930 { | |
931 CPDF_Array *pArray = (CPDF_Array *) pFilter; | |
932 if( pArray->GetString(pArray->GetCount() -1) == FX_BSTRC("CCITTFacD
ecode") || | |
933 pArray->GetString(pArray->GetCount() -1) == FX_BSTRC("JBIG2Deco
de") ) | |
934 bpc = 1; | |
935 | |
936 if( pArray->GetString(pArray->GetCount() -1) == FX_BSTRC("RunLengt
hDecode") || | |
937 pArray->GetString(pArray->GetCount() -1) == FX_BSTRC("DCTDecode
") ) | |
938 bpc = 8; | |
939 } | |
940 } | |
941 | |
942 return bpc; | 939 return bpc; |
943 } | 940 } |
944 | |
945 #define NORMALCOLOR_MAX(color, max) (color) > (max) ? (max) : (color) < 0 ? 0 :
(color); | 941 #define NORMALCOLOR_MAX(color, max) (color) > (max) ? (max) : (color) < 0 ? 0 :
(color); |
946 void CPDF_DIBSource::TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_
scan) const | 942 void CPDF_DIBSource::TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_
scan) const |
947 { | 943 { |
948 int max_data = (1 << m_bpc) - 1; | 944 int max_data = (1 << m_bpc) - 1; |
949 if (m_bDefaultDecode) { | 945 if (m_bDefaultDecode) { |
950 if (m_Family == PDFCS_DEVICERGB || m_Family == PDFCS_CALRGB) { | 946 if (m_Family == PDFCS_DEVICERGB || m_Family == PDFCS_CALRGB) { |
951 if (m_bpc == 16) { | 947 if (m_bpc == 16) { |
952 FX_LPBYTE dest_pos = dest_scan; | 948 FX_LPBYTE dest_pos = dest_scan; |
953 FX_LPCBYTE src_pos = src_scan; | 949 FX_LPCBYTE src_pos = src_scan; |
954 for (int col = 0; col < m_Width; col ++) { | 950 for (int col = 0; col < m_Width; col ++) { |
955 *dest_scan++ = src_pos[4]; | 951 *dest_scan++ = src_pos[4]; |
956 *dest_scan++ = src_pos[2]; | 952 *dest_scan++ = src_pos[2]; |
957 *dest_scan++ = *src_pos; | 953 *dest_scan++ = *src_pos; |
958 src_pos += 6; | 954 src_pos += 6; |
959 } | 955 } |
960 } else if (m_bpc == 8) { | 956 } else if (m_bpc == 8) { |
961 FX_LPBYTE dest_pos = dest_scan; | 957 FX_LPBYTE dest_pos = dest_scan; |
962 FX_LPCBYTE src_pos = src_scan; | 958 FX_LPCBYTE src_pos = src_scan; |
963 for (int column = 0; column < m_Width; column ++) { | 959 for (int column = 0; column < m_Width; column ++) { |
964 *dest_scan++ = src_pos[2]; | 960 *dest_scan++ = src_pos[2]; |
965 *dest_scan++ = src_pos[1]; | 961 *dest_scan++ = src_pos[1]; |
966 *dest_scan++ = *src_pos; | 962 *dest_scan++ = *src_pos; |
967 src_pos += 3; | 963 src_pos += 3; |
968 } | 964 } |
969 } else { | 965 } else { |
970 int src_bit_pos = 0; | 966 int src_bit_pos = 0; |
971 int dest_byte_pos = 0; | 967 int dest_byte_pos = 0; |
972 | |
973 FX_DWORD bpc = GetValidBpp(); | 968 FX_DWORD bpc = GetValidBpp(); |
974 | |
975 for (int column = 0; column < m_Width; column ++) { | 969 for (int column = 0; column < m_Width; column ++) { |
976 int R = _GetBits8(src_scan, src_bit_pos, bpc); | 970 int R = _GetBits8(src_scan, src_bit_pos, bpc); |
977 src_bit_pos += bpc; | 971 src_bit_pos += bpc; |
978 int G = _GetBits8(src_scan, src_bit_pos, bpc); | 972 int G = _GetBits8(src_scan, src_bit_pos, bpc); |
979 src_bit_pos += bpc; | 973 src_bit_pos += bpc; |
980 int B = _GetBits8(src_scan, src_bit_pos, bpc); | 974 int B = _GetBits8(src_scan, src_bit_pos, bpc); |
981 src_bit_pos += bpc; | 975 src_bit_pos += bpc; |
982 R = NORMALCOLOR_MAX(R, max_data); | 976 R = NORMALCOLOR_MAX(R, max_data); |
983 G = NORMALCOLOR_MAX(G, max_data); | 977 G = NORMALCOLOR_MAX(G, max_data); |
984 B = NORMALCOLOR_MAX(B, max_data); | 978 B = NORMALCOLOR_MAX(B, max_data); |
985 dest_scan[dest_byte_pos] = B * 255 / max_data; | 979 dest_scan[dest_byte_pos] = B * 255 / max_data; |
986 dest_scan[dest_byte_pos + 1] = G * 255 / max_data; | 980 dest_scan[dest_byte_pos + 1] = G * 255 / max_data; |
987 dest_scan[dest_byte_pos + 2] = R * 255 / max_data; | 981 dest_scan[dest_byte_pos + 2] = R * 255 / max_data; |
988 dest_byte_pos += 3; | 982 dest_byte_pos += 3; |
989 } | 983 } |
990 } | 984 } |
991 return; | 985 return; |
992 } else if (m_bpc == 8) { | 986 } else if (m_bpc == 8) { |
993 » » » if (m_nComponents == m_pColorSpace->CountComponents()) | 987 if (m_nComponents == m_pColorSpace->CountComponents()) |
994 » » » » m_pColorSpace->TranslateImageLine(dest_scan, src
_scan, m_Width, m_Width, m_Height, | 988 m_pColorSpace->TranslateImageLine(dest_scan, src_scan, m_Width,
m_Width, m_Height, |
995 m_bLoadMask && m_GroupFamily == PD
FCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK); | 989 m_bLoadMask && m_GroupFamily =
= PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK); |
996 return; | 990 return; |
997 } | 991 } |
998 } | 992 } |
999 CFX_FixedBufGrow<FX_FLOAT, 16> color_values1(m_nComponents); | 993 CFX_FixedBufGrow<FX_FLOAT, 16> color_values1(m_nComponents); |
1000 FX_FLOAT* color_values = color_values1; | 994 FX_FLOAT* color_values = color_values1; |
1001 FX_FLOAT R, G, B; | 995 FX_FLOAT R, G, B; |
1002 if (m_bpc == 8) { | 996 if (m_bpc == 8) { |
1003 int src_byte_pos = 0; | 997 int src_byte_pos = 0; |
1004 int dest_byte_pos = 0; | 998 int dest_byte_pos = 0; |
1005 for (int column = 0; column < m_Width; column ++) { | 999 for (int column = 0; column < m_Width; column ++) { |
(...skipping 14 matching lines...) Expand all Loading... |
1020 G = NORMALCOLOR_MAX(G, 1); | 1014 G = NORMALCOLOR_MAX(G, 1); |
1021 B = NORMALCOLOR_MAX(B, 1); | 1015 B = NORMALCOLOR_MAX(B, 1); |
1022 dest_scan[dest_byte_pos] = (FX_INT32)(B * 255); | 1016 dest_scan[dest_byte_pos] = (FX_INT32)(B * 255); |
1023 dest_scan[dest_byte_pos + 1] = (FX_INT32)(G * 255); | 1017 dest_scan[dest_byte_pos + 1] = (FX_INT32)(G * 255); |
1024 dest_scan[dest_byte_pos + 2] = (FX_INT32)(R * 255); | 1018 dest_scan[dest_byte_pos + 2] = (FX_INT32)(R * 255); |
1025 dest_byte_pos += 3; | 1019 dest_byte_pos += 3; |
1026 } | 1020 } |
1027 } else { | 1021 } else { |
1028 int src_bit_pos = 0; | 1022 int src_bit_pos = 0; |
1029 int dest_byte_pos = 0; | 1023 int dest_byte_pos = 0; |
1030 | |
1031 FX_DWORD bpc = GetValidBpp(); | 1024 FX_DWORD bpc = GetValidBpp(); |
1032 | |
1033 for (int column = 0; column < m_Width; column ++) { | 1025 for (int column = 0; column < m_Width; column ++) { |
1034 for (FX_DWORD color = 0; color < m_nComponents; color ++) { | 1026 for (FX_DWORD color = 0; color < m_nComponents; color ++) { |
1035 int data = _GetBits8(src_scan, src_bit_pos, bpc); | 1027 int data = _GetBits8(src_scan, src_bit_pos, bpc); |
1036 color_values[color] = m_pCompData[color].m_DecodeMin + | 1028 color_values[color] = m_pCompData[color].m_DecodeMin + |
1037 m_pCompData[color].m_DecodeStep * data; | 1029 m_pCompData[color].m_DecodeStep * data; |
1038 src_bit_pos += bpc; | 1030 src_bit_pos += bpc; |
1039 } | 1031 } |
1040 if (m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family ==
PDFCS_DEVICECMYK) { | 1032 if (m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family ==
PDFCS_DEVICECMYK) { |
1041 FX_FLOAT k = 1.0f - color_values[3]; | 1033 FX_FLOAT k = 1.0f - color_values[3]; |
1042 R = (1.0f - color_values[0]) * k; | 1034 R = (1.0f - color_values[0]) * k; |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 if (!m_bCached) { | 1507 if (!m_bCached) { |
1516 if (m_pBitmap) { | 1508 if (m_pBitmap) { |
1517 delete m_pBitmap; | 1509 delete m_pBitmap; |
1518 m_pBitmap = NULL; | 1510 m_pBitmap = NULL; |
1519 } | 1511 } |
1520 if (m_pMask) { | 1512 if (m_pMask) { |
1521 delete m_pMask; | 1513 delete m_pMask; |
1522 } | 1514 } |
1523 } | 1515 } |
1524 } | 1516 } |
OLD | NEW |