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 "../../../../third_party/base/nonstd_unique_ptr.h" | 7 #include "../../../../third_party/base/nonstd_unique_ptr.h" |
8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
9 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 9 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
10 #include "../../../include/fpdfapi/fpdf_render.h" | 10 #include "../../../include/fpdfapi/fpdf_render.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 m_bpp = 1; | 263 m_bpp = 1; |
264 } else if (m_bpc * m_nComponents <= 8) { | 264 } else if (m_bpc * m_nComponents <= 8) { |
265 m_bpp = 8; | 265 m_bpp = 8; |
266 } else { | 266 } else { |
267 m_bpp = 24; | 267 m_bpp = 24; |
268 } | 268 } |
269 FX_SAFE_DWORD pitch = CalculatePitch32(m_bpp, m_Width); | 269 FX_SAFE_DWORD pitch = CalculatePitch32(m_bpp, m_Width); |
270 if (!pitch.IsValid()) { | 270 if (!pitch.IsValid()) { |
271 return FALSE; | 271 return FALSE; |
272 } | 272 } |
273 m_pLineBuf = FX_Alloc(FX_BYTE, pitch.ValueOrDie()); | 273 m_pLineBuf = FX_Alloc(uint8_t, pitch.ValueOrDie()); |
274 if (m_pColorSpace && bStdCS) { | 274 if (m_pColorSpace && bStdCS) { |
275 m_pColorSpace->EnableStdConversion(TRUE); | 275 m_pColorSpace->EnableStdConversion(TRUE); |
276 } | 276 } |
277 LoadPalette(); | 277 LoadPalette(); |
278 if (m_bColorKey) { | 278 if (m_bColorKey) { |
279 m_bpp = 32; | 279 m_bpp = 32; |
280 m_AlphaFlag = 2; | 280 m_AlphaFlag = 2; |
281 pitch = CalculatePitch32(m_bpp, m_Width); | 281 pitch = CalculatePitch32(m_bpp, m_Width); |
282 if (!pitch.IsValid()) { | 282 if (!pitch.IsValid()) { |
283 return FALSE; | 283 return FALSE; |
284 } | 284 } |
285 m_pMaskedLine = FX_Alloc(FX_BYTE, pitch.ValueOrDie()); | 285 m_pMaskedLine = FX_Alloc(uint8_t, pitch.ValueOrDie()); |
286 } | 286 } |
287 m_Pitch = pitch.ValueOrDie(); | 287 m_Pitch = pitch.ValueOrDie(); |
288 if (ppMask) { | 288 if (ppMask) { |
289 *ppMask = LoadMask(*pMatteColor); | 289 *ppMask = LoadMask(*pMatteColor); |
290 } | 290 } |
291 if (m_pColorSpace && bStdCS) { | 291 if (m_pColorSpace && bStdCS) { |
292 m_pColorSpace->EnableStdConversion(FALSE); | 292 m_pColorSpace->EnableStdConversion(FALSE); |
293 } | 293 } |
294 return TRUE; | 294 return TRUE; |
295 } | 295 } |
(...skipping 11 matching lines...) Expand all Loading... |
307 } else { | 307 } else { |
308 m_bpp = 24; | 308 m_bpp = 24; |
309 } | 309 } |
310 if (!m_bpc || !m_nComponents) { | 310 if (!m_bpc || !m_nComponents) { |
311 return 0; | 311 return 0; |
312 } | 312 } |
313 FX_SAFE_DWORD pitch = CalculatePitch32(m_bpp, m_Width); | 313 FX_SAFE_DWORD pitch = CalculatePitch32(m_bpp, m_Width); |
314 if (!pitch.IsValid()) { | 314 if (!pitch.IsValid()) { |
315 return 0; | 315 return 0; |
316 } | 316 } |
317 m_pLineBuf = FX_Alloc(FX_BYTE, pitch.ValueOrDie()); | 317 m_pLineBuf = FX_Alloc(uint8_t, pitch.ValueOrDie()); |
318 if (m_pColorSpace && m_bStdCS) { | 318 if (m_pColorSpace && m_bStdCS) { |
319 m_pColorSpace->EnableStdConversion(TRUE); | 319 m_pColorSpace->EnableStdConversion(TRUE); |
320 } | 320 } |
321 LoadPalette(); | 321 LoadPalette(); |
322 if (m_bColorKey) { | 322 if (m_bColorKey) { |
323 m_bpp = 32; | 323 m_bpp = 32; |
324 m_AlphaFlag = 2; | 324 m_AlphaFlag = 2; |
325 pitch = CalculatePitch32(m_bpp, m_Width); | 325 pitch = CalculatePitch32(m_bpp, m_Width); |
326 if (!pitch.IsValid()) { | 326 if (!pitch.IsValid()) { |
327 return 0; | 327 return 0; |
328 } | 328 } |
329 m_pMaskedLine = FX_Alloc(FX_BYTE, pitch.ValueOrDie()); | 329 m_pMaskedLine = FX_Alloc(uint8_t, pitch.ValueOrDie()); |
330 } | 330 } |
331 m_Pitch = pitch.ValueOrDie(); | 331 m_Pitch = pitch.ValueOrDie(); |
332 return 1; | 332 return 1; |
333 } | 333 } |
334 int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, const CPDF_Strea
m* pStream, FX_BOOL bHasMask, | 334 int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, const CPDF_Strea
m* pStream, FX_BOOL bHasMask, |
335 CPDF_Dictionary* pFormResources, CPDF_Dic
tionary* pPageResources, | 335 CPDF_Dictionary* pFormResources, CPDF_Dic
tionary* pPageResources, |
336 FX_BOOL bStdCS, FX_DWORD GroupFamily, FX_
BOOL bLoadMask) | 336 FX_BOOL bStdCS, FX_DWORD GroupFamily, FX_
BOOL bLoadMask) |
337 { | 337 { |
338 if (pStream == NULL) { | 338 if (pStream == NULL) { |
339 return 0; | 339 return 0; |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 } else { | 723 } else { |
724 width = (width * output_nComps + 2) / 3; | 724 width = (width * output_nComps + 2) / 3; |
725 format = FXDIB_Rgb; | 725 format = FXDIB_Rgb; |
726 } | 726 } |
727 m_pCachedBitmap.reset(new CFX_DIBitmap); | 727 m_pCachedBitmap.reset(new CFX_DIBitmap); |
728 if (!m_pCachedBitmap->Create(width, height, format)) { | 728 if (!m_pCachedBitmap->Create(width, height, format)) { |
729 m_pCachedBitmap.reset(); | 729 m_pCachedBitmap.reset(); |
730 return; | 730 return; |
731 } | 731 } |
732 m_pCachedBitmap->Clear(0xFFFFFFFF); | 732 m_pCachedBitmap->Clear(0xFFFFFFFF); |
733 context->set_output_offsets(FX_Alloc(unsigned char, output_nComps)); | 733 context->set_output_offsets(FX_Alloc(uint8_t, output_nComps)); |
734 for (int i = 0; i < output_nComps; ++i) | 734 for (int i = 0; i < output_nComps; ++i) |
735 context->output_offsets()[i] = i; | 735 context->output_offsets()[i] = i; |
736 if (bSwapRGB) { | 736 if (bSwapRGB) { |
737 context->output_offsets()[0] = 2; | 737 context->output_offsets()[0] = 2; |
738 context->output_offsets()[2] = 0; | 738 context->output_offsets()[2] = 0; |
739 } | 739 } |
740 if (!pJpxModule->Decode(context->context(), | 740 if (!pJpxModule->Decode(context->context(), |
741 m_pCachedBitmap->GetBuffer(), | 741 m_pCachedBitmap->GetBuffer(), |
742 m_pCachedBitmap->GetPitch(), | 742 m_pCachedBitmap->GetPitch(), |
743 bTranslateColor, | 743 bTranslateColor, |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 FX_FLOAT k = 1.0f - color_values[3]; | 1030 FX_FLOAT k = 1.0f - color_values[3]; |
1031 R = (1.0f - color_values[0]) * k; | 1031 R = (1.0f - color_values[0]) * k; |
1032 G = (1.0f - color_values[1]) * k; | 1032 G = (1.0f - color_values[1]) * k; |
1033 B = (1.0f - color_values[2]) * k; | 1033 B = (1.0f - color_values[2]) * k; |
1034 } else { | 1034 } else { |
1035 m_pColorSpace->GetRGB(color_values, R, G, B); | 1035 m_pColorSpace->GetRGB(color_values, R, G, B); |
1036 } | 1036 } |
1037 R = NORMALCOLOR_MAX(R, 1); | 1037 R = NORMALCOLOR_MAX(R, 1); |
1038 G = NORMALCOLOR_MAX(G, 1); | 1038 G = NORMALCOLOR_MAX(G, 1); |
1039 B = NORMALCOLOR_MAX(B, 1); | 1039 B = NORMALCOLOR_MAX(B, 1); |
1040 dest_scan[dest_byte_pos] = (FX_INT32)(B * 255); | 1040 dest_scan[dest_byte_pos] = (int32_t)(B * 255); |
1041 dest_scan[dest_byte_pos + 1] = (FX_INT32)(G * 255); | 1041 dest_scan[dest_byte_pos + 1] = (int32_t)(G * 255); |
1042 dest_scan[dest_byte_pos + 2] = (FX_INT32)(R * 255); | 1042 dest_scan[dest_byte_pos + 2] = (int32_t)(R * 255); |
1043 dest_byte_pos += 3; | 1043 dest_byte_pos += 3; |
1044 } | 1044 } |
1045 } else { | 1045 } else { |
1046 int src_bit_pos = 0; | 1046 int src_bit_pos = 0; |
1047 int dest_byte_pos = 0; | 1047 int dest_byte_pos = 0; |
1048 for (int column = 0; column < m_Width; column ++) { | 1048 for (int column = 0; column < m_Width; column ++) { |
1049 for (FX_DWORD color = 0; color < m_nComponents; color ++) { | 1049 for (FX_DWORD color = 0; color < m_nComponents; color ++) { |
1050 int data = _GetBits8(src_scan, src_bit_pos, m_bpc); | 1050 int data = _GetBits8(src_scan, src_bit_pos, m_bpc); |
1051 color_values[color] = m_pCompData[color].m_DecodeMin + | 1051 color_values[color] = m_pCompData[color].m_DecodeMin + |
1052 m_pCompData[color].m_DecodeStep * data; | 1052 m_pCompData[color].m_DecodeStep * data; |
1053 src_bit_pos += m_bpc; | 1053 src_bit_pos += m_bpc; |
1054 } | 1054 } |
1055 if (m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family ==
PDFCS_DEVICECMYK) { | 1055 if (m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family ==
PDFCS_DEVICECMYK) { |
1056 FX_FLOAT k = 1.0f - color_values[3]; | 1056 FX_FLOAT k = 1.0f - color_values[3]; |
1057 R = (1.0f - color_values[0]) * k; | 1057 R = (1.0f - color_values[0]) * k; |
1058 G = (1.0f - color_values[1]) * k; | 1058 G = (1.0f - color_values[1]) * k; |
1059 B = (1.0f - color_values[2]) * k; | 1059 B = (1.0f - color_values[2]) * k; |
1060 } else { | 1060 } else { |
1061 m_pColorSpace->GetRGB(color_values, R, G, B); | 1061 m_pColorSpace->GetRGB(color_values, R, G, B); |
1062 } | 1062 } |
1063 R = NORMALCOLOR_MAX(R, 1); | 1063 R = NORMALCOLOR_MAX(R, 1); |
1064 G = NORMALCOLOR_MAX(G, 1); | 1064 G = NORMALCOLOR_MAX(G, 1); |
1065 B = NORMALCOLOR_MAX(B, 1); | 1065 B = NORMALCOLOR_MAX(B, 1); |
1066 dest_scan[dest_byte_pos] = (FX_INT32)(B * 255); | 1066 dest_scan[dest_byte_pos] = (int32_t)(B * 255); |
1067 dest_scan[dest_byte_pos + 1] = (FX_INT32)(G * 255); | 1067 dest_scan[dest_byte_pos + 1] = (int32_t)(G * 255); |
1068 dest_scan[dest_byte_pos + 2] = (FX_INT32)(R * 255); | 1068 dest_scan[dest_byte_pos + 2] = (int32_t)(R * 255); |
1069 dest_byte_pos += 3; | 1069 dest_byte_pos += 3; |
1070 } | 1070 } |
1071 } | 1071 } |
1072 } | 1072 } |
1073 FX_LPBYTE CPDF_DIBSource::GetBuffer() const | 1073 FX_LPBYTE CPDF_DIBSource::GetBuffer() const |
1074 { | 1074 { |
1075 if (m_pCachedBitmap) { | 1075 if (m_pCachedBitmap) { |
1076 return m_pCachedBitmap->GetBuffer(); | 1076 return m_pCachedBitmap->GetBuffer(); |
1077 } | 1077 } |
1078 return NULL; | 1078 return NULL; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 color_index |= data << (color * m_bpc); | 1148 color_index |= data << (color * m_bpc); |
1149 src_bit_pos += m_bpc; | 1149 src_bit_pos += m_bpc; |
1150 } | 1150 } |
1151 m_pLineBuf[col] = color_index; | 1151 m_pLineBuf[col] = color_index; |
1152 } | 1152 } |
1153 } | 1153 } |
1154 if (m_bColorKey) { | 1154 if (m_bColorKey) { |
1155 FX_LPBYTE pDestPixel = m_pMaskedLine; | 1155 FX_LPBYTE pDestPixel = m_pMaskedLine; |
1156 FX_LPCBYTE pSrcPixel = m_pLineBuf; | 1156 FX_LPCBYTE pSrcPixel = m_pLineBuf; |
1157 for (int col = 0; col < m_Width; col ++) { | 1157 for (int col = 0; col < m_Width; col ++) { |
1158 FX_BYTE index = *pSrcPixel++; | 1158 uint8_t index = *pSrcPixel++; |
1159 if (m_pPalette) { | 1159 if (m_pPalette) { |
1160 *pDestPixel++ = FXARGB_B(m_pPalette[index]); | 1160 *pDestPixel++ = FXARGB_B(m_pPalette[index]); |
1161 *pDestPixel++ = FXARGB_G(m_pPalette[index]); | 1161 *pDestPixel++ = FXARGB_G(m_pPalette[index]); |
1162 *pDestPixel++ = FXARGB_R(m_pPalette[index]); | 1162 *pDestPixel++ = FXARGB_R(m_pPalette[index]); |
1163 } else { | 1163 } else { |
1164 *pDestPixel++ = index; | 1164 *pDestPixel++ = index; |
1165 *pDestPixel++ = index; | 1165 *pDestPixel++ = index; |
1166 *pDestPixel++ = index; | 1166 *pDestPixel++ = index; |
1167 } | 1167 } |
1168 *pDestPixel = (index < m_pCompData[0].m_ColorKeyMin || index > m
_pCompData[0].m_ColorKeyMax) ? 0xff : 0; | 1168 *pDestPixel = (index < m_pCompData[0].m_ColorKeyMin || index > m
_pCompData[0].m_ColorKeyMax) ? 0xff : 0; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 } | 1247 } |
1248 | 1248 |
1249 FX_SAFE_INT32 max_src_x = clip_left; | 1249 FX_SAFE_INT32 max_src_x = clip_left; |
1250 max_src_x += clip_width - 1; | 1250 max_src_x += clip_width - 1; |
1251 max_src_x *= src_width; | 1251 max_src_x *= src_width; |
1252 max_src_x /= dest_width; | 1252 max_src_x /= dest_width; |
1253 if (!max_src_x.IsValid()) { | 1253 if (!max_src_x.IsValid()) { |
1254 return; | 1254 return; |
1255 } | 1255 } |
1256 | 1256 |
1257 CFX_FixedBufGrow<FX_BYTE, 128> temp(orig_Bpp); | 1257 CFX_FixedBufGrow<uint8_t, 128> temp(orig_Bpp); |
1258 if (m_bpc * m_nComponents == 1) { | 1258 if (m_bpc * m_nComponents == 1) { |
1259 FX_DWORD set_argb = (FX_DWORD) - 1, reset_argb = 0; | 1259 FX_DWORD set_argb = (FX_DWORD) - 1, reset_argb = 0; |
1260 if (m_bImageMask) { | 1260 if (m_bImageMask) { |
1261 if (m_bDefaultDecode) { | 1261 if (m_bDefaultDecode) { |
1262 set_argb = 0; | 1262 set_argb = 0; |
1263 reset_argb = (FX_DWORD) - 1; | 1263 reset_argb = (FX_DWORD) - 1; |
1264 } | 1264 } |
1265 } else if (m_bColorKey) { | 1265 } else if (m_bColorKey) { |
1266 reset_argb = m_pPalette ? m_pPalette[0] : 0xff000000; | 1266 reset_argb = m_pPalette ? m_pPalette[0] : 0xff000000; |
1267 set_argb = m_pPalette ? m_pPalette[1] : 0xffffffff; | 1267 set_argb = m_pPalette ? m_pPalette[1] : 0xffffffff; |
(...skipping 27 matching lines...) Expand all Loading... |
1295 } | 1295 } |
1296 for (int i = 0; i < clip_width; i ++) { | 1296 for (int i = 0; i < clip_width; i ++) { |
1297 FX_DWORD src_x = (clip_left + i) * src_width / dest_width; | 1297 FX_DWORD src_x = (clip_left + i) * src_width / dest_width; |
1298 if (bFlipX) { | 1298 if (bFlipX) { |
1299 src_x = src_width - src_x - 1; | 1299 src_x = src_width - src_x - 1; |
1300 } | 1300 } |
1301 src_x %= src_width; | 1301 src_x %= src_width; |
1302 int dest_pos = i * dest_Bpp; | 1302 int dest_pos = i * dest_Bpp; |
1303 if (pSrcLine[src_x / 8] & (1 << (7 - src_x % 8))) { | 1303 if (pSrcLine[src_x / 8] & (1 << (7 - src_x % 8))) { |
1304 if (dest_Bpp == 1) { | 1304 if (dest_Bpp == 1) { |
1305 dest_scan[dest_pos] = (FX_BYTE)set_argb; | 1305 dest_scan[dest_pos] = (uint8_t)set_argb; |
1306 } else if (dest_Bpp == 3) { | 1306 } else if (dest_Bpp == 3) { |
1307 dest_scan[dest_pos] = FXARGB_B(set_argb); | 1307 dest_scan[dest_pos] = FXARGB_B(set_argb); |
1308 dest_scan[dest_pos + 1] = FXARGB_G(set_argb); | 1308 dest_scan[dest_pos + 1] = FXARGB_G(set_argb); |
1309 dest_scan[dest_pos + 2] = FXARGB_R(set_argb); | 1309 dest_scan[dest_pos + 2] = FXARGB_R(set_argb); |
1310 } else { | 1310 } else { |
1311 *(FX_DWORD*)(dest_scan + dest_pos) = set_argb; | 1311 *(FX_DWORD*)(dest_scan + dest_pos) = set_argb; |
1312 } | 1312 } |
1313 } else { | 1313 } else { |
1314 if (dest_Bpp == 1) { | 1314 if (dest_Bpp == 1) { |
1315 dest_scan[dest_pos] = (FX_BYTE)reset_argb; | 1315 dest_scan[dest_pos] = (uint8_t)reset_argb; |
1316 } else if (dest_Bpp == 3) { | 1316 } else if (dest_Bpp == 3) { |
1317 dest_scan[dest_pos] = FXARGB_B(reset_argb); | 1317 dest_scan[dest_pos] = FXARGB_B(reset_argb); |
1318 dest_scan[dest_pos + 1] = FXARGB_G(reset_argb); | 1318 dest_scan[dest_pos + 1] = FXARGB_G(reset_argb); |
1319 dest_scan[dest_pos + 2] = FXARGB_R(reset_argb); | 1319 dest_scan[dest_pos + 2] = FXARGB_R(reset_argb); |
1320 } else { | 1320 } else { |
1321 *(FX_DWORD*)(dest_scan + dest_pos) = reset_argb; | 1321 *(FX_DWORD*)(dest_scan + dest_pos) = reset_argb; |
1322 } | 1322 } |
1323 } | 1323 } |
1324 } | 1324 } |
1325 return; | 1325 return; |
(...skipping 12 matching lines...) Expand all Loading... |
1338 pSrcLine = m_pLineBuf; | 1338 pSrcLine = m_pLineBuf; |
1339 } | 1339 } |
1340 if (m_bColorKey) { | 1340 if (m_bColorKey) { |
1341 for (int i = 0; i < clip_width; i ++) { | 1341 for (int i = 0; i < clip_width; i ++) { |
1342 FX_DWORD src_x = (clip_left + i) * src_width / dest_width; | 1342 FX_DWORD src_x = (clip_left + i) * src_width / dest_width; |
1343 if (bFlipX) { | 1343 if (bFlipX) { |
1344 src_x = src_width - src_x - 1; | 1344 src_x = src_width - src_x - 1; |
1345 } | 1345 } |
1346 src_x %= src_width; | 1346 src_x %= src_width; |
1347 FX_LPBYTE pDestPixel = dest_scan + i * 4; | 1347 FX_LPBYTE pDestPixel = dest_scan + i * 4; |
1348 FX_BYTE index = pSrcLine[src_x]; | 1348 uint8_t index = pSrcLine[src_x]; |
1349 if (m_pPalette) { | 1349 if (m_pPalette) { |
1350 *pDestPixel++ = FXARGB_B(m_pPalette[index]); | 1350 *pDestPixel++ = FXARGB_B(m_pPalette[index]); |
1351 *pDestPixel++ = FXARGB_G(m_pPalette[index]); | 1351 *pDestPixel++ = FXARGB_G(m_pPalette[index]); |
1352 *pDestPixel++ = FXARGB_R(m_pPalette[index]); | 1352 *pDestPixel++ = FXARGB_R(m_pPalette[index]); |
1353 } else { | 1353 } else { |
1354 *pDestPixel++ = index; | 1354 *pDestPixel++ = index; |
1355 *pDestPixel++ = index; | 1355 *pDestPixel++ = index; |
1356 *pDestPixel++ = index; | 1356 *pDestPixel++ = index; |
1357 } | 1357 } |
1358 *pDestPixel = (index < m_pCompData[0].m_ColorKeyMin || index > m
_pCompData[0].m_ColorKeyMax) ? 0xff : 0; | 1358 *pDestPixel = (index < m_pCompData[0].m_ColorKeyMin || index > m
_pCompData[0].m_ColorKeyMax) ? 0xff : 0; |
1359 } | 1359 } |
1360 return; | 1360 return; |
1361 } | 1361 } |
1362 for (int i = 0; i < clip_width; i ++) { | 1362 for (int i = 0; i < clip_width; i ++) { |
1363 FX_DWORD src_x = (clip_left + i) * src_width / dest_width; | 1363 FX_DWORD src_x = (clip_left + i) * src_width / dest_width; |
1364 if (bFlipX) { | 1364 if (bFlipX) { |
1365 src_x = src_width - src_x - 1; | 1365 src_x = src_width - src_x - 1; |
1366 } | 1366 } |
1367 src_x %= src_width; | 1367 src_x %= src_width; |
1368 FX_BYTE index = pSrcLine[src_x]; | 1368 uint8_t index = pSrcLine[src_x]; |
1369 if (dest_Bpp == 1) { | 1369 if (dest_Bpp == 1) { |
1370 dest_scan[i] = index; | 1370 dest_scan[i] = index; |
1371 } else { | 1371 } else { |
1372 int dest_pos = i * dest_Bpp; | 1372 int dest_pos = i * dest_Bpp; |
1373 FX_ARGB argb = m_pPalette[index]; | 1373 FX_ARGB argb = m_pPalette[index]; |
1374 dest_scan[dest_pos] = FXARGB_B(argb); | 1374 dest_scan[dest_pos] = FXARGB_B(argb); |
1375 dest_scan[dest_pos + 1] = FXARGB_G(argb); | 1375 dest_scan[dest_pos + 1] = FXARGB_G(argb); |
1376 dest_scan[dest_pos + 2] = FXARGB_R(argb); | 1376 dest_scan[dest_pos + 2] = FXARGB_R(argb); |
1377 } | 1377 } |
1378 } | 1378 } |
1379 return; | 1379 return; |
1380 } else { | 1380 } else { |
1381 int last_src_x = -1; | 1381 int last_src_x = -1; |
1382 FX_ARGB last_argb; | 1382 FX_ARGB last_argb; |
1383 FX_FLOAT orig_Not8Bpp = (FX_FLOAT)m_bpc * (FX_FLOAT)m_nComponents / 8.0f
; | 1383 FX_FLOAT orig_Not8Bpp = (FX_FLOAT)m_bpc * (FX_FLOAT)m_nComponents / 8.0f
; |
1384 FX_FLOAT unit_To8Bpc = 255.0f / ((1 << m_bpc) - 1); | 1384 FX_FLOAT unit_To8Bpc = 255.0f / ((1 << m_bpc) - 1); |
1385 for (int i = 0; i < clip_width; i ++) { | 1385 for (int i = 0; i < clip_width; i ++) { |
1386 int dest_x = clip_left + i; | 1386 int dest_x = clip_left + i; |
1387 FX_DWORD src_x = (bFlipX ? (dest_width - dest_x - 1) : dest_x) * (FX
_INT64)src_width / dest_width; | 1387 FX_DWORD src_x = (bFlipX ? (dest_width - dest_x - 1) : dest_x) * (in
t64_t)src_width / dest_width; |
1388 src_x %= src_width; | 1388 src_x %= src_width; |
1389 FX_LPCBYTE pSrcPixel = NULL; | 1389 FX_LPCBYTE pSrcPixel = NULL; |
1390 if (m_bpc % 8 == 0) { | 1390 if (m_bpc % 8 == 0) { |
1391 pSrcPixel = pSrcLine + src_x * orig_Bpp; | 1391 pSrcPixel = pSrcLine + src_x * orig_Bpp; |
1392 } else { | 1392 } else { |
1393 pSrcPixel = pSrcLine + (int)(src_x * orig_Not8Bpp); | 1393 pSrcPixel = pSrcLine + (int)(src_x * orig_Not8Bpp); |
1394 } | 1394 } |
1395 FX_LPBYTE pDestPixel = dest_scan + i * dest_Bpp; | 1395 FX_LPBYTE pDestPixel = dest_scan + i * dest_Bpp; |
1396 FX_ARGB argb; | 1396 FX_ARGB argb; |
1397 if (src_x == last_src_x) { | 1397 if (src_x == last_src_x) { |
1398 argb = last_argb; | 1398 argb = last_argb; |
1399 } else { | 1399 } else { |
1400 if (m_pColorSpace) { | 1400 if (m_pColorSpace) { |
1401 FX_BYTE color[4]; | 1401 uint8_t color[4]; |
1402 if (!m_bDefaultDecode) { | 1402 if (!m_bDefaultDecode) { |
1403 for (int i = 0; i < m_nComponents; i ++) { | 1403 for (int i = 0; i < m_nComponents; i ++) { |
1404 int color_value = (int)((m_pCompData[i].m_DecodeMin
+ m_pCompData[i].m_DecodeStep * (FX_FLOAT)pSrcPixel[i]) * 255.0f + 0.5f); | 1404 int color_value = (int)((m_pCompData[i].m_DecodeMin
+ m_pCompData[i].m_DecodeStep * (FX_FLOAT)pSrcPixel[i]) * 255.0f + 0.5f); |
1405 temp[i] = color_value > 255 ? 255 : (color_value < 0
? 0 : color_value); | 1405 temp[i] = color_value > 255 ? 255 : (color_value < 0
? 0 : color_value); |
1406 } | 1406 } |
1407 m_pColorSpace->TranslateImageLine(color, temp, 1, 0, 0,
m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK
); | 1407 m_pColorSpace->TranslateImageLine(color, temp, 1, 0, 0,
m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK
); |
1408 } else { | 1408 } else { |
1409 if (m_bpc < 8) { | 1409 if (m_bpc < 8) { |
1410 int src_bit_pos = 0; | 1410 int src_bit_pos = 0; |
1411 if (src_x % 2) { | 1411 if (src_x % 2) { |
1412 src_bit_pos = 4; | 1412 src_bit_pos = 4; |
1413 } | 1413 } |
1414 for (FX_DWORD i = 0; i < m_nComponents; i ++) { | 1414 for (FX_DWORD i = 0; i < m_nComponents; i ++) { |
1415 temp[i] = (FX_BYTE)(_GetBits8(pSrcPixel, src_bit
_pos, m_bpc) * unit_To8Bpc); | 1415 temp[i] = (uint8_t)(_GetBits8(pSrcPixel, src_bit
_pos, m_bpc) * unit_To8Bpc); |
1416 src_bit_pos += m_bpc; | 1416 src_bit_pos += m_bpc; |
1417 } | 1417 } |
1418 m_pColorSpace->TranslateImageLine(color, temp, 1, 0,
0, m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICE
CMYK); | 1418 m_pColorSpace->TranslateImageLine(color, temp, 1, 0,
0, m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICE
CMYK); |
1419 } else { | 1419 } else { |
1420 m_pColorSpace->TranslateImageLine(color, pSrcPixel,
1, 0, 0, m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_D
EVICECMYK); | 1420 m_pColorSpace->TranslateImageLine(color, pSrcPixel,
1, 0, 0, m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_D
EVICECMYK); |
1421 } | 1421 } |
1422 } | 1422 } |
1423 argb = FXARGB_MAKE(0xff, color[2], color[1], color[0]); | 1423 argb = FXARGB_MAKE(0xff, color[2], color[1], color[0]); |
1424 } else { | 1424 } else { |
1425 argb = FXARGB_MAKE(0xff, pSrcPixel[2], pSrcPixel[1], pSrcPix
el[0]); | 1425 argb = FXARGB_MAKE(0xff, pSrcPixel[2], pSrcPixel[1], pSrcPix
el[0]); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1466 } | 1466 } |
1467 CPDF_ProgressiveImageLoaderHandle::CPDF_ProgressiveImageLoaderHandle() | 1467 CPDF_ProgressiveImageLoaderHandle::CPDF_ProgressiveImageLoaderHandle() |
1468 { | 1468 { |
1469 m_pImageLoader = NULL; | 1469 m_pImageLoader = NULL; |
1470 m_pCache = NULL; | 1470 m_pCache = NULL; |
1471 m_pImage = NULL; | 1471 m_pImage = NULL; |
1472 } | 1472 } |
1473 CPDF_ProgressiveImageLoaderHandle::~CPDF_ProgressiveImageLoaderHandle() | 1473 CPDF_ProgressiveImageLoaderHandle::~CPDF_ProgressiveImageLoaderHandle() |
1474 { | 1474 { |
1475 } | 1475 } |
1476 FX_BOOL CPDF_ProgressiveImageLoaderHandle::Start(CPDF_ImageLoader* pImageLoader,
const CPDF_ImageObject* pImage, CPDF_PageRenderCache* pCache, FX_BOOL bStdCS, F
X_DWORD GroupFamily, FX_BOOL bLoadMask, CPDF_RenderStatus* pRenderStatus, FX_INT
32 nDownsampleWidth, FX_INT32 nDownsampleHeight) | 1476 FX_BOOL CPDF_ProgressiveImageLoaderHandle::Start(CPDF_ImageLoader* pImageLoader,
const CPDF_ImageObject* pImage, CPDF_PageRenderCache* pCache, FX_BOOL bStdCS, F
X_DWORD GroupFamily, FX_BOOL bLoadMask, CPDF_RenderStatus* pRenderStatus, int32_
t nDownsampleWidth, int32_t nDownsampleHeight) |
1477 { | 1477 { |
1478 m_pImageLoader = pImageLoader; | 1478 m_pImageLoader = pImageLoader; |
1479 m_pCache = pCache; | 1479 m_pCache = pCache; |
1480 m_pImage = (CPDF_ImageObject*)pImage; | 1480 m_pImage = (CPDF_ImageObject*)pImage; |
1481 m_nDownsampleWidth = nDownsampleWidth; | 1481 m_nDownsampleWidth = nDownsampleWidth; |
1482 m_nDownsampleHeight = nDownsampleHeight; | 1482 m_nDownsampleHeight = nDownsampleHeight; |
1483 FX_BOOL ret; | 1483 FX_BOOL ret; |
1484 if (pCache) { | 1484 if (pCache) { |
1485 ret = pCache->StartGetCachedBitmap(pImage->m_pImage->GetStream(), bStdCS
, GroupFamily, bLoadMask, pRenderStatus, m_nDownsampleWidth, m_nDownsampleHeight
); | 1485 ret = pCache->StartGetCachedBitmap(pImage->m_pImage->GetStream(), bStdCS
, GroupFamily, bLoadMask, pRenderStatus, m_nDownsampleWidth, m_nDownsampleHeight
); |
1486 if (ret == FALSE) { | 1486 if (ret == FALSE) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 } | 1529 } |
1530 if (pCache) { | 1530 if (pCache) { |
1531 pCache->GetCachedBitmap(pImage->m_pImage->GetStream(), m_pBitmap, m_pMas
k, m_MatteColor, bStdCS, GroupFamily, bLoadMask, pRenderStatus, m_nDownsampleWid
th, m_nDownsampleHeight); | 1531 pCache->GetCachedBitmap(pImage->m_pImage->GetStream(), m_pBitmap, m_pMas
k, m_MatteColor, bStdCS, GroupFamily, bLoadMask, pRenderStatus, m_nDownsampleWid
th, m_nDownsampleHeight); |
1532 m_bCached = TRUE; | 1532 m_bCached = TRUE; |
1533 } else { | 1533 } else { |
1534 m_pBitmap = pImage->m_pImage->LoadDIBSource(&m_pMask, &m_MatteColor, bSt
dCS, GroupFamily, bLoadMask); | 1534 m_pBitmap = pImage->m_pImage->LoadDIBSource(&m_pMask, &m_MatteColor, bSt
dCS, GroupFamily, bLoadMask); |
1535 m_bCached = FALSE; | 1535 m_bCached = FALSE; |
1536 } | 1536 } |
1537 return FALSE; | 1537 return FALSE; |
1538 } | 1538 } |
1539 FX_BOOL CPDF_ImageLoader::StartLoadImage(const CPDF_ImageObject* pImage, CPDF_Pa
geRenderCache* pCache, FX_LPVOID& LoadHandle, FX_BOOL bStdCS, FX_DWORD GroupFami
ly, FX_BOOL bLoadMask, CPDF_RenderStatus* pRenderStatus, FX_INT32 nDownsampleWid
th, FX_INT32 nDownsampleHeight) | 1539 FX_BOOL CPDF_ImageLoader::StartLoadImage(const CPDF_ImageObject* pImage, CPDF_Pa
geRenderCache* pCache, FX_LPVOID& LoadHandle, FX_BOOL bStdCS, FX_DWORD GroupFami
ly, FX_BOOL bLoadMask, CPDF_RenderStatus* pRenderStatus, int32_t nDownsampleWidt
h, int32_t nDownsampleHeight) |
1540 { | 1540 { |
1541 m_nDownsampleWidth = nDownsampleWidth; | 1541 m_nDownsampleWidth = nDownsampleWidth; |
1542 m_nDownsampleHeight = nDownsampleHeight; | 1542 m_nDownsampleHeight = nDownsampleHeight; |
1543 CPDF_ProgressiveImageLoaderHandle* pLoaderHandle = new CPDF_ProgressiveImage
LoaderHandle; | 1543 CPDF_ProgressiveImageLoaderHandle* pLoaderHandle = new CPDF_ProgressiveImage
LoaderHandle; |
1544 FX_BOOL ret = pLoaderHandle->Start(this, pImage, pCache, bStdCS, GroupFamily
, bLoadMask, pRenderStatus, m_nDownsampleWidth, m_nDownsampleHeight); | 1544 FX_BOOL ret = pLoaderHandle->Start(this, pImage, pCache, bStdCS, GroupFamily
, bLoadMask, pRenderStatus, m_nDownsampleWidth, m_nDownsampleHeight); |
1545 LoadHandle = pLoaderHandle; | 1545 LoadHandle = pLoaderHandle; |
1546 return ret; | 1546 return ret; |
1547 } | 1547 } |
1548 FX_BOOL CPDF_ImageLoader::Continue(FX_LPVOID LoadHandle, IFX_Pause* pPause) | 1548 FX_BOOL CPDF_ImageLoader::Continue(FX_LPVOID LoadHandle, IFX_Pause* pPause) |
1549 { | 1549 { |
1550 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause); | 1550 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause); |
1551 } | 1551 } |
1552 CPDF_ImageLoader::~CPDF_ImageLoader() | 1552 CPDF_ImageLoader::~CPDF_ImageLoader() |
1553 { | 1553 { |
1554 if (!m_bCached) { | 1554 if (!m_bCached) { |
1555 delete m_pBitmap; | 1555 delete m_pBitmap; |
1556 delete m_pMask; | 1556 delete m_pMask; |
1557 } | 1557 } |
1558 } | 1558 } |
OLD | NEW |