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 if (bpc == 16) { |
Tom Sepez
2014/08/01 20:33:53
nit: someday down the road, this might be better s
Bo Xu
2014/08/01 21:03:01
Changed to switch statement.
| |
931 FX_LPCBYTE src_pos = src_scan; | 939 FX_LPCBYTE src_pos = src_scan; |
932 for (int col = 0; col < m_Width; col ++) { | 940 for (int col = 0; col < m_Width; col ++) { |
933 *dest_scan++ = src_pos[4]; | 941 *dest_scan++ = src_pos[4]; |
934 *dest_scan++ = src_pos[2]; | 942 *dest_scan++ = src_pos[2]; |
935 *dest_scan++ = *src_pos; | 943 *dest_scan++ = *src_pos; |
936 src_pos += 6; | 944 src_pos += 6; |
937 } | 945 } |
938 } else if (m_bpc == 8) { | 946 } |
Tom Sepez
2014/08/01 20:33:53
nit: this indentation style doesn't match what's i
Bo Xu
2014/08/01 21:03:01
Done.
| |
947 else if (bpc == 8) { | |
939 FX_LPCBYTE src_pos = src_scan; | 948 FX_LPCBYTE src_pos = src_scan; |
940 for (int column = 0; column < m_Width; column ++) { | 949 for (int column = 0; column < m_Width; column ++) { |
941 *dest_scan++ = src_pos[2]; | 950 *dest_scan++ = src_pos[2]; |
942 *dest_scan++ = src_pos[1]; | 951 *dest_scan++ = src_pos[1]; |
943 *dest_scan++ = *src_pos; | 952 *dest_scan++ = *src_pos; |
944 src_pos += 3; | 953 src_pos += 3; |
945 } | 954 } |
946 } else { | 955 } |
956 else { | |
947 int src_bit_pos = 0; | 957 int src_bit_pos = 0; |
948 int dest_byte_pos = 0; | 958 int dest_byte_pos = 0; |
949 FX_DWORD bpc = GetValidBpc(); | |
950 for (int column = 0; column < m_Width; column ++) { | 959 for (int column = 0; column < m_Width; column ++) { |
951 int R = _GetBits8(src_scan, src_bit_pos, bpc); | 960 int R = _GetBits8(src_scan, src_bit_pos, bpc); |
952 src_bit_pos += bpc; | 961 src_bit_pos += bpc; |
953 int G = _GetBits8(src_scan, src_bit_pos, bpc); | 962 int G = _GetBits8(src_scan, src_bit_pos, bpc); |
954 src_bit_pos += bpc; | 963 src_bit_pos += bpc; |
955 int B = _GetBits8(src_scan, src_bit_pos, bpc); | 964 int B = _GetBits8(src_scan, src_bit_pos, bpc); |
956 src_bit_pos += bpc; | 965 src_bit_pos += bpc; |
957 R = NORMALCOLOR_MAX(R, max_data); | 966 R = NORMALCOLOR_MAX(R, max_data); |
958 G = NORMALCOLOR_MAX(G, max_data); | 967 G = NORMALCOLOR_MAX(G, max_data); |
959 B = NORMALCOLOR_MAX(B, max_data); | 968 B = NORMALCOLOR_MAX(B, max_data); |
960 dest_scan[dest_byte_pos] = B * 255 / max_data; | 969 dest_scan[dest_byte_pos] = B * 255 / max_data; |
961 dest_scan[dest_byte_pos + 1] = G * 255 / max_data; | 970 dest_scan[dest_byte_pos + 1] = G * 255 / max_data; |
962 dest_scan[dest_byte_pos + 2] = R * 255 / max_data; | 971 dest_scan[dest_byte_pos + 2] = R * 255 / max_data; |
963 dest_byte_pos += 3; | 972 dest_byte_pos += 3; |
964 } | 973 } |
965 } | 974 } |
966 return; | 975 return; |
967 } else if (m_bpc == 8) { | 976 } |
977 else if (bpc == 8) { | |
968 if (m_nComponents == m_pColorSpace->CountComponents()) | 978 if (m_nComponents == m_pColorSpace->CountComponents()) |
969 m_pColorSpace->TranslateImageLine(dest_scan, src_scan, m_Width, m_Width, m_Height, | 979 m_pColorSpace->TranslateImageLine(dest_scan, src_scan, m_Width, m_Width, m_Height, |
970 m_bLoadMask && m_GroupFamily = = PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK); | 980 m_bLoadMask && m_GroupFamily = = PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK); |
971 return; | 981 return; |
972 } | 982 } |
973 } | 983 } |
974 CFX_FixedBufGrow<FX_FLOAT, 16> color_values1(m_nComponents); | 984 CFX_FixedBufGrow<FX_FLOAT, 16> color_values1(m_nComponents); |
975 FX_FLOAT* color_values = color_values1; | 985 FX_FLOAT* color_values = color_values1; |
976 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; | 986 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; |
977 if (m_bpc == 8) { | 987 if (bpc == 8) { |
978 int src_byte_pos = 0; | 988 int src_byte_pos = 0; |
979 int dest_byte_pos = 0; | 989 int dest_byte_pos = 0; |
980 for (int column = 0; column < m_Width; column ++) { | 990 for (int column = 0; column < m_Width; column ++) { |
981 for (FX_DWORD color = 0; color < m_nComponents; color ++) { | 991 for (FX_DWORD color = 0; color < m_nComponents; color ++) { |
982 int data = src_scan[src_byte_pos ++]; | 992 int data = src_scan[src_byte_pos ++]; |
983 color_values[color] = m_pCompData[color].m_DecodeMin + | 993 color_values[color] = m_pCompData[color].m_DecodeMin + |
984 m_pCompData[color].m_DecodeStep * data; | 994 m_pCompData[color].m_DecodeStep * data; |
985 } | 995 } |
986 if (m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK) { | 996 if (m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK) { |
987 FX_FLOAT k = 1.0f - color_values[3]; | 997 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) { | 1526 if (!m_bCached) { |
1517 if (m_pBitmap) { | 1527 if (m_pBitmap) { |
1518 delete m_pBitmap; | 1528 delete m_pBitmap; |
1519 m_pBitmap = NULL; | 1529 m_pBitmap = NULL; |
1520 } | 1530 } |
1521 if (m_pMask) { | 1531 if (m_pMask) { |
1522 delete m_pMask; | 1532 delete m_pMask; |
1523 } | 1533 } |
1524 } | 1534 } |
1525 } | 1535 } |
OLD | NEW |