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/fpdfapi/fpdf_module.h" | 7 #include "../../../include/fpdfapi/fpdf_module.h" |
8 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 8 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
9 #include "../../../include/fpdfapi/fpdf_render.h" | 9 #include "../../../include/fpdfapi/fpdf_render.h" |
10 #include "../../../include/fxcodec/fx_codec.h" | 10 #include "../../../include/fxcodec/fx_codec.h" |
11 #include "../../../include/fxcrt/fx_safe_types.h" | 11 #include "../../../include/fxcrt/fx_safe_types.h" |
12 #include "../../../include/fxge/fx_ge.h" | 12 #include "../../../include/fxge/fx_ge.h" |
13 #include "../fpdf_page/pageint.h" | 13 #include "../fpdf_page/pageint.h" |
14 #include "render_int.h" | 14 #include "render_int.h" |
15 | 15 |
16 FX_BOOL CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj, const CFX_A
ffineMatrix* pObj2Device) | 16 bool CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj, const CFX_Affi
neMatrix* pObj2Device) |
17 { | 17 { |
18 CPDF_ImageRenderer render; | 18 CPDF_ImageRenderer render; |
19 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) { | 19 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) { |
20 render.Continue(NULL); | 20 render.Continue(NULL); |
21 } | 21 } |
22 return render.m_Result; | 22 return render.m_Result; |
23 } | 23 } |
24 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, int left, int
top, FX_ARGB mask_argb, | 24 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, int left, int
top, FX_ARGB mask_argb, |
25 int bitmap_alpha, int blend_mode, int Transparency) | 25 int bitmap_alpha, int blend_mode, int Transparency) |
26 { | 26 { |
27 if (pDIBitmap == NULL) { | 27 if (pDIBitmap == NULL) { |
28 return; | 28 return; |
29 } | 29 } |
30 FX_BOOL bIsolated = Transparency & PDFTRANS_ISOLATED; | 30 bool bIsolated = Transparency & PDFTRANS_ISOLATED; |
31 FX_BOOL bGroup = Transparency & PDFTRANS_GROUP; | 31 bool bGroup = Transparency & PDFTRANS_GROUP; |
32 if (blend_mode == FXDIB_BLEND_NORMAL) { | 32 if (blend_mode == FXDIB_BLEND_NORMAL) { |
33 if (!pDIBitmap->IsAlphaMask()) { | 33 if (!pDIBitmap->IsAlphaMask()) { |
34 if (bitmap_alpha < 255) { | 34 if (bitmap_alpha < 255) { |
35 pDIBitmap->MultiplyAlpha(bitmap_alpha); | 35 pDIBitmap->MultiplyAlpha(bitmap_alpha); |
36 } | 36 } |
37 if (m_pDevice->SetDIBits(pDIBitmap, left, top)) { | 37 if (m_pDevice->SetDIBits(pDIBitmap, left, top)) { |
38 return; | 38 return; |
39 } | 39 } |
40 } else { | 40 } else { |
41 FX_DWORD fill_argb = m_Options.TranslateColor(mask_argb); | 41 FX_DWORD fill_argb = m_Options.TranslateColor(mask_argb); |
42 if (bitmap_alpha < 255) { | 42 if (bitmap_alpha < 255) { |
43 ((uint8_t*)&fill_argb)[3] = ((uint8_t*)&fill_argb)[3] * bitmap_a
lpha / 255; | 43 ((uint8_t*)&fill_argb)[3] = ((uint8_t*)&fill_argb)[3] * bitmap_a
lpha / 255; |
44 } | 44 } |
45 if (m_pDevice->SetBitMask(pDIBitmap, left, top, fill_argb)) { | 45 if (m_pDevice->SetBitMask(pDIBitmap, left, top, fill_argb)) { |
46 return; | 46 return; |
47 } | 47 } |
48 } | 48 } |
49 } | 49 } |
50 FX_BOOL bBackAlphaRequired = blend_mode && bIsolated && !m_bDropObjects; | 50 bool bBackAlphaRequired = blend_mode && bIsolated && !m_bDropObjects; |
51 FX_BOOL bGetBackGround = ((m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT))
|| | 51 bool bGetBackGround = ((m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT)) || |
52 (!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT)
&& (m_pDevice->GetRenderCaps() | 52 (!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT)
&& (m_pDevice->GetRenderCaps() |
53 & FXRC_GET_BITS) && !bBackAlphaRequired); | 53 & FXRC_GET_BITS) && !bBackAlphaRequired); |
54 if (bGetBackGround) { | 54 if (bGetBackGround) { |
55 if (bIsolated || !bGroup) { | 55 if (bIsolated || !bGroup) { |
56 if (pDIBitmap->IsAlphaMask()) { | 56 if (pDIBitmap->IsAlphaMask()) { |
57 return; | 57 return; |
58 } | 58 } |
59 m_pDevice->SetDIBits(pDIBitmap, left, top, blend_mode); | 59 m_pDevice->SetDIBits(pDIBitmap, left, top, blend_mode); |
60 } else { | 60 } else { |
61 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), top + pDIBitma
p->GetHeight()); | 61 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), top + pDIBitma
p->GetHeight()); |
62 rect.Intersect(m_pDevice->GetClipBox()); | 62 rect.Intersect(m_pDevice->GetClipBox()); |
63 CFX_DIBitmap* pClone = NULL; | 63 CFX_DIBitmap* pClone = NULL; |
64 FX_BOOL bClone = FALSE; | 64 bool bClone = false; |
65 if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { | 65 if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { |
66 bClone = TRUE; | 66 bClone = true; |
67 pClone = m_pDevice->GetBackDrop()->Clone(&rect); | 67 pClone = m_pDevice->GetBackDrop()->Clone(&rect); |
68 CFX_DIBitmap *pForeBitmap = m_pDevice->GetBitmap(); | 68 CFX_DIBitmap *pForeBitmap = m_pDevice->GetBitmap(); |
69 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHei
ght(), pForeBitmap, rect.left, rect.top); | 69 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHei
ght(), pForeBitmap, rect.left, rect.top); |
70 left = left >= 0 ? 0 : left; | 70 left = left >= 0 ? 0 : left; |
71 top = top >= 0 ? 0 : top; | 71 top = top >= 0 ? 0 : top; |
72 if (!pDIBitmap->IsAlphaMask()) | 72 if (!pDIBitmap->IsAlphaMask()) |
73 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->Ge
tHeight(), pDIBitmap, | 73 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->Ge
tHeight(), pDIBitmap, |
74 left, top, blend_mode); | 74 left, top, blend_mode); |
75 else | 75 else |
76 pClone->CompositeMask(0, 0, pClone->GetWidth(), pClone->GetH
eight(), pDIBitmap, | 76 pClone->CompositeMask(0, 0, pClone->GetWidth(), pClone->GetH
eight(), pDIBitmap, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 delete pBackdrop; | 111 delete pBackdrop; |
112 pBackdrop = pBackdrop1; | 112 pBackdrop = pBackdrop1; |
113 m_pDevice->SetDIBits(pBackdrop, back_left, back_top); | 113 m_pDevice->SetDIBits(pBackdrop, back_left, back_top); |
114 delete pBackdrop; | 114 delete pBackdrop; |
115 } | 115 } |
116 FX_COLORREF CPDF_TransferFunc::TranslateColor(FX_COLORREF rgb) | 116 FX_COLORREF CPDF_TransferFunc::TranslateColor(FX_COLORREF rgb) |
117 { | 117 { |
118 return FXSYS_RGB(m_Samples[FXSYS_GetRValue(rgb)], m_Samples[256 + FXSYS_GetG
Value(rgb)], | 118 return FXSYS_RGB(m_Samples[FXSYS_GetRValue(rgb)], m_Samples[256 + FXSYS_GetG
Value(rgb)], |
119 m_Samples[512 + FXSYS_GetBValue(rgb)]); | 119 m_Samples[512 + FXSYS_GetBValue(rgb)]); |
120 } | 120 } |
121 CFX_DIBSource* CPDF_TransferFunc::TranslateImage(const CFX_DIBSource* pSrc, FX_B
OOL bAutoDropSrc) | 121 CFX_DIBSource* CPDF_TransferFunc::TranslateImage(const CFX_DIBSource* pSrc, bool
bAutoDropSrc) |
122 { | 122 { |
123 CPDF_DIBTransferFunc* pDest = new CPDF_DIBTransferFunc(this); | 123 CPDF_DIBTransferFunc* pDest = new CPDF_DIBTransferFunc(this); |
124 pDest->LoadSrc(pSrc, bAutoDropSrc); | 124 pDest->LoadSrc(pSrc, bAutoDropSrc); |
125 return pDest; | 125 return pDest; |
126 } | 126 } |
127 FXDIB_Format CPDF_DIBTransferFunc::GetDestFormat() | 127 FXDIB_Format CPDF_DIBTransferFunc::GetDestFormat() |
128 { | 128 { |
129 if (m_pSrc->IsAlphaMask()) { | 129 if (m_pSrc->IsAlphaMask()) { |
130 return FXDIB_8bppMask; | 130 return FXDIB_8bppMask; |
131 } | 131 } |
132 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 132 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
133 return (m_pSrc->HasAlpha()) ? FXDIB_Argb : FXDIB_Rgb32; | 133 return (m_pSrc->HasAlpha()) ? FXDIB_Argb : FXDIB_Rgb32; |
134 #else | 134 #else |
135 return (m_pSrc->HasAlpha()) ? FXDIB_Argb : FXDIB_Rgb; | 135 return (m_pSrc->HasAlpha()) ? FXDIB_Argb : FXDIB_Rgb; |
136 #endif | 136 #endif |
137 } | 137 } |
138 CPDF_DIBTransferFunc::CPDF_DIBTransferFunc(const CPDF_TransferFunc* pTransferFun
c) | 138 CPDF_DIBTransferFunc::CPDF_DIBTransferFunc(const CPDF_TransferFunc* pTransferFun
c) |
139 { | 139 { |
140 m_RampR = pTransferFunc->m_Samples; | 140 m_RampR = pTransferFunc->m_Samples; |
141 m_RampG = &pTransferFunc->m_Samples[256]; | 141 m_RampG = &pTransferFunc->m_Samples[256]; |
142 m_RampB = &pTransferFunc->m_Samples[512]; | 142 m_RampB = &pTransferFunc->m_Samples[512]; |
143 } | 143 } |
144 void CPDF_DIBTransferFunc::TranslateScanline(uint8_t* dest_buf, const uint8_t* s
rc_buf) const | 144 void CPDF_DIBTransferFunc::TranslateScanline(uint8_t* dest_buf, const uint8_t* s
rc_buf) const |
145 { | 145 { |
146 int i; | 146 int i; |
147 FX_BOOL bSkip = FALSE; | 147 bool bSkip = false; |
148 switch (m_pSrc->GetFormat()) { | 148 switch (m_pSrc->GetFormat()) { |
149 case FXDIB_1bppRgb: { | 149 case FXDIB_1bppRgb: { |
150 int r0 = m_RampR[0], g0 = m_RampG[0], b0 = m_RampB[0]; | 150 int r0 = m_RampR[0], g0 = m_RampG[0], b0 = m_RampB[0]; |
151 int r1 = m_RampR[255], g1 = m_RampG[255], b1 = m_RampB[255]; | 151 int r1 = m_RampR[255], g1 = m_RampG[255], b1 = m_RampB[255]; |
152 for (i = 0; i < m_Width; i ++) { | 152 for (i = 0; i < m_Width; i ++) { |
153 if (src_buf[i / 8] & (1 << (7 - i % 8))) { | 153 if (src_buf[i / 8] & (1 << (7 - i % 8))) { |
154 *dest_buf++ = b1; | 154 *dest_buf++ = b1; |
155 *dest_buf++ = g1; | 155 *dest_buf++ = g1; |
156 *dest_buf++ = r1; | 156 *dest_buf++ = r1; |
157 } else { | 157 } else { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 for (i = 0; i < m_Width; i ++) { | 206 for (i = 0; i < m_Width; i ++) { |
207 *dest_buf++ = m_RampB[*(src_buf++)]; | 207 *dest_buf++ = m_RampB[*(src_buf++)]; |
208 *dest_buf++ = m_RampG[*(src_buf++)]; | 208 *dest_buf++ = m_RampG[*(src_buf++)]; |
209 *dest_buf++ = m_RampR[*(src_buf++)]; | 209 *dest_buf++ = m_RampR[*(src_buf++)]; |
210 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 210 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
211 dest_buf++; | 211 dest_buf++; |
212 #endif | 212 #endif |
213 } | 213 } |
214 break; | 214 break; |
215 case FXDIB_Rgb32: | 215 case FXDIB_Rgb32: |
216 bSkip = TRUE; | 216 bSkip = true; |
217 case FXDIB_Argb: | 217 case FXDIB_Argb: |
218 for (i = 0; i < m_Width; i ++) { | 218 for (i = 0; i < m_Width; i ++) { |
219 *dest_buf++ = m_RampB[*(src_buf++)]; | 219 *dest_buf++ = m_RampB[*(src_buf++)]; |
220 *dest_buf++ = m_RampG[*(src_buf++)]; | 220 *dest_buf++ = m_RampG[*(src_buf++)]; |
221 *dest_buf++ = m_RampR[*(src_buf++)]; | 221 *dest_buf++ = m_RampR[*(src_buf++)]; |
222 if (!bSkip) { | 222 if (!bSkip) { |
223 *dest_buf++ = *src_buf; | 223 *dest_buf++ = *src_buf; |
224 } | 224 } |
225 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 225 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
226 else { | 226 else { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 } else | 259 } else |
260 #endif | 260 #endif |
261 for (int i = 0; i < pixels; i ++) { | 261 for (int i = 0; i < pixels; i ++) { |
262 *dest_buf++ = m_RampB[*(src_buf++)]; | 262 *dest_buf++ = m_RampB[*(src_buf++)]; |
263 *dest_buf++ = m_RampG[*(src_buf++)]; | 263 *dest_buf++ = m_RampG[*(src_buf++)]; |
264 *dest_buf++ = m_RampR[*(src_buf++)]; | 264 *dest_buf++ = m_RampR[*(src_buf++)]; |
265 *dest_buf++ = *(src_buf++); | 265 *dest_buf++ = *(src_buf++); |
266 } | 266 } |
267 } | 267 } |
268 } | 268 } |
269 static FX_BOOL _IsSupported(CPDF_ColorSpace* pCS) | 269 static bool _IsSupported(CPDF_ColorSpace* pCS) |
270 { | 270 { |
271 if (pCS->GetFamily() == PDFCS_DEVICERGB || pCS->GetFamily() == PDFCS_DEVICEG
RAY || | 271 if (pCS->GetFamily() == PDFCS_DEVICERGB || pCS->GetFamily() == PDFCS_DEVICEG
RAY || |
272 pCS->GetFamily() == PDFCS_DEVICECMYK || pCS->GetFamily() == PDFCS_CA
LGRAY || | 272 pCS->GetFamily() == PDFCS_DEVICECMYK || pCS->GetFamily() == PDFCS_CA
LGRAY || |
273 pCS->GetFamily() == PDFCS_CALRGB) { | 273 pCS->GetFamily() == PDFCS_CALRGB) { |
274 return TRUE; | 274 return true; |
275 } | 275 } |
276 if (pCS->GetFamily() == PDFCS_INDEXED && _IsSupported(pCS->GetBaseCS())) { | 276 if (pCS->GetFamily() == PDFCS_INDEXED && _IsSupported(pCS->GetBaseCS())) { |
277 return TRUE; | 277 return true; |
278 } | 278 } |
279 return FALSE; | 279 return false; |
280 } | 280 } |
281 CPDF_ImageRenderer::CPDF_ImageRenderer() | 281 CPDF_ImageRenderer::CPDF_ImageRenderer() |
282 { | 282 { |
283 m_pRenderStatus = NULL; | 283 m_pRenderStatus = NULL; |
284 m_pImageObject = NULL; | 284 m_pImageObject = NULL; |
285 m_Result = TRUE; | 285 m_Result = true; |
286 m_Status = 0; | 286 m_Status = 0; |
287 m_pQuickStretcher = NULL; | 287 m_pQuickStretcher = NULL; |
288 m_pTransformer = NULL; | 288 m_pTransformer = NULL; |
289 m_DeviceHandle = NULL; | 289 m_DeviceHandle = NULL; |
290 m_LoadHandle = NULL; | 290 m_LoadHandle = NULL; |
291 m_pClone = NULL; | 291 m_pClone = NULL; |
292 m_bStdCS = FALSE; | 292 m_bStdCS = false; |
293 m_bPatternColor = FALSE; | 293 m_bPatternColor = false; |
294 m_BlendType = FXDIB_BLEND_NORMAL; | 294 m_BlendType = FXDIB_BLEND_NORMAL; |
295 m_pPattern = NULL; | 295 m_pPattern = NULL; |
296 m_pObj2Device = NULL; | 296 m_pObj2Device = NULL; |
297 } | 297 } |
298 CPDF_ImageRenderer::~CPDF_ImageRenderer() | 298 CPDF_ImageRenderer::~CPDF_ImageRenderer() |
299 { | 299 { |
300 delete m_pQuickStretcher; | 300 delete m_pQuickStretcher; |
301 delete m_pTransformer; | 301 delete m_pTransformer; |
302 if (m_DeviceHandle) { | 302 if (m_DeviceHandle) { |
303 m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle); | 303 m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle); |
304 } | 304 } |
305 delete (CPDF_ProgressiveImageLoaderHandle*)m_LoadHandle; | 305 delete (CPDF_ProgressiveImageLoaderHandle*)m_LoadHandle; |
306 delete m_pClone; | 306 delete m_pClone; |
307 } | 307 } |
308 FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() | 308 bool CPDF_ImageRenderer::StartLoadDIBSource() |
309 { | 309 { |
310 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); | 310 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); |
311 FX_RECT image_rect = image_rect_f.GetOutterRect(); | 311 FX_RECT image_rect = image_rect_f.GetOutterRect(); |
312 int dest_width = image_rect.Width(); | 312 int dest_width = image_rect.Width(); |
313 int dest_height = image_rect.Height(); | 313 int dest_height = image_rect.Height(); |
314 if (m_ImageMatrix.a < 0) { | 314 if (m_ImageMatrix.a < 0) { |
315 dest_width = -dest_width; | 315 dest_width = -dest_width; |
316 } | 316 } |
317 if (m_ImageMatrix.d > 0) { | 317 if (m_ImageMatrix.d > 0) { |
318 dest_height = -dest_height; | 318 dest_height = -dest_height; |
319 } | 319 } |
320 if (m_Loader.StartLoadImage(m_pImageObject, m_pRenderStatus->m_pContext->m_p
PageCache, m_LoadHandle, m_bStdCS, | 320 if (m_Loader.StartLoadImage(m_pImageObject, m_pRenderStatus->m_pContext->m_p
PageCache, m_LoadHandle, m_bStdCS, |
321 m_pRenderStatus->m_GroupFamily, m_pRenderStatus-
>m_bLoadMask, m_pRenderStatus, dest_width, dest_height)) { | 321 m_pRenderStatus->m_GroupFamily, m_pRenderStatus-
>m_bLoadMask, m_pRenderStatus, dest_width, dest_height)) { |
322 if (m_LoadHandle != NULL) { | 322 if (m_LoadHandle != NULL) { |
323 m_Status = 4; | 323 m_Status = 4; |
324 return TRUE; | 324 return true; |
325 } | 325 } |
326 return FALSE; | 326 return false; |
327 } | 327 } |
328 return FALSE; | 328 return false; |
329 } | 329 } |
330 FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() | 330 bool CPDF_ImageRenderer::StartRenderDIBSource() |
331 { | 331 { |
332 if (m_Loader.m_pBitmap == NULL) { | 332 if (m_Loader.m_pBitmap == NULL) { |
333 return FALSE; | 333 return false; |
334 } | 334 } |
335 m_BitmapAlpha = 255; | 335 m_BitmapAlpha = 255; |
336 const CPDF_GeneralStateData* pGeneralState = m_pImageObject->m_GeneralState; | 336 const CPDF_GeneralStateData* pGeneralState = m_pImageObject->m_GeneralState; |
337 if (pGeneralState) { | 337 if (pGeneralState) { |
338 m_BitmapAlpha = FXSYS_round(pGeneralState->m_FillAlpha * 255); | 338 m_BitmapAlpha = FXSYS_round(pGeneralState->m_FillAlpha * 255); |
339 } | 339 } |
340 m_pDIBSource = m_Loader.m_pBitmap; | 340 m_pDIBSource = m_Loader.m_pBitmap; |
341 if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_ALPHA && m_Loader
.m_pMask == NULL) { | 341 if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_ALPHA && m_Loader
.m_pMask == NULL) { |
342 return StartBitmapAlpha(); | 342 return StartBitmapAlpha(); |
343 } | 343 } |
344 if (pGeneralState && pGeneralState->m_pTR) { | 344 if (pGeneralState && pGeneralState->m_pTR) { |
345 if (!pGeneralState->m_pTransferFunc) { | 345 if (!pGeneralState->m_pTransferFunc) { |
346 ((CPDF_GeneralStateData*)pGeneralState)->m_pTransferFunc = m_pRender
Status->GetTransferFunc(pGeneralState->m_pTR); | 346 ((CPDF_GeneralStateData*)pGeneralState)->m_pTransferFunc = m_pRender
Status->GetTransferFunc(pGeneralState->m_pTR); |
347 } | 347 } |
348 if (pGeneralState->m_pTransferFunc && !pGeneralState->m_pTransferFunc->m
_bIdentity) { | 348 if (pGeneralState->m_pTransferFunc && !pGeneralState->m_pTransferFunc->m
_bIdentity) { |
349 m_pDIBSource = m_Loader.m_pBitmap = pGeneralState->m_pTransferFunc->
TranslateImage(m_Loader.m_pBitmap, !m_Loader.m_bCached); | 349 m_pDIBSource = m_Loader.m_pBitmap = pGeneralState->m_pTransferFunc->
TranslateImage(m_Loader.m_pBitmap, !m_Loader.m_bCached); |
350 if (m_Loader.m_bCached && m_Loader.m_pMask) { | 350 if (m_Loader.m_bCached && m_Loader.m_pMask) { |
351 m_Loader.m_pMask = m_Loader.m_pMask->Clone(); | 351 m_Loader.m_pMask = m_Loader.m_pMask->Clone(); |
352 } | 352 } |
353 m_Loader.m_bCached = FALSE; | 353 m_Loader.m_bCached = false; |
354 } | 354 } |
355 } | 355 } |
356 m_FillArgb = 0; | 356 m_FillArgb = 0; |
357 m_bPatternColor = FALSE; | 357 m_bPatternColor = false; |
358 m_pPattern = NULL; | 358 m_pPattern = NULL; |
359 if (m_pDIBSource->IsAlphaMask()) { | 359 if (m_pDIBSource->IsAlphaMask()) { |
360 CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor(); | 360 CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor(); |
361 if (pColor && pColor->IsPattern()) { | 361 if (pColor && pColor->IsPattern()) { |
362 m_pPattern = pColor->GetPattern(); | 362 m_pPattern = pColor->GetPattern(); |
363 if (m_pPattern != NULL) { | 363 if (m_pPattern != NULL) { |
364 m_bPatternColor = TRUE; | 364 m_bPatternColor = true; |
365 } | 365 } |
366 } | 366 } |
367 m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject); | 367 m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject); |
368 } else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) { | 368 } else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) { |
369 m_pClone = m_pDIBSource->Clone(); | 369 m_pClone = m_pDIBSource->Clone(); |
370 m_pClone->ConvertColorScale(m_pRenderStatus->m_Options.m_BackColor, m_pR
enderStatus->m_Options.m_ForeColor); | 370 m_pClone->ConvertColorScale(m_pRenderStatus->m_Options.m_BackColor, m_pR
enderStatus->m_Options.m_ForeColor); |
371 m_pDIBSource = m_pClone; | 371 m_pDIBSource = m_pClone; |
372 } | 372 } |
373 m_Flags = 0; | 373 m_Flags = 0; |
374 if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) { | 374 if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 if (pColorSpace) { | 423 if (pColorSpace) { |
424 int format = pColorSpace->GetFamily(); | 424 int format = pColorSpace->GetFamily(); |
425 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || form
at == PDFCS_DEVICEN) { | 425 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || form
at == PDFCS_DEVICEN) { |
426 m_BlendType = FXDIB_BLEND_DARKEN; | 426 m_BlendType = FXDIB_BLEND_DARKEN; |
427 } | 427 } |
428 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); | 428 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); |
429 } | 429 } |
430 } | 430 } |
431 return StartDIBSource(); | 431 return StartDIBSource(); |
432 } | 432 } |
433 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, const CPDF_PageObj
ect* pObj, const CFX_AffineMatrix* pObj2Device, FX_BOOL bStdCS, int blendType) | 433 bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, const CPDF_PageObject
* pObj, const CFX_AffineMatrix* pObj2Device, bool bStdCS, int blendType) |
434 { | 434 { |
435 m_pRenderStatus = pStatus; | 435 m_pRenderStatus = pStatus; |
436 m_bStdCS = bStdCS; | 436 m_bStdCS = bStdCS; |
437 m_pImageObject = (CPDF_ImageObject*)pObj; | 437 m_pImageObject = (CPDF_ImageObject*)pObj; |
438 m_BlendType = blendType; | 438 m_BlendType = blendType; |
439 m_pObj2Device = pObj2Device; | 439 m_pObj2Device = pObj2Device; |
440 CPDF_Dictionary* pOC = m_pImageObject->m_pImage->GetOC(); | 440 CPDF_Dictionary* pOC = m_pImageObject->m_pImage->GetOC(); |
441 if (pOC && m_pRenderStatus->m_Options.m_pOCContext && !m_pRenderStatus->m_Op
tions.m_pOCContext->CheckOCGVisible(pOC)) { | 441 if (pOC && m_pRenderStatus->m_Options.m_pOCContext && !m_pRenderStatus->m_Op
tions.m_pOCContext->CheckOCGVisible(pOC)) { |
442 return FALSE; | 442 return false; |
443 } | 443 } |
444 m_ImageMatrix = m_pImageObject->m_Matrix; | 444 m_ImageMatrix = m_pImageObject->m_Matrix; |
445 m_ImageMatrix.Concat(*pObj2Device); | 445 m_ImageMatrix.Concat(*pObj2Device); |
446 if (StartLoadDIBSource()) { | 446 if (StartLoadDIBSource()) { |
447 return TRUE; | 447 return true; |
448 } | 448 } |
449 return StartRenderDIBSource(); | 449 return StartRenderDIBSource(); |
450 } | 450 } |
451 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, const CFX_DIBSourc
e* pDIBSource, FX_ARGB bitmap_argb, | 451 bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, const CFX_DIBSource*
pDIBSource, FX_ARGB bitmap_argb, |
452 int bitmap_alpha, const CFX_AffineMatrix* pIma
ge2Device, FX_DWORD flags, FX_BOOL bStdCS, int blendType) | 452 int bitmap_alpha, const CFX_AffineMatrix* pIma
ge2Device, FX_DWORD flags, bool bStdCS, int blendType) |
453 { | 453 { |
454 m_pRenderStatus = pStatus; | 454 m_pRenderStatus = pStatus; |
455 m_pDIBSource = pDIBSource; | 455 m_pDIBSource = pDIBSource; |
456 m_FillArgb = bitmap_argb; | 456 m_FillArgb = bitmap_argb; |
457 m_BitmapAlpha = bitmap_alpha; | 457 m_BitmapAlpha = bitmap_alpha; |
458 m_ImageMatrix = *pImage2Device; | 458 m_ImageMatrix = *pImage2Device; |
459 m_Flags = flags; | 459 m_Flags = flags; |
460 m_bStdCS = bStdCS; | 460 m_bStdCS = bStdCS; |
461 m_BlendType = blendType; | 461 m_BlendType = blendType; |
462 return StartDIBSource(); | 462 return StartDIBSource(); |
463 } | 463 } |
464 FX_BOOL»CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) | 464 bool» CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) |
465 { | 465 { |
466 if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRenderCaps
() & FXRC_BLEND_MODE)) { | 466 if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRenderCaps
() & FXRC_BLEND_MODE)) { |
467 m_Result = FALSE; | 467 m_Result = false; |
468 return FALSE; | 468 return false; |
469 } | 469 } |
470 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); | 470 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); |
471 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); | 471 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); |
472 if (rect.IsEmpty()) { | 472 if (rect.IsEmpty()) { |
473 return FALSE; | 473 return false; |
474 } | 474 } |
475 CFX_AffineMatrix new_matrix = m_ImageMatrix; | 475 CFX_AffineMatrix new_matrix = m_ImageMatrix; |
476 new_matrix.TranslateI(-rect.left, -rect.top); | 476 new_matrix.TranslateI(-rect.left, -rect.top); |
477 int width = rect.Width(); | 477 int width = rect.Width(); |
478 int height = rect.Height(); | 478 int height = rect.Height(); |
479 CFX_FxgeDevice bitmap_device1; | 479 CFX_FxgeDevice bitmap_device1; |
480 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32)) { | 480 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32)) { |
481 return TRUE; | 481 return true; |
482 } | 482 } |
483 bitmap_device1.GetBitmap()->Clear(0xffffff); | 483 bitmap_device1.GetBitmap()->Clear(0xffffff); |
484 { | 484 { |
485 CPDF_RenderStatus bitmap_render; | 485 CPDF_RenderStatus bitmap_render; |
486 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, N
ULL, NULL, | 486 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, N
ULL, NULL, |
487 NULL, NULL, &m_pRenderStatus->m_Options, 0, m_p
RenderStatus->m_bDropObjects, NULL, TRUE); | 487 NULL, NULL, &m_pRenderStatus->m_Options, 0, m_p
RenderStatus->m_bDropObjects, NULL, true); |
488 CFX_Matrix patternDevice = *pObj2Device; | 488 CFX_Matrix patternDevice = *pObj2Device; |
489 patternDevice.Translate((FX_FLOAT) - rect.left, (FX_FLOAT) - rect.top); | 489 patternDevice.Translate((FX_FLOAT) - rect.left, (FX_FLOAT) - rect.top); |
490 if(m_pPattern->m_PatternType == PATTERN_TILING) { | 490 if(m_pPattern->m_PatternType == PATTERN_TILING) { |
491 bitmap_render.DrawTilingPattern((CPDF_TilingPattern*)m_pPattern, m_p
ImageObject, &patternDevice, FALSE); | 491 bitmap_render.DrawTilingPattern((CPDF_TilingPattern*)m_pPattern, m_p
ImageObject, &patternDevice, false); |
492 } else { | 492 } else { |
493 bitmap_render.DrawShadingPattern((CPDF_ShadingPattern*)m_pPattern, m
_pImageObject, &patternDevice, FALSE); | 493 bitmap_render.DrawShadingPattern((CPDF_ShadingPattern*)m_pPattern, m
_pImageObject, &patternDevice, false); |
494 } | 494 } |
495 } | 495 } |
496 { | 496 { |
497 CFX_FxgeDevice bitmap_device2; | 497 CFX_FxgeDevice bitmap_device2; |
498 if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb))
{ | 498 if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb))
{ |
499 return TRUE; | 499 return true; |
500 } | 500 } |
501 bitmap_device2.GetBitmap()->Clear(0); | 501 bitmap_device2.GetBitmap()->Clear(0); |
502 CPDF_RenderStatus bitmap_render; | 502 CPDF_RenderStatus bitmap_render; |
503 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, N
ULL, NULL, | 503 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, N
ULL, NULL, |
504 NULL, NULL, NULL, 0, m_pRenderStatus->m_bDropOb
jects, NULL, TRUE); | 504 NULL, NULL, NULL, 0, m_pRenderStatus->m_bDropOb
jects, NULL, true); |
505 CPDF_ImageRenderer image_render; | 505 CPDF_ImageRenderer image_render; |
506 if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255, &n
ew_matrix, m_Flags, TRUE)) { | 506 if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255, &n
ew_matrix, m_Flags, true)) { |
507 image_render.Continue(NULL); | 507 image_render.Continue(NULL); |
508 } | 508 } |
509 if (m_Loader.m_MatteColor != 0xffffffff) { | 509 if (m_Loader.m_MatteColor != 0xffffffff) { |
510 int matte_r = FXARGB_R(m_Loader.m_MatteColor); | 510 int matte_r = FXARGB_R(m_Loader.m_MatteColor); |
511 int matte_g = FXARGB_G(m_Loader.m_MatteColor); | 511 int matte_g = FXARGB_G(m_Loader.m_MatteColor); |
512 int matte_b = FXARGB_B(m_Loader.m_MatteColor); | 512 int matte_b = FXARGB_B(m_Loader.m_MatteColor); |
513 for (int row = 0; row < height; row ++) { | 513 for (int row = 0; row < height; row ++) { |
514 uint8_t* dest_scan = (uint8_t*)bitmap_device1.GetBitmap()->GetSc
anline(row); | 514 uint8_t* dest_scan = (uint8_t*)bitmap_device1.GetBitmap()->GetSc
anline(row); |
515 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanli
ne(row); | 515 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanli
ne(row); |
516 for (int col = 0; col < width; col ++) { | 516 for (int col = 0; col < width; col ++) { |
(...skipping 25 matching lines...) Expand all Loading... |
542 dest_scan += 4; | 542 dest_scan += 4; |
543 } | 543 } |
544 } | 544 } |
545 } | 545 } |
546 } | 546 } |
547 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); | 547 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); |
548 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); | 548 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); |
549 bitmap_device1.GetBitmap()->MultiplyAlpha(255); | 549 bitmap_device1.GetBitmap()->MultiplyAlpha(255); |
550 } | 550 } |
551 m_pRenderStatus->m_pDevice->SetDIBits(bitmap_device1.GetBitmap(), rect.left,
rect.top, m_BlendType); | 551 m_pRenderStatus->m_pDevice->SetDIBits(bitmap_device1.GetBitmap(), rect.left,
rect.top, m_BlendType); |
552 return FALSE; | 552 return false; |
553 } | 553 } |
554 FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() | 554 bool CPDF_ImageRenderer::DrawMaskedImage() |
555 { | 555 { |
556 if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRenderCaps
() & FXRC_BLEND_MODE)) { | 556 if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRenderCaps
() & FXRC_BLEND_MODE)) { |
557 m_Result = FALSE; | 557 m_Result = false; |
558 return FALSE; | 558 return false; |
559 } | 559 } |
560 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); | 560 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); |
561 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); | 561 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); |
562 if (rect.IsEmpty()) { | 562 if (rect.IsEmpty()) { |
563 return FALSE; | 563 return false; |
564 } | 564 } |
565 CFX_AffineMatrix new_matrix = m_ImageMatrix; | 565 CFX_AffineMatrix new_matrix = m_ImageMatrix; |
566 new_matrix.TranslateI(-rect.left, -rect.top); | 566 new_matrix.TranslateI(-rect.left, -rect.top); |
567 int width = rect.Width(); | 567 int width = rect.Width(); |
568 int height = rect.Height(); | 568 int height = rect.Height(); |
569 CFX_FxgeDevice bitmap_device1; | 569 CFX_FxgeDevice bitmap_device1; |
570 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32)) { | 570 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32)) { |
571 return TRUE; | 571 return true; |
572 } | 572 } |
573 bitmap_device1.GetBitmap()->Clear(0xffffff); | 573 bitmap_device1.GetBitmap()->Clear(0xffffff); |
574 { | 574 { |
575 CPDF_RenderStatus bitmap_render; | 575 CPDF_RenderStatus bitmap_render; |
576 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, N
ULL, NULL, | 576 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, N
ULL, NULL, |
577 NULL, NULL, NULL, 0, m_pRenderStatus->m_bDropOb
jects, NULL, TRUE); | 577 NULL, NULL, NULL, 0, m_pRenderStatus->m_bDropOb
jects, NULL, true); |
578 CPDF_ImageRenderer image_render; | 578 CPDF_ImageRenderer image_render; |
579 if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix
, m_Flags, TRUE)) { | 579 if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix
, m_Flags, true)) { |
580 image_render.Continue(NULL); | 580 image_render.Continue(NULL); |
581 } | 581 } |
582 } | 582 } |
583 { | 583 { |
584 CFX_FxgeDevice bitmap_device2; | 584 CFX_FxgeDevice bitmap_device2; |
585 if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb)) { | 585 if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb)) { |
586 return TRUE; | 586 return true; |
587 } | 587 } |
588 bitmap_device2.GetBitmap()->Clear(0); | 588 bitmap_device2.GetBitmap()->Clear(0); |
589 CPDF_RenderStatus bitmap_render; | 589 CPDF_RenderStatus bitmap_render; |
590 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, N
ULL, NULL, | 590 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, N
ULL, NULL, |
591 NULL, NULL, NULL, 0, m_pRenderStatus->m_bDropOb
jects, NULL, TRUE); | 591 NULL, NULL, NULL, 0, m_pRenderStatus->m_bDropOb
jects, NULL, true); |
592 CPDF_ImageRenderer image_render; | 592 CPDF_ImageRenderer image_render; |
593 if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255
, &new_matrix, m_Flags, TRUE)) { | 593 if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255
, &new_matrix, m_Flags, true)) { |
594 image_render.Continue(NULL); | 594 image_render.Continue(NULL); |
595 } | 595 } |
596 if (m_Loader.m_MatteColor != 0xffffffff) { | 596 if (m_Loader.m_MatteColor != 0xffffffff) { |
597 int matte_r = FXARGB_R(m_Loader.m_MatteColor); | 597 int matte_r = FXARGB_R(m_Loader.m_MatteColor); |
598 int matte_g = FXARGB_G(m_Loader.m_MatteColor); | 598 int matte_g = FXARGB_G(m_Loader.m_MatteColor); |
599 int matte_b = FXARGB_B(m_Loader.m_MatteColor); | 599 int matte_b = FXARGB_B(m_Loader.m_MatteColor); |
600 for (int row = 0; row < height; row ++) { | 600 for (int row = 0; row < height; row ++) { |
601 uint8_t* dest_scan = (uint8_t*)bitmap_device1.GetBitmap()->GetSc
anline(row); | 601 uint8_t* dest_scan = (uint8_t*)bitmap_device1.GetBitmap()->GetSc
anline(row); |
602 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanli
ne(row); | 602 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanli
ne(row); |
603 for (int col = 0; col < width; col ++) { | 603 for (int col = 0; col < width; col ++) { |
(...skipping 27 matching lines...) Expand all Loading... |
631 } | 631 } |
632 } | 632 } |
633 } | 633 } |
634 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); | 634 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); |
635 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); | 635 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); |
636 if (m_BitmapAlpha < 255) { | 636 if (m_BitmapAlpha < 255) { |
637 bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha); | 637 bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha); |
638 } | 638 } |
639 } | 639 } |
640 m_pRenderStatus->m_pDevice->SetDIBits(bitmap_device1.GetBitmap(), rect.left,
rect.top, m_BlendType); | 640 m_pRenderStatus->m_pDevice->SetDIBits(bitmap_device1.GetBitmap(), rect.left,
rect.top, m_BlendType); |
641 return FALSE; | 641 return false; |
642 } | 642 } |
643 FX_BOOL CPDF_ImageRenderer::StartDIBSource() | 643 bool CPDF_ImageRenderer::StartDIBSource() |
644 { | 644 { |
645 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { | 645 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { |
646 int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() *
m_pDIBSource->GetHeight(); | 646 int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() *
m_pDIBSource->GetHeight(); |
647 if (image_size > FPDF_HUGE_IMAGE_SIZE && !(m_Flags & RENDER_FORCE_HALFTO
NE)) { | 647 if (image_size > FPDF_HUGE_IMAGE_SIZE && !(m_Flags & RENDER_FORCE_HALFTO
NE)) { |
648 m_Flags |= RENDER_FORCE_DOWNSAMPLE; | 648 m_Flags |= RENDER_FORCE_DOWNSAMPLE; |
649 } | 649 } |
650 } | 650 } |
651 if (m_pRenderStatus->m_pDevice->StartDIBits(m_pDIBSource, m_BitmapAlpha, m_F
illArgb, | 651 if (m_pRenderStatus->m_pDevice->StartDIBits(m_pDIBSource, m_BitmapAlpha, m_F
illArgb, |
652 &m_ImageMatrix, m_Flags, m_DeviceHandle, 0, NULL, m_BlendType)) { | 652 &m_ImageMatrix, m_Flags, m_DeviceHandle, 0, NULL, m_BlendType)) { |
653 if (m_DeviceHandle != NULL) { | 653 if (m_DeviceHandle != NULL) { |
654 m_Status = 3; | 654 m_Status = 3; |
655 return TRUE; | 655 return true; |
656 } | 656 } |
657 return FALSE; | 657 return false; |
658 } | 658 } |
659 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); | 659 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); |
660 FX_RECT image_rect = image_rect_f.GetOutterRect(); | 660 FX_RECT image_rect = image_rect_f.GetOutterRect(); |
661 int dest_width = image_rect.Width(); | 661 int dest_width = image_rect.Width(); |
662 int dest_height = image_rect.Height(); | 662 int dest_height = image_rect.Height(); |
663 if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || | 663 if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || |
664 (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0) ) { | 664 (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0) ) { |
665 if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRender
Caps() & FXRC_BLEND_MODE)) { | 665 if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRender
Caps() & FXRC_BLEND_MODE)) { |
666 m_Result = FALSE; | 666 m_Result = false; |
667 return FALSE; | 667 return false; |
668 } | 668 } |
669 FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox(); | 669 FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox(); |
670 clip_box.Intersect(image_rect); | 670 clip_box.Intersect(image_rect); |
671 m_Status = 2; | 671 m_Status = 2; |
672 m_pTransformer = new CFX_ImageTransformer; | 672 m_pTransformer = new CFX_ImageTransformer; |
673 m_pTransformer->Start(m_pDIBSource, &m_ImageMatrix, m_Flags, &clip_box); | 673 m_pTransformer->Start(m_pDIBSource, &m_ImageMatrix, m_Flags, &clip_box); |
674 return TRUE; | 674 return true; |
675 } | 675 } |
676 if (m_ImageMatrix.a < 0) { | 676 if (m_ImageMatrix.a < 0) { |
677 dest_width = -dest_width; | 677 dest_width = -dest_width; |
678 } | 678 } |
679 if (m_ImageMatrix.d > 0) { | 679 if (m_ImageMatrix.d > 0) { |
680 dest_height = -dest_height; | 680 dest_height = -dest_height; |
681 } | 681 } |
682 int dest_left, dest_top; | 682 int dest_left, dest_top; |
683 dest_left = dest_width > 0 ? image_rect.left : image_rect.right; | 683 dest_left = dest_width > 0 ? image_rect.left : image_rect.right; |
684 dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom; | 684 dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom; |
685 if (m_pDIBSource->IsOpaqueImage() && m_BitmapAlpha == 255) { | 685 if (m_pDIBSource->IsOpaqueImage() && m_BitmapAlpha == 255) { |
686 if (m_pRenderStatus->m_pDevice->StretchDIBits(m_pDIBSource, dest_left, d
est_top, | 686 if (m_pRenderStatus->m_pDevice->StretchDIBits(m_pDIBSource, dest_left, d
est_top, |
687 dest_width, dest_height, m_Flags, NULL, m_BlendType)) { | 687 dest_width, dest_height, m_Flags, NULL, m_BlendType)) { |
688 return FALSE; | 688 return false; |
689 } | 689 } |
690 } | 690 } |
691 if (m_pDIBSource->IsAlphaMask()) { | 691 if (m_pDIBSource->IsAlphaMask()) { |
692 if (m_BitmapAlpha != 255) { | 692 if (m_BitmapAlpha != 255) { |
693 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); | 693 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); |
694 } | 694 } |
695 if (m_pRenderStatus->m_pDevice->StretchBitMask(m_pDIBSource, dest_left,
dest_top, dest_width, dest_height, m_FillArgb, m_Flags)) { | 695 if (m_pRenderStatus->m_pDevice->StretchBitMask(m_pDIBSource, dest_left,
dest_top, dest_width, dest_height, m_FillArgb, m_Flags)) { |
696 return FALSE; | 696 return false; |
697 } | 697 } |
698 } | 698 } |
699 if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRenderCaps
() & FXRC_BLEND_MODE)) { | 699 if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRenderCaps
() & FXRC_BLEND_MODE)) { |
700 m_Result = FALSE; | 700 m_Result = false; |
701 return TRUE; | 701 return true; |
702 } | 702 } |
703 FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox(); | 703 FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox(); |
704 FX_RECT dest_rect = clip_box; | 704 FX_RECT dest_rect = clip_box; |
705 dest_rect.Intersect(image_rect); | 705 dest_rect.Intersect(image_rect); |
706 FX_RECT dest_clip(dest_rect.left - image_rect.left, dest_rect.top - image_re
ct.top, | 706 FX_RECT dest_clip(dest_rect.left - image_rect.left, dest_rect.top - image_re
ct.top, |
707 dest_rect.right - image_rect.left, dest_rect.bottom - imag
e_rect.top); | 707 dest_rect.right - image_rect.left, dest_rect.bottom - imag
e_rect.top); |
708 CFX_DIBitmap* pStretched = m_pDIBSource->StretchTo(dest_width, dest_height,
m_Flags, &dest_clip); | 708 CFX_DIBitmap* pStretched = m_pDIBSource->StretchTo(dest_width, dest_height,
m_Flags, &dest_clip); |
709 if (pStretched) { | 709 if (pStretched) { |
710 m_pRenderStatus->CompositeDIBitmap(pStretched, dest_rect.left, dest_rect
.top, m_FillArgb, | 710 m_pRenderStatus->CompositeDIBitmap(pStretched, dest_rect.left, dest_rect
.top, m_FillArgb, |
711 m_BitmapAlpha, m_BlendType, FALSE); | 711 m_BitmapAlpha, m_BlendType, false); |
712 delete pStretched; | 712 delete pStretched; |
713 pStretched = NULL; | 713 pStretched = NULL; |
714 } | 714 } |
715 return FALSE; | 715 return false; |
716 } | 716 } |
717 FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() | 717 bool CPDF_ImageRenderer::StartBitmapAlpha() |
718 { | 718 { |
719 if (m_pDIBSource->IsOpaqueImage()) { | 719 if (m_pDIBSource->IsOpaqueImage()) { |
720 CFX_PathData path; | 720 CFX_PathData path; |
721 path.AppendRect(0, 0, 1, 1); | 721 path.AppendRect(0, 0, 1, 1); |
722 path.Transform(&m_ImageMatrix); | 722 path.Transform(&m_ImageMatrix); |
723 FX_DWORD fill_color = ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_B
itmapAlpha); | 723 FX_DWORD fill_color = ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_B
itmapAlpha); |
724 m_pRenderStatus->m_pDevice->DrawPath(&path, NULL, NULL, fill_color, 0, F
XFILL_WINDING); | 724 m_pRenderStatus->m_pDevice->DrawPath(&path, NULL, NULL, fill_color, 0, F
XFILL_WINDING); |
725 } else { | 725 } else { |
726 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask() ? m_pDIBSo
urce : m_pDIBSource->GetAlphaMask(); | 726 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask() ? m_pDIBSo
urce : m_pDIBSource->GetAlphaMask(); |
727 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || FXSYS_fabs(m_ImageMatrix.c) >
= 0.5f) { | 727 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || FXSYS_fabs(m_ImageMatrix.c) >
= 0.5f) { |
728 int left, top; | 728 int left, top; |
729 CFX_DIBitmap* pTransformed = pAlphaMask->TransformTo(&m_ImageMatrix,
left, top); | 729 CFX_DIBitmap* pTransformed = pAlphaMask->TransformTo(&m_ImageMatrix,
left, top); |
730 if (pTransformed == NULL) { | 730 if (pTransformed == NULL) { |
731 return TRUE; | 731 return true; |
732 } | 732 } |
733 m_pRenderStatus->m_pDevice->SetBitMask(pTransformed, left, top, Argb
Encode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha)); | 733 m_pRenderStatus->m_pDevice->SetBitMask(pTransformed, left, top, Argb
Encode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha)); |
734 delete pTransformed; | 734 delete pTransformed; |
735 } else { | 735 } else { |
736 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); | 736 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); |
737 FX_RECT image_rect = image_rect_f.GetOutterRect(); | 737 FX_RECT image_rect = image_rect_f.GetOutterRect(); |
738 int dest_width = m_ImageMatrix.a > 0 ? image_rect.Width() : -image_r
ect.Width(); | 738 int dest_width = m_ImageMatrix.a > 0 ? image_rect.Width() : -image_r
ect.Width(); |
739 int dest_height = m_ImageMatrix.d > 0 ? -image_rect.Height() : image
_rect.Height(); | 739 int dest_height = m_ImageMatrix.d > 0 ? -image_rect.Height() : image
_rect.Height(); |
740 int left = dest_width > 0 ? image_rect.left : image_rect.right; | 740 int left = dest_width > 0 ? image_rect.left : image_rect.right; |
741 int top = dest_height > 0 ? image_rect.top : image_rect.bottom; | 741 int top = dest_height > 0 ? image_rect.top : image_rect.bottom; |
742 m_pRenderStatus->m_pDevice->StretchBitMask(pAlphaMask, left, top, de
st_width, dest_height, | 742 m_pRenderStatus->m_pDevice->StretchBitMask(pAlphaMask, left, top, de
st_width, dest_height, |
743 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha
)); | 743 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha
)); |
744 } | 744 } |
745 if (m_pDIBSource != pAlphaMask) { | 745 if (m_pDIBSource != pAlphaMask) { |
746 delete pAlphaMask; | 746 delete pAlphaMask; |
747 } | 747 } |
748 } | 748 } |
749 return FALSE; | 749 return false; |
750 } | 750 } |
751 FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) | 751 bool CPDF_ImageRenderer::Continue(IFX_Pause* pPause) |
752 { | 752 { |
753 if (m_Status == 1) { | 753 if (m_Status == 1) { |
754 if (m_pQuickStretcher->Continue(pPause)) { | 754 if (m_pQuickStretcher->Continue(pPause)) { |
755 return TRUE; | 755 return true; |
756 } | 756 } |
757 if (m_pQuickStretcher->m_pBitmap->IsAlphaMask()) | 757 if (m_pQuickStretcher->m_pBitmap->IsAlphaMask()) |
758 m_pRenderStatus->m_pDevice->SetBitMask(m_pQuickStretcher->m_pBitmap,
m_pQuickStretcher->m_ResultLeft, | 758 m_pRenderStatus->m_pDevice->SetBitMask(m_pQuickStretcher->m_pBitmap,
m_pQuickStretcher->m_ResultLeft, |
759 m_pQuickStretcher->m_ResultTo
p, m_FillArgb); | 759 m_pQuickStretcher->m_ResultTo
p, m_FillArgb); |
760 else | 760 else |
761 m_pRenderStatus->m_pDevice->SetDIBits(m_pQuickStretcher->m_pBitmap,
m_pQuickStretcher->m_ResultLeft, | 761 m_pRenderStatus->m_pDevice->SetDIBits(m_pQuickStretcher->m_pBitmap,
m_pQuickStretcher->m_ResultLeft, |
762 m_pQuickStretcher->m_ResultTop
, m_BlendType); | 762 m_pQuickStretcher->m_ResultTop
, m_BlendType); |
763 return FALSE; | 763 return false; |
764 } | 764 } |
765 if (m_Status == 2) { | 765 if (m_Status == 2) { |
766 if (m_pTransformer->Continue(pPause)) { | 766 if (m_pTransformer->Continue(pPause)) { |
767 return TRUE; | 767 return true; |
768 } | 768 } |
769 CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach(); | 769 CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach(); |
770 if (pBitmap == NULL) { | 770 if (pBitmap == NULL) { |
771 return FALSE; | 771 return false; |
772 } | 772 } |
773 if (pBitmap->IsAlphaMask()) { | 773 if (pBitmap->IsAlphaMask()) { |
774 if (m_BitmapAlpha != 255) { | 774 if (m_BitmapAlpha != 255) { |
775 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); | 775 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); |
776 } | 776 } |
777 m_Result = m_pRenderStatus->m_pDevice->SetBitMask(pBitmap, | 777 m_Result = m_pRenderStatus->m_pDevice->SetBitMask(pBitmap, |
778 m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop
, m_FillArgb); | 778 m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop
, m_FillArgb); |
779 } else { | 779 } else { |
780 if (m_BitmapAlpha != 255) { | 780 if (m_BitmapAlpha != 255) { |
781 pBitmap->MultiplyAlpha(m_BitmapAlpha); | 781 pBitmap->MultiplyAlpha(m_BitmapAlpha); |
782 } | 782 } |
783 m_Result = m_pRenderStatus->m_pDevice->SetDIBits(pBitmap, | 783 m_Result = m_pRenderStatus->m_pDevice->SetDIBits(pBitmap, |
784 m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop
, m_BlendType); | 784 m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop
, m_BlendType); |
785 } | 785 } |
786 delete pBitmap; | 786 delete pBitmap; |
787 return FALSE; | 787 return false; |
788 } | 788 } |
789 if (m_Status == 3) { | 789 if (m_Status == 3) { |
790 return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause
); | 790 return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause
); |
791 } | 791 } |
792 if (m_Status == 4) { | 792 if (m_Status == 4) { |
793 if (m_Loader.Continue(m_LoadHandle, pPause)) { | 793 if (m_Loader.Continue(m_LoadHandle, pPause)) { |
794 return TRUE; | 794 return true; |
795 } | 795 } |
796 if (StartRenderDIBSource()) { | 796 if (StartRenderDIBSource()) { |
797 return Continue(pPause); | 797 return Continue(pPause); |
798 } | 798 } |
799 } | 799 } |
800 return FALSE; | 800 return false; |
801 } | 801 } |
802 CPDF_QuickStretcher::CPDF_QuickStretcher() | 802 CPDF_QuickStretcher::CPDF_QuickStretcher() |
803 { | 803 { |
804 m_pBitmap = NULL; | 804 m_pBitmap = NULL; |
805 m_pDecoder = NULL; | 805 m_pDecoder = NULL; |
806 m_pCS = NULL; | 806 m_pCS = NULL; |
807 } | 807 } |
808 CPDF_QuickStretcher::~CPDF_QuickStretcher() | 808 CPDF_QuickStretcher::~CPDF_QuickStretcher() |
809 { | 809 { |
810 delete m_pBitmap; | 810 delete m_pBitmap; |
811 if (m_pCS) { | 811 if (m_pCS) { |
812 m_pCS->ReleaseCS(); | 812 m_pCS->ReleaseCS(); |
813 } | 813 } |
814 delete m_pDecoder; | 814 delete m_pDecoder; |
815 } | 815 } |
816 ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(const uint8_t* src_buf, FX_DW
ORD src_size, int width, int height, | 816 ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(const uint8_t* src_buf, FX_DW
ORD src_size, int width, int height, |
817 int nComps, int bpc, const CPDF_Dictionary* pParams); | 817 int nComps, int bpc, const CPDF_Dictionary* pParams); |
818 FX_BOOL CPDF_QuickStretcher::Start(CPDF_ImageObject* pImageObj, CFX_AffineMatrix
* pImage2Device, const FX_RECT* pClipBox) | 818 bool CPDF_QuickStretcher::Start(CPDF_ImageObject* pImageObj, CFX_AffineMatrix* p
Image2Device, const FX_RECT* pClipBox) |
819 { | 819 { |
820 if (FXSYS_fabs(pImage2Device->a) < FXSYS_fabs(pImage2Device->b) * 10 && FXSY
S_fabs(pImage2Device->d) < FXSYS_fabs(pImage2Device->c) * 10) { | 820 if (FXSYS_fabs(pImage2Device->a) < FXSYS_fabs(pImage2Device->b) * 10 && FXSY
S_fabs(pImage2Device->d) < FXSYS_fabs(pImage2Device->c) * 10) { |
821 return FALSE; | 821 return false; |
822 } | 822 } |
823 CFX_FloatRect image_rect_f = pImage2Device->GetUnitRect(); | 823 CFX_FloatRect image_rect_f = pImage2Device->GetUnitRect(); |
824 FX_RECT image_rect = image_rect_f.GetOutterRect(); | 824 FX_RECT image_rect = image_rect_f.GetOutterRect(); |
825 m_DestWidth = image_rect.Width(); | 825 m_DestWidth = image_rect.Width(); |
826 m_DestHeight = image_rect.Height(); | 826 m_DestHeight = image_rect.Height(); |
827 m_bFlipX = pImage2Device->a < 0; | 827 m_bFlipX = pImage2Device->a < 0; |
828 m_bFlipY = pImage2Device->d > 0; | 828 m_bFlipY = pImage2Device->d > 0; |
829 FX_RECT result_rect = *pClipBox; | 829 FX_RECT result_rect = *pClipBox; |
830 result_rect.Intersect(image_rect); | 830 result_rect.Intersect(image_rect); |
831 if (result_rect.IsEmpty()) { | 831 if (result_rect.IsEmpty()) { |
832 return FALSE; | 832 return false; |
833 } | 833 } |
834 m_ResultWidth = result_rect.Width(); | 834 m_ResultWidth = result_rect.Width(); |
835 m_ResultHeight = result_rect.Height(); | 835 m_ResultHeight = result_rect.Height(); |
836 m_ResultLeft = result_rect.left; | 836 m_ResultLeft = result_rect.left; |
837 m_ResultTop = result_rect.top; | 837 m_ResultTop = result_rect.top; |
838 m_ClipLeft = result_rect.left - image_rect.left; | 838 m_ClipLeft = result_rect.left - image_rect.left; |
839 m_ClipTop = result_rect.top - image_rect.top; | 839 m_ClipTop = result_rect.top - image_rect.top; |
840 CPDF_Dictionary* pDict = pImageObj->m_pImage->GetDict(); | 840 CPDF_Dictionary* pDict = pImageObj->m_pImage->GetDict(); |
841 if (pDict->GetInteger(FX_BSTRC("BitsPerComponent")) != 8) { | 841 if (pDict->GetInteger(FX_BSTRC("BitsPerComponent")) != 8) { |
842 return FALSE; | 842 return false; |
843 } | 843 } |
844 if (pDict->KeyExist(FX_BSTRC("SMask")) || pDict->KeyExist(FX_BSTRC("Mask")))
{ | 844 if (pDict->KeyExist(FX_BSTRC("SMask")) || pDict->KeyExist(FX_BSTRC("Mask")))
{ |
845 return FALSE; | 845 return false; |
846 } | 846 } |
847 m_SrcWidth = pDict->GetInteger(FX_BSTRC("Width")); | 847 m_SrcWidth = pDict->GetInteger(FX_BSTRC("Width")); |
848 m_SrcHeight = pDict->GetInteger(FX_BSTRC("Height")); | 848 m_SrcHeight = pDict->GetInteger(FX_BSTRC("Height")); |
849 m_pCS = NULL; | 849 m_pCS = NULL; |
850 m_Bpp = 3; | 850 m_Bpp = 3; |
851 CPDF_Object* pCSObj = pDict->GetElementValue(FX_BSTRC("ColorSpace")); | 851 CPDF_Object* pCSObj = pDict->GetElementValue(FX_BSTRC("ColorSpace")); |
852 if (pCSObj == NULL) { | 852 if (pCSObj == NULL) { |
853 return FALSE; | 853 return false; |
854 } | 854 } |
855 m_pCS = CPDF_ColorSpace::Load(pImageObj->m_pImage->GetDocument(), pCSObj); | 855 m_pCS = CPDF_ColorSpace::Load(pImageObj->m_pImage->GetDocument(), pCSObj); |
856 if (m_pCS == NULL) { | 856 if (m_pCS == NULL) { |
857 return FALSE; | 857 return false; |
858 } | 858 } |
859 if (!_IsSupported(m_pCS)) { | 859 if (!_IsSupported(m_pCS)) { |
860 return FALSE; | 860 return false; |
861 } | 861 } |
862 m_Bpp = m_pCS->CountComponents(); | 862 m_Bpp = m_pCS->CountComponents(); |
863 if (m_pCS->sRGB()) { | 863 if (m_pCS->sRGB()) { |
864 m_pCS->ReleaseCS(); | 864 m_pCS->ReleaseCS(); |
865 m_pCS = NULL; | 865 m_pCS = NULL; |
866 } | 866 } |
867 CPDF_Stream* pStream = pImageObj->m_pImage->GetStream(); | 867 CPDF_Stream* pStream = pImageObj->m_pImage->GetStream(); |
868 m_StreamAcc.LoadAllData(pStream, FALSE, m_SrcWidth * m_SrcHeight * m_Bpp, TR
UE); | 868 m_StreamAcc.LoadAllData(pStream, false, m_SrcWidth * m_SrcHeight * m_Bpp, tr
ue); |
869 m_pDecoder = NULL; | 869 m_pDecoder = NULL; |
870 if (!m_StreamAcc.GetImageDecoder().IsEmpty()) { | 870 if (!m_StreamAcc.GetImageDecoder().IsEmpty()) { |
871 if (m_StreamAcc.GetImageDecoder() == FX_BSTRC("DCTDecode")) { | 871 if (m_StreamAcc.GetImageDecoder() == FX_BSTRC("DCTDecode")) { |
872 const CPDF_Dictionary* pParam = m_StreamAcc.GetImageParam(); | 872 const CPDF_Dictionary* pParam = m_StreamAcc.GetImageParam(); |
873 m_pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( | 873 m_pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( |
874 m_StreamAcc.GetData(), m_StreamAcc.GetSize(), m_Src
Width, m_SrcHeight, m_Bpp, | 874 m_StreamAcc.GetData(), m_StreamAcc.GetSize(), m_Src
Width, m_SrcHeight, m_Bpp, |
875 pParam ? pParam->GetInteger(FX_BSTRC("ColorTransfor
m"), 1) : 1); | 875 pParam ? pParam->GetInteger(FX_BSTRC("ColorTransfor
m"), 1) : 1); |
876 } else if (m_StreamAcc.GetImageDecoder() == FX_BSTRC("FlateDecode")) { | 876 } else if (m_StreamAcc.GetImageDecoder() == FX_BSTRC("FlateDecode")) { |
877 m_pDecoder = FPDFAPI_CreateFlateDecoder( | 877 m_pDecoder = FPDFAPI_CreateFlateDecoder( |
878 m_StreamAcc.GetData(), m_StreamAcc.GetSize(), m_Src
Width, m_SrcHeight, m_Bpp, 8, | 878 m_StreamAcc.GetData(), m_StreamAcc.GetSize(), m_Src
Width, m_SrcHeight, m_Bpp, 8, |
879 m_StreamAcc.GetImageParam()); | 879 m_StreamAcc.GetImageParam()); |
880 } else { | 880 } else { |
881 return FALSE; | 881 return false; |
882 } | 882 } |
883 m_pDecoder->DownScale(m_DestWidth, m_DestHeight); | 883 m_pDecoder->DownScale(m_DestWidth, m_DestHeight); |
884 } | 884 } |
885 m_pBitmap = new CFX_DIBitmap; | 885 m_pBitmap = new CFX_DIBitmap; |
886 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 886 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
887 m_pBitmap->Create(m_ResultWidth, m_ResultHeight, FXDIB_Rgb32); | 887 m_pBitmap->Create(m_ResultWidth, m_ResultHeight, FXDIB_Rgb32); |
888 #else | 888 #else |
889 m_pBitmap->Create(m_ResultWidth, m_ResultHeight, FXDIB_Rgb); | 889 m_pBitmap->Create(m_ResultWidth, m_ResultHeight, FXDIB_Rgb); |
890 #endif | 890 #endif |
891 m_LineIndex = 0; | 891 m_LineIndex = 0; |
892 return TRUE; | 892 return true; |
893 } | 893 } |
894 FX_BOOL CPDF_QuickStretcher::Continue(IFX_Pause* pPause) | 894 bool CPDF_QuickStretcher::Continue(IFX_Pause* pPause) |
895 { | 895 { |
896 uint8_t* result_buf = m_pBitmap->GetBuffer(); | 896 uint8_t* result_buf = m_pBitmap->GetBuffer(); |
897 int src_width = m_pDecoder ? m_pDecoder->GetWidth() : m_SrcWidth; | 897 int src_width = m_pDecoder ? m_pDecoder->GetWidth() : m_SrcWidth; |
898 int src_height = m_pDecoder ? m_pDecoder->GetHeight() : m_SrcHeight; | 898 int src_height = m_pDecoder ? m_pDecoder->GetHeight() : m_SrcHeight; |
899 int src_pitch = src_width * m_Bpp; | 899 int src_pitch = src_width * m_Bpp; |
900 while (m_LineIndex < m_ResultHeight) { | 900 while (m_LineIndex < m_ResultHeight) { |
901 int dest_y, src_y; | 901 int dest_y, src_y; |
902 if (m_bFlipY) { | 902 if (m_bFlipY) { |
903 dest_y = m_ResultHeight - m_LineIndex - 1; | 903 dest_y = m_ResultHeight - m_LineIndex - 1; |
904 src_y = (m_DestHeight - (dest_y + m_ClipTop) - 1) * src_height / m_D
estHeight; | 904 src_y = (m_DestHeight - (dest_y + m_ClipTop) - 1) * src_height / m_D
estHeight; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 m_pCS->TranslateImageLine(result_scan, src_pixel, 1, 0, 0); | 938 m_pCS->TranslateImageLine(result_scan, src_pixel, 1, 0, 0); |
939 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 939 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
940 result_scan += 4; | 940 result_scan += 4; |
941 #else | 941 #else |
942 result_scan += 3; | 942 result_scan += 3; |
943 #endif | 943 #endif |
944 } | 944 } |
945 } | 945 } |
946 m_LineIndex ++; | 946 m_LineIndex ++; |
947 if (pPause && pPause->NeedToPauseNow()) { | 947 if (pPause && pPause->NeedToPauseNow()) { |
948 return TRUE; | 948 return true; |
949 } | 949 } |
950 } | 950 } |
951 return FALSE; | 951 return false; |
952 } | 952 } |
953 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, | 953 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, |
954 FX_RECT* pClipRect, const CFX_AffineMatrix* pMatrix) | 954 FX_RECT* pClipRect, const CFX_AffineMatrix* pMatrix) |
955 { | 955 { |
956 if (pSMaskDict == NULL) { | 956 if (pSMaskDict == NULL) { |
957 return NULL; | 957 return NULL; |
958 } | 958 } |
959 CFX_DIBitmap* pMask = NULL; | 959 CFX_DIBitmap* pMask = NULL; |
960 int width = pClipRect->right - pClipRect->left; | 960 int width = pClipRect->right - pClipRect->left; |
961 int height = pClipRect->bottom - pClipRect->top; | 961 int height = pClipRect->bottom - pClipRect->top; |
962 FX_BOOL bLuminosity = FALSE; | 962 bool bLuminosity = false; |
963 bLuminosity = pSMaskDict->GetConstString(FX_BSTRC("S")) != FX_BSTRC("Alpha")
; | 963 bLuminosity = pSMaskDict->GetConstString(FX_BSTRC("S")) != FX_BSTRC("Alpha")
; |
964 CPDF_Stream* pGroup = pSMaskDict->GetStream(FX_BSTRC("G")); | 964 CPDF_Stream* pGroup = pSMaskDict->GetStream(FX_BSTRC("G")); |
965 if (pGroup == NULL) { | 965 if (pGroup == NULL) { |
966 return NULL; | 966 return NULL; |
967 } | 967 } |
968 CPDF_Function* pFunc = NULL; | 968 CPDF_Function* pFunc = NULL; |
969 CPDF_Object* pFuncObj = pSMaskDict->GetElementValue(FX_BSTRC("TR")); | 969 CPDF_Object* pFuncObj = pSMaskDict->GetElementValue(FX_BSTRC("TR")); |
970 if (pFuncObj && (pFuncObj->GetType() == PDFOBJ_DICTIONARY || pFuncObj->GetTy
pe() == PDFOBJ_STREAM)) { | 970 if (pFuncObj && (pFuncObj->GetType() == PDFOBJ_DICTIONARY || pFuncObj->GetTy
pe() == PDFOBJ_STREAM)) { |
971 pFunc = CPDF_Function::Load(pFuncObj); | 971 pFunc = CPDF_Function::Load(pFuncObj); |
972 } | 972 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 bitmap.Clear(0); | 1025 bitmap.Clear(0); |
1026 } | 1026 } |
1027 CPDF_Dictionary* pFormResource = NULL; | 1027 CPDF_Dictionary* pFormResource = NULL; |
1028 if (form.m_pFormDict) { | 1028 if (form.m_pFormDict) { |
1029 pFormResource = form.m_pFormDict->GetDict(FX_BSTRC("Resources")); | 1029 pFormResource = form.m_pFormDict->GetDict(FX_BSTRC("Resources")); |
1030 } | 1030 } |
1031 CPDF_RenderOptions options; | 1031 CPDF_RenderOptions options; |
1032 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA
; | 1032 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA
; |
1033 CPDF_RenderStatus status; | 1033 CPDF_RenderStatus status; |
1034 status.Initialize(m_pContext, &bitmap_device, NULL, NULL, NULL, NULL, | 1034 status.Initialize(m_pContext, &bitmap_device, NULL, NULL, NULL, NULL, |
1035 &options, 0, m_bDropObjects, pFormResource, TRUE, NULL, 0,
pCS ? pCS->GetFamily() : 0, bLuminosity); | 1035 &options, 0, m_bDropObjects, pFormResource, true, NULL, 0,
pCS ? pCS->GetFamily() : 0, bLuminosity); |
1036 status.RenderObjectList(&form, &matrix); | 1036 status.RenderObjectList(&form, &matrix); |
1037 pMask = new CFX_DIBitmap; | 1037 pMask = new CFX_DIBitmap; |
1038 if (!pMask->Create(width, height, FXDIB_8bppMask)) { | 1038 if (!pMask->Create(width, height, FXDIB_8bppMask)) { |
1039 delete pMask; | 1039 delete pMask; |
1040 return NULL; | 1040 return NULL; |
1041 } | 1041 } |
1042 uint8_t* dest_buf = pMask->GetBuffer(); | 1042 uint8_t* dest_buf = pMask->GetBuffer(); |
1043 int dest_pitch = pMask->GetPitch(); | 1043 int dest_pitch = pMask->GetPitch(); |
1044 uint8_t* src_buf = bitmap.GetBuffer(); | 1044 uint8_t* src_buf = bitmap.GetBuffer(); |
1045 int src_pitch = bitmap.GetPitch(); | 1045 int src_pitch = bitmap.GetPitch(); |
(...skipping 26 matching lines...) Expand all Loading... |
1072 for (int i = 0; i < size; i ++) { | 1072 for (int i = 0; i < size; i ++) { |
1073 dest_buf[i] = pTransfer[src_buf[i]]; | 1073 dest_buf[i] = pTransfer[src_buf[i]]; |
1074 } | 1074 } |
1075 } else { | 1075 } else { |
1076 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 1076 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
1077 } | 1077 } |
1078 delete pFunc; | 1078 delete pFunc; |
1079 FX_Free(pTransfer); | 1079 FX_Free(pTransfer); |
1080 return pMask; | 1080 return pMask; |
1081 } | 1081 } |
OLD | NEW |