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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
912 if (pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("CCITTFacD ecode") || | 912 if (pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("CCITTFacD ecode") || |
913 pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("JBIG2 Decode")) { | 913 pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("JBIG2 Decode")) { |
914 bpc = 1; | 914 bpc = 1; |
915 } | 915 } |
916 if (pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("RunLength Decode") || | 916 if (pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("RunLength Decode") || |
917 pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("DCTDe code")) { | 917 pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("DCTDe code")) { |
918 bpc = 8; | 918 bpc = 8; |
919 } | 919 } |
920 } | 920 } |
921 } | 921 } |
922 if (bpc != 1 && bpc != 2 && bpc != 4 && bpc != 8 && bpc != 12 && bpc != 16) { | |
923 bpc = 0; | |
924 } | |
925 | |
922 return bpc; | 926 return bpc; |
923 } | 927 } |
924 #define NORMALCOLOR_MAX(color, max) (color) > (max) ? (max) : (color) < 0 ? 0 : (color); | 928 #define NORMALCOLOR_MAX(color, max) (color) > (max) ? (max) : (color) < 0 ? 0 : (color); |
925 void CPDF_DIBSource::TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_ scan) const | 929 void CPDF_DIBSource::TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_ scan) const |
926 { | 930 { |
927 int max_data = (1 << m_bpc) - 1; | 931 FX_DWORD bpc = GetValidBpc(); |
932 if (bpc == 0) { | |
933 return; | |
934 } | |
935 int max_data = (1 << bpc) - 1; | |
928 if (m_bDefaultDecode) { | 936 if (m_bDefaultDecode) { |
929 if (m_Family == PDFCS_DEVICERGB || m_Family == PDFCS_CALRGB) { | 937 if (m_Family == PDFCS_DEVICERGB || m_Family == PDFCS_CALRGB) { |
930 if (m_bpc == 16) { | 938 FX_LPCBYTE src_pos = src_scan; |
931 FX_LPCBYTE src_pos = src_scan; | 939 switch (bpc){ |
Tom Sepez
2014/08/01 21:10:48
nit: space after )
Bo Xu
2014/08/01 23:13:52
Done.
| |
932 for (int col = 0; col < m_Width; col ++) { | 940 case 16: |
933 *dest_scan++ = src_pos[4]; | 941 for (int col = 0; col < m_Width; col ++) { |
934 *dest_scan++ = src_pos[2]; | 942 *dest_scan++ = src_pos[4]; |
935 *dest_scan++ = *src_pos; | 943 *dest_scan++ = src_pos[2]; |
936 src_pos += 6; | 944 *dest_scan++ = *src_pos; |
937 } | 945 src_pos += 6; |
938 } else if (m_bpc == 8) { | 946 } |
939 FX_LPCBYTE src_pos = src_scan; | 947 break; |
940 for (int column = 0; column < m_Width; column ++) { | 948 case 8: |
941 *dest_scan++ = src_pos[2]; | 949 for (int column = 0; column < m_Width; column ++) { |
942 *dest_scan++ = src_pos[1]; | 950 *dest_scan++ = src_pos[2]; |
943 *dest_scan++ = *src_pos; | 951 *dest_scan++ = src_pos[1]; |
944 src_pos += 3; | 952 *dest_scan++ = *src_pos; |
945 } | 953 src_pos += 3; |
946 } else { | 954 } |
947 int src_bit_pos = 0; | 955 break; |
948 int dest_byte_pos = 0; | 956 default: |
949 FX_DWORD bpc = GetValidBpc(); | 957 int src_bit_pos = 0; |
950 for (int column = 0; column < m_Width; column ++) { | 958 int dest_byte_pos = 0; |
951 int R = _GetBits8(src_scan, src_bit_pos, bpc); | 959 for (int column = 0; column < m_Width; column ++) { |
952 src_bit_pos += bpc; | 960 int R = _GetBits8(src_scan, src_bit_pos, bpc); |
953 int G = _GetBits8(src_scan, src_bit_pos, bpc); | 961 src_bit_pos += bpc; |
954 src_bit_pos += bpc; | 962 int G = _GetBits8(src_scan, src_bit_pos, bpc); |
955 int B = _GetBits8(src_scan, src_bit_pos, bpc); | 963 src_bit_pos += bpc; |
956 src_bit_pos += bpc; | 964 int B = _GetBits8(src_scan, src_bit_pos, bpc); |
957 R = NORMALCOLOR_MAX(R, max_data); | 965 src_bit_pos += bpc; |
958 G = NORMALCOLOR_MAX(G, max_data); | 966 R = NORMALCOLOR_MAX(R, max_data); |
959 B = NORMALCOLOR_MAX(B, max_data); | 967 G = NORMALCOLOR_MAX(G, max_data); |
960 dest_scan[dest_byte_pos] = B * 255 / max_data; | 968 B = NORMALCOLOR_MAX(B, max_data); |
961 dest_scan[dest_byte_pos + 1] = G * 255 / max_data; | 969 dest_scan[dest_byte_pos] = B * 255 / max_data; |
962 dest_scan[dest_byte_pos + 2] = R * 255 / max_data; | 970 dest_scan[dest_byte_pos + 1] = G * 255 / max_data; |
963 dest_byte_pos += 3; | 971 dest_scan[dest_byte_pos + 2] = R * 255 / max_data; |
972 dest_byte_pos += 3; | |
964 } | 973 } |
Tom Sepez
2014/08/01 21:10:48
nit: some picky people might insist on a break her
Bo Xu
2014/08/01 23:13:52
Done.
| |
965 } | 974 } |
966 return; | 975 return; |
967 } else if (m_bpc == 8) { | 976 } else if (bpc == 8) { |
968 if (m_nComponents == m_pColorSpace->CountComponents()) | 977 if (m_nComponents == m_pColorSpace->CountComponents()) |
969 m_pColorSpace->TranslateImageLine(dest_scan, src_scan, m_Width, m_Width, m_Height, | 978 m_pColorSpace->TranslateImageLine(dest_scan, src_scan, m_Width, m_Width, m_Height, |
970 m_bLoadMask && m_GroupFamily = = PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK); | 979 m_bLoadMask && m_GroupFamily = = PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK); |
971 return; | 980 return; |
972 } | 981 } |
973 } | 982 } |
974 CFX_FixedBufGrow<FX_FLOAT, 16> color_values1(m_nComponents); | 983 CFX_FixedBufGrow<FX_FLOAT, 16> color_values1(m_nComponents); |
975 FX_FLOAT* color_values = color_values1; | 984 FX_FLOAT* color_values = color_values1; |
976 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; | 985 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; |
977 if (m_bpc == 8) { | 986 if (bpc == 8) { |
978 int src_byte_pos = 0; | 987 int src_byte_pos = 0; |
979 int dest_byte_pos = 0; | 988 int dest_byte_pos = 0; |
980 for (int column = 0; column < m_Width; column ++) { | 989 for (int column = 0; column < m_Width; column ++) { |
981 for (FX_DWORD color = 0; color < m_nComponents; color ++) { | 990 for (FX_DWORD color = 0; color < m_nComponents; color ++) { |
982 int data = src_scan[src_byte_pos ++]; | 991 int data = src_scan[src_byte_pos ++]; |
983 color_values[color] = m_pCompData[color].m_DecodeMin + | 992 color_values[color] = m_pCompData[color].m_DecodeMin + |
984 m_pCompData[color].m_DecodeStep * data; | 993 m_pCompData[color].m_DecodeStep * data; |
985 } | 994 } |
986 if (m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK) { | 995 if (m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK) { |
987 FX_FLOAT k = 1.0f - color_values[3]; | 996 FX_FLOAT k = 1.0f - color_values[3]; |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1516 if (!m_bCached) { | 1525 if (!m_bCached) { |
1517 if (m_pBitmap) { | 1526 if (m_pBitmap) { |
1518 delete m_pBitmap; | 1527 delete m_pBitmap; |
1519 m_pBitmap = NULL; | 1528 m_pBitmap = NULL; |
1520 } | 1529 } |
1521 if (m_pMask) { | 1530 if (m_pMask) { |
1522 delete m_pMask; | 1531 delete m_pMask; |
1523 } | 1532 } |
1524 } | 1533 } |
1525 } | 1534 } |
OLD | NEW |