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_dib.h" | 7 #include "../../../include/fxge/fx_dib.h" |
8 #include "../../../include/fxge/fx_ge.h" | 8 #include "../../../include/fxge/fx_ge.h" |
9 #include "../../../include/fxcodec/fx_codec.h" | 9 #include "../../../include/fxcodec/fx_codec.h" |
10 #include "dib_int.h" | 10 #include "dib_int.h" |
11 #include <limits.h> | 11 #include <limits.h> |
12 bool ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitch,
int width, int height, | 12 FX_BOOL ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitc
h, int width, int height, |
13 const CFX_DIBSource* pSrcBitmap, int src_left, int src_top
, FX_DWORD*& pal, void* pIccTransform); | 13 const CFX_DIBSource* pSrcBitmap, int src_left, int src_top
, FX_DWORD*& pal, void* pIccTransform); |
14 void CmykDecode(FX_DWORD cmyk, int& c, int& m, int& y, int& k) | 14 void CmykDecode(FX_DWORD cmyk, int& c, int& m, int& y, int& k) |
15 { | 15 { |
16 c = FXSYS_GetCValue(cmyk); | 16 c = FXSYS_GetCValue(cmyk); |
17 m = FXSYS_GetMValue(cmyk); | 17 m = FXSYS_GetMValue(cmyk); |
18 y = FXSYS_GetYValue(cmyk); | 18 y = FXSYS_GetYValue(cmyk); |
19 k = FXSYS_GetKValue(cmyk); | 19 k = FXSYS_GetKValue(cmyk); |
20 } | 20 } |
21 void ArgbDecode(FX_DWORD argb, int& a, int& r, int& g, int& b) | 21 void ArgbDecode(FX_DWORD argb, int& a, int& r, int& g, int& b) |
22 { | 22 { |
(...skipping 22 matching lines...) Expand all Loading... |
45 } | 45 } |
46 CFX_DIBSource::~CFX_DIBSource() | 46 CFX_DIBSource::~CFX_DIBSource() |
47 { | 47 { |
48 if (m_pPalette) { | 48 if (m_pPalette) { |
49 FX_Free(m_pPalette); | 49 FX_Free(m_pPalette); |
50 } | 50 } |
51 delete m_pAlphaMask; | 51 delete m_pAlphaMask; |
52 } | 52 } |
53 CFX_DIBitmap::CFX_DIBitmap() | 53 CFX_DIBitmap::CFX_DIBitmap() |
54 { | 54 { |
55 m_bExtBuf = false; | 55 m_bExtBuf = FALSE; |
56 m_pBuffer = NULL; | 56 m_pBuffer = NULL; |
57 m_pPalette = NULL; | 57 m_pPalette = NULL; |
58 } | 58 } |
59 #define _MAX_OOM_LIMIT_ 12000000 | 59 #define _MAX_OOM_LIMIT_ 12000000 |
60 bool CFX_DIBitmap::Create(int width, int height, FXDIB_Format format, uint8_t* p
Buffer, int pitch) | 60 FX_BOOL CFX_DIBitmap::Create(int width, int height, FXDIB_Format format, uint8_t
* pBuffer, int pitch) |
61 { | 61 { |
62 m_pBuffer = NULL; | 62 m_pBuffer = NULL; |
63 m_bpp = (uint8_t)format; | 63 m_bpp = (uint8_t)format; |
64 m_AlphaFlag = (uint8_t)(format >> 8); | 64 m_AlphaFlag = (uint8_t)(format >> 8); |
65 m_Width = m_Height = m_Pitch = 0; | 65 m_Width = m_Height = m_Pitch = 0; |
66 if (width <= 0 || height <= 0 || pitch < 0) { | 66 if (width <= 0 || height <= 0 || pitch < 0) { |
67 return false; | 67 return FALSE; |
68 } | 68 } |
69 if ((INT_MAX - 31) / width < (format & 0xff)) { | 69 if ((INT_MAX - 31) / width < (format & 0xff)) { |
70 return false; | 70 return FALSE; |
71 } | 71 } |
72 if (!pitch) { | 72 if (!pitch) { |
73 pitch = (width * (format & 0xff) + 31) / 32 * 4; | 73 pitch = (width * (format & 0xff) + 31) / 32 * 4; |
74 } | 74 } |
75 if ((1 << 30) / pitch < height) { | 75 if ((1 << 30) / pitch < height) { |
76 return false; | 76 return FALSE; |
77 } | 77 } |
78 if (pBuffer) { | 78 if (pBuffer) { |
79 m_pBuffer = pBuffer; | 79 m_pBuffer = pBuffer; |
80 m_bExtBuf = true; | 80 m_bExtBuf = TRUE; |
81 } else { | 81 } else { |
82 int size = pitch * height + 4; | 82 int size = pitch * height + 4; |
83 int oomlimit = _MAX_OOM_LIMIT_; | 83 int oomlimit = _MAX_OOM_LIMIT_; |
84 if (oomlimit >= 0 && size >= oomlimit) { | 84 if (oomlimit >= 0 && size >= oomlimit) { |
85 m_pBuffer = FX_TryAlloc(uint8_t, size); | 85 m_pBuffer = FX_TryAlloc(uint8_t, size); |
86 if (m_pBuffer == NULL) { | 86 if (m_pBuffer == NULL) { |
87 return false; | 87 return FALSE; |
88 } | 88 } |
89 } else { | 89 } else { |
90 m_pBuffer = FX_Alloc(uint8_t, size); | 90 m_pBuffer = FX_Alloc(uint8_t, size); |
91 } | 91 } |
92 } | 92 } |
93 m_Width = width; | 93 m_Width = width; |
94 m_Height = height; | 94 m_Height = height; |
95 m_Pitch = pitch; | 95 m_Pitch = pitch; |
96 if (HasAlpha() && format != FXDIB_Argb) { | 96 if (HasAlpha() && format != FXDIB_Argb) { |
97 bool ret = true; | 97 FX_BOOL ret = TRUE; |
98 ret = BuildAlphaMask(); | 98 ret = BuildAlphaMask(); |
99 if (!ret) { | 99 if (!ret) { |
100 if (!m_bExtBuf && m_pBuffer) { | 100 if (!m_bExtBuf && m_pBuffer) { |
101 FX_Free(m_pBuffer); | 101 FX_Free(m_pBuffer); |
102 m_pBuffer = NULL; | 102 m_pBuffer = NULL; |
103 m_Width = m_Height = m_Pitch = 0; | 103 m_Width = m_Height = m_Pitch = 0; |
104 return false; | 104 return FALSE; |
105 } | 105 } |
106 } | 106 } |
107 } | 107 } |
108 return true; | 108 return TRUE; |
109 } | 109 } |
110 bool CFX_DIBitmap::Copy(const CFX_DIBSource* pSrc) | 110 FX_BOOL CFX_DIBitmap::Copy(const CFX_DIBSource* pSrc) |
111 { | 111 { |
112 if (m_pBuffer) { | 112 if (m_pBuffer) { |
113 return false; | 113 return FALSE; |
114 } | 114 } |
115 if (!Create(pSrc->GetWidth(), pSrc->GetHeight(), pSrc->GetFormat())) { | 115 if (!Create(pSrc->GetWidth(), pSrc->GetHeight(), pSrc->GetFormat())) { |
116 return false; | 116 return FALSE; |
117 } | 117 } |
118 CopyPalette(pSrc->GetPalette()); | 118 CopyPalette(pSrc->GetPalette()); |
119 CopyAlphaMask(pSrc->m_pAlphaMask); | 119 CopyAlphaMask(pSrc->m_pAlphaMask); |
120 for (int row = 0; row < pSrc->GetHeight(); row ++) { | 120 for (int row = 0; row < pSrc->GetHeight(); row ++) { |
121 FXSYS_memcpy(m_pBuffer + row * m_Pitch, pSrc->GetScanline(row), m_Pitch)
; | 121 FXSYS_memcpy(m_pBuffer + row * m_Pitch, pSrc->GetScanline(row), m_Pitch)
; |
122 } | 122 } |
123 return true; | 123 return TRUE; |
124 } | 124 } |
125 CFX_DIBitmap::~CFX_DIBitmap() | 125 CFX_DIBitmap::~CFX_DIBitmap() |
126 { | 126 { |
127 if (m_pBuffer && !m_bExtBuf) { | 127 if (m_pBuffer && !m_bExtBuf) { |
128 FX_Free(m_pBuffer); | 128 FX_Free(m_pBuffer); |
129 } | 129 } |
130 m_pBuffer = NULL; | 130 m_pBuffer = NULL; |
131 } | 131 } |
132 void CFX_DIBitmap::TakeOver(CFX_DIBitmap* pSrcBitmap) | 132 void CFX_DIBitmap::TakeOver(CFX_DIBitmap* pSrcBitmap) |
133 { | 133 { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 for (int i = 0; i < 256; i ++) { | 211 for (int i = 0; i < 256; i ++) { |
212 m_pPalette[i] = 0xff - i; | 212 m_pPalette[i] = 0xff - i; |
213 } | 213 } |
214 } else { | 214 } else { |
215 for (int i = 0; i < 256; i ++) { | 215 for (int i = 0; i < 256; i ++) { |
216 m_pPalette[i] = 0xff000000 | (i * 0x10101); | 216 m_pPalette[i] = 0xff000000 | (i * 0x10101); |
217 } | 217 } |
218 } | 218 } |
219 } | 219 } |
220 } | 220 } |
221 bool CFX_DIBSource::BuildAlphaMask() | 221 FX_BOOL CFX_DIBSource::BuildAlphaMask() |
222 { | 222 { |
223 if (m_pAlphaMask) { | 223 if (m_pAlphaMask) { |
224 return true; | 224 return TRUE; |
225 } | 225 } |
226 m_pAlphaMask = new CFX_DIBitmap; | 226 m_pAlphaMask = new CFX_DIBitmap; |
227 if (!m_pAlphaMask->Create(m_Width, m_Height, FXDIB_8bppMask)) { | 227 if (!m_pAlphaMask->Create(m_Width, m_Height, FXDIB_8bppMask)) { |
228 delete m_pAlphaMask; | 228 delete m_pAlphaMask; |
229 m_pAlphaMask = NULL; | 229 m_pAlphaMask = NULL; |
230 return false; | 230 return FALSE; |
231 } | 231 } |
232 FXSYS_memset(m_pAlphaMask->GetBuffer(), 0xff, m_pAlphaMask->GetHeight()*m_pA
lphaMask->GetPitch()); | 232 FXSYS_memset(m_pAlphaMask->GetBuffer(), 0xff, m_pAlphaMask->GetHeight()*m_pA
lphaMask->GetPitch()); |
233 return true; | 233 return TRUE; |
234 } | 234 } |
235 FX_DWORD CFX_DIBSource::GetPaletteEntry(int index) const | 235 FX_DWORD CFX_DIBSource::GetPaletteEntry(int index) const |
236 { | 236 { |
237 ASSERT((GetBPP() == 1 || GetBPP() == 8) && !IsAlphaMask()); | 237 ASSERT((GetBPP() == 1 || GetBPP() == 8) && !IsAlphaMask()); |
238 if (m_pPalette) { | 238 if (m_pPalette) { |
239 return m_pPalette[index]; | 239 return m_pPalette[index]; |
240 } | 240 } |
241 if (IsCmykImage()) { | 241 if (IsCmykImage()) { |
242 if (GetBPP() == 1) { | 242 if (GetBPP() == 1) { |
243 return index ? 0 : 0xff; | 243 return index ? 0 : 0xff; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 if (pClipRgn) { | 360 if (pClipRgn) { |
361 dest_rect.Intersect(pClipRgn->GetBox()); | 361 dest_rect.Intersect(pClipRgn->GetBox()); |
362 } | 362 } |
363 dest_left = dest_rect.left; | 363 dest_left = dest_rect.left; |
364 dest_top = dest_rect.top; | 364 dest_top = dest_rect.top; |
365 src_left = dest_left - x_offset; | 365 src_left = dest_left - x_offset; |
366 src_top = dest_top - y_offset; | 366 src_top = dest_top - y_offset; |
367 width = dest_rect.right - dest_rect.left; | 367 width = dest_rect.right - dest_rect.left; |
368 height = dest_rect.bottom - dest_rect.top; | 368 height = dest_rect.bottom - dest_rect.top; |
369 } | 369 } |
370 bool CFX_DIBitmap::TransferBitmap(int dest_left, int dest_top, int width, int he
ight, | 370 FX_BOOL CFX_DIBitmap::TransferBitmap(int dest_left, int dest_top, int width, int
height, |
371 const CFX_DIBSource* pSrcBitmap, int src_le
ft, int src_top, void* pIccTransform) | 371 const CFX_DIBSource* pSrcBitmap, int src_le
ft, int src_top, void* pIccTransform) |
372 { | 372 { |
373 if (m_pBuffer == NULL) { | 373 if (m_pBuffer == NULL) { |
374 return false; | 374 return FALSE; |
375 } | 375 } |
376 GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(), p
SrcBitmap->GetHeight(), src_left, src_top, NULL); | 376 GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(), p
SrcBitmap->GetHeight(), src_left, src_top, NULL); |
377 if (width == 0 || height == 0) { | 377 if (width == 0 || height == 0) { |
378 return true; | 378 return TRUE; |
379 } | 379 } |
380 FXDIB_Format dest_format = GetFormat(); | 380 FXDIB_Format dest_format = GetFormat(); |
381 FXDIB_Format src_format = pSrcBitmap->GetFormat(); | 381 FXDIB_Format src_format = pSrcBitmap->GetFormat(); |
382 if (dest_format == src_format && pIccTransform == NULL) { | 382 if (dest_format == src_format && pIccTransform == NULL) { |
383 if (GetBPP() == 1) { | 383 if (GetBPP() == 1) { |
384 for (int row = 0; row < height; row ++) { | 384 for (int row = 0; row < height; row ++) { |
385 uint8_t* dest_scan = m_pBuffer + (dest_top + row) * m_Pitch; | 385 uint8_t* dest_scan = m_pBuffer + (dest_top + row) * m_Pitch; |
386 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row)
; | 386 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row)
; |
387 for (int col = 0; col < width; col ++) { | 387 for (int col = 0; col < width; col ++) { |
388 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left +
col) % 8))) { | 388 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left +
col) % 8))) { |
389 dest_scan[(dest_left + col) / 8] |= 1 << (7 - (dest_left
+ col) % 8); | 389 dest_scan[(dest_left + col) / 8] |= 1 << (7 - (dest_left
+ col) % 8); |
390 } else { | 390 } else { |
391 dest_scan[(dest_left + col) / 8] &= ~(1 << (7 - (dest_le
ft + col) % 8)); | 391 dest_scan[(dest_left + col) / 8] &= ~(1 << (7 - (dest_le
ft + col) % 8)); |
392 } | 392 } |
393 } | 393 } |
394 } | 394 } |
395 } else { | 395 } else { |
396 int Bpp = GetBPP() / 8; | 396 int Bpp = GetBPP() / 8; |
397 for (int row = 0; row < height; row ++) { | 397 for (int row = 0; row < height; row ++) { |
398 uint8_t* dest_scan = m_pBuffer + (dest_top + row) * m_Pitch + de
st_left * Bpp; | 398 uint8_t* dest_scan = m_pBuffer + (dest_top + row) * m_Pitch + de
st_left * Bpp; |
399 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row)
+ src_left * Bpp; | 399 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row)
+ src_left * Bpp; |
400 FXSYS_memcpy(dest_scan, src_scan, width * Bpp); | 400 FXSYS_memcpy(dest_scan, src_scan, width * Bpp); |
401 } | 401 } |
402 } | 402 } |
403 } else { | 403 } else { |
404 if (m_pPalette) { | 404 if (m_pPalette) { |
405 return false; | 405 return FALSE; |
406 } | 406 } |
407 if (m_bpp == 8) { | 407 if (m_bpp == 8) { |
408 dest_format = FXDIB_8bppMask; | 408 dest_format = FXDIB_8bppMask; |
409 } | 409 } |
410 uint8_t* dest_buf = m_pBuffer + dest_top * m_Pitch + dest_left * GetBPP(
) / 8; | 410 uint8_t* dest_buf = m_pBuffer + dest_top * m_Pitch + dest_left * GetBPP(
) / 8; |
411 FX_DWORD* d_plt = NULL; | 411 FX_DWORD* d_plt = NULL; |
412 if(!ConvertBuffer(dest_format, dest_buf, m_Pitch, width, height, pSrcBit
map, src_left, src_top, d_plt, pIccTransform)) { | 412 if(!ConvertBuffer(dest_format, dest_buf, m_Pitch, width, height, pSrcBit
map, src_left, src_top, d_plt, pIccTransform)) { |
413 return false; | 413 return FALSE; |
414 } | 414 } |
415 } | 415 } |
416 return true; | 416 return TRUE; |
417 } | 417 } |
418 bool CFX_DIBitmap::TransferMask(int dest_left, int dest_top, int width, int heig
ht, | 418 FX_BOOL CFX_DIBitmap::TransferMask(int dest_left, int dest_top, int width, int h
eight, |
419 const CFX_DIBSource* pMask, FX_DWORD color, i
nt src_left, int src_top, int alpha_flag, void* pIccTransform) | 419 const CFX_DIBSource* pMask, FX_DWORD color, i
nt src_left, int src_top, int alpha_flag, void* pIccTransform) |
420 { | 420 { |
421 if (m_pBuffer == NULL) { | 421 if (m_pBuffer == NULL) { |
422 return false; | 422 return FALSE; |
423 } | 423 } |
424 ASSERT(HasAlpha() && (m_bpp >= 24)); | 424 ASSERT(HasAlpha() && (m_bpp >= 24)); |
425 ASSERT(pMask->IsAlphaMask()); | 425 ASSERT(pMask->IsAlphaMask()); |
426 if (!HasAlpha() || !pMask->IsAlphaMask() || m_bpp < 24) { | 426 if (!HasAlpha() || !pMask->IsAlphaMask() || m_bpp < 24) { |
427 return false; | 427 return FALSE; |
428 } | 428 } |
429 GetOverlapRect(dest_left, dest_top, width, height, pMask->GetWidth(), pMask-
>GetHeight(), src_left, src_top, NULL); | 429 GetOverlapRect(dest_left, dest_top, width, height, pMask->GetWidth(), pMask-
>GetHeight(), src_left, src_top, NULL); |
430 if (width == 0 || height == 0) { | 430 if (width == 0 || height == 0) { |
431 return true; | 431 return TRUE; |
432 } | 432 } |
433 int src_bpp = pMask->GetBPP(); | 433 int src_bpp = pMask->GetBPP(); |
434 int alpha; | 434 int alpha; |
435 FX_DWORD dst_color; | 435 FX_DWORD dst_color; |
436 if (alpha_flag >> 8) { | 436 if (alpha_flag >> 8) { |
437 alpha = alpha_flag & 0xff; | 437 alpha = alpha_flag & 0xff; |
438 dst_color = FXCMYK_TODIB(color); | 438 dst_color = FXCMYK_TODIB(color); |
439 } else { | 439 } else { |
440 alpha = FXARGB_A(color); | 440 alpha = FXARGB_A(color); |
441 dst_color = FXARGB_TODIB(color); | 441 dst_color = FXARGB_TODIB(color); |
442 } | 442 } |
443 uint8_t* color_p = (uint8_t*)&dst_color; | 443 uint8_t* color_p = (uint8_t*)&dst_color; |
444 if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() && CFX_GEModule::
Get()->GetCodecModule()->GetIccModule()) { | 444 if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() && CFX_GEModule::
Get()->GetCodecModule()->GetIccModule()) { |
445 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); | 445 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); |
446 pIccModule->TranslateScanline(pIccTransform, color_p, color_p, 1); | 446 pIccModule->TranslateScanline(pIccTransform, color_p, color_p, 1); |
447 } else { | 447 } else { |
448 if (alpha_flag >> 8 && !IsCmykImage()) | 448 if (alpha_flag >> 8 && !IsCmykImage()) |
449 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), F
XSYS_GetYValue(color), FXSYS_GetKValue(color), | 449 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), F
XSYS_GetYValue(color), FXSYS_GetKValue(color), |
450 color_p[2], color_p[1], color_p[0]); | 450 color_p[2], color_p[1], color_p[0]); |
451 else if (!(alpha_flag >> 8) && IsCmykImage()) { | 451 else if (!(alpha_flag >> 8) && IsCmykImage()) { |
452 return false; | 452 return FALSE; |
453 } | 453 } |
454 } | 454 } |
455 if(!IsCmykImage()) { | 455 if(!IsCmykImage()) { |
456 color_p[3] = (uint8_t)alpha; | 456 color_p[3] = (uint8_t)alpha; |
457 } | 457 } |
458 if (GetFormat() == FXDIB_Argb) { | 458 if (GetFormat() == FXDIB_Argb) { |
459 for (int row = 0; row < height; row ++) { | 459 for (int row = 0; row < height; row ++) { |
460 FX_DWORD* dest_pos = (FX_DWORD*)(m_pBuffer + (dest_top + row) * m_Pi
tch + dest_left * 4); | 460 FX_DWORD* dest_pos = (FX_DWORD*)(m_pBuffer + (dest_top + row) * m_Pi
tch + dest_left * 4); |
461 const uint8_t* src_scan = pMask->GetScanline(src_top + row); | 461 const uint8_t* src_scan = pMask->GetScanline(src_top + row); |
462 if (src_bpp == 1) { | 462 if (src_bpp == 1) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 } else { | 500 } else { |
501 src_scan += src_left; | 501 src_scan += src_left; |
502 for (int col = 0; col < width; col ++) { | 502 for (int col = 0; col < width; col ++) { |
503 FXSYS_memcpy(dest_color_pos, color_p, comps); | 503 FXSYS_memcpy(dest_color_pos, color_p, comps); |
504 dest_color_pos += comps; | 504 dest_color_pos += comps; |
505 *dest_alpha_pos++ = (alpha * (*src_scan++) / 255); | 505 *dest_alpha_pos++ = (alpha * (*src_scan++) / 255); |
506 } | 506 } |
507 } | 507 } |
508 } | 508 } |
509 } | 509 } |
510 return true; | 510 return TRUE; |
511 } | 511 } |
512 void CFX_DIBSource::CopyPalette(const FX_DWORD* pSrc, FX_DWORD size) | 512 void CFX_DIBSource::CopyPalette(const FX_DWORD* pSrc, FX_DWORD size) |
513 { | 513 { |
514 if (pSrc == NULL || GetBPP() > 8) { | 514 if (pSrc == NULL || GetBPP() > 8) { |
515 if (m_pPalette) { | 515 if (m_pPalette) { |
516 FX_Free(m_pPalette); | 516 FX_Free(m_pPalette); |
517 } | 517 } |
518 m_pPalette = NULL; | 518 m_pPalette = NULL; |
519 } else { | 519 } else { |
520 FX_DWORD pal_size = 1 << GetBPP(); | 520 FX_DWORD pal_size = 1 << GetBPP(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 for (int row = rect.top; row < rect.bottom; row ++) { | 563 for (int row = rect.top; row < rect.bottom; row ++) { |
564 const uint8_t* src_scan = GetScanline(row) + rect.left * 4 + 3; | 564 const uint8_t* src_scan = GetScanline(row) + rect.left * 4 + 3; |
565 uint8_t* dest_scan = (uint8_t*)pMask->GetScanline(row - rect.top); | 565 uint8_t* dest_scan = (uint8_t*)pMask->GetScanline(row - rect.top); |
566 for (int col = rect.left; col < rect.right; col ++) { | 566 for (int col = rect.left; col < rect.right; col ++) { |
567 *dest_scan ++ = *src_scan; | 567 *dest_scan ++ = *src_scan; |
568 src_scan += 4; | 568 src_scan += 4; |
569 } | 569 } |
570 } | 570 } |
571 return pMask; | 571 return pMask; |
572 } | 572 } |
573 bool CFX_DIBSource::CopyAlphaMask(const CFX_DIBSource* pAlphaMask, const FX_RECT
* pClip) | 573 FX_BOOL CFX_DIBSource::CopyAlphaMask(const CFX_DIBSource* pAlphaMask, const FX_R
ECT* pClip) |
574 { | 574 { |
575 if (!HasAlpha() || GetFormat() == FXDIB_Argb) { | 575 if (!HasAlpha() || GetFormat() == FXDIB_Argb) { |
576 return false; | 576 return FALSE; |
577 } | 577 } |
578 if (pAlphaMask) { | 578 if (pAlphaMask) { |
579 FX_RECT rect(0, 0, pAlphaMask->m_Width, pAlphaMask->m_Height); | 579 FX_RECT rect(0, 0, pAlphaMask->m_Width, pAlphaMask->m_Height); |
580 if (pClip) { | 580 if (pClip) { |
581 rect.Intersect(*pClip); | 581 rect.Intersect(*pClip); |
582 if (rect.IsEmpty() || rect.Width() != m_Width || rect.Height() != m_
Height) { | 582 if (rect.IsEmpty() || rect.Width() != m_Width || rect.Height() != m_
Height) { |
583 return false; | 583 return FALSE; |
584 } | 584 } |
585 } else { | 585 } else { |
586 if (pAlphaMask->m_Width != m_Width || pAlphaMask->m_Height != m_Heig
ht) { | 586 if (pAlphaMask->m_Width != m_Width || pAlphaMask->m_Height != m_Heig
ht) { |
587 return false; | 587 return FALSE; |
588 } | 588 } |
589 } | 589 } |
590 for (int row = 0; row < m_Height; row ++) | 590 for (int row = 0; row < m_Height; row ++) |
591 FXSYS_memcpy((void*)m_pAlphaMask->GetScanline(row), | 591 FXSYS_memcpy((void*)m_pAlphaMask->GetScanline(row), |
592 pAlphaMask->GetScanline(row + rect.top) + rect.left,
m_pAlphaMask->m_Pitch); | 592 pAlphaMask->GetScanline(row + rect.top) + rect.left,
m_pAlphaMask->m_Pitch); |
593 } else { | 593 } else { |
594 m_pAlphaMask->Clear(0xff000000); | 594 m_pAlphaMask->Clear(0xff000000); |
595 } | 595 } |
596 return true; | 596 return TRUE; |
597 } | 597 } |
598 const int g_ChannelOffset[] = {0, 2, 1, 0, 0, 1, 2, 3, 3}; | 598 const int g_ChannelOffset[] = {0, 2, 1, 0, 0, 1, 2, 3, 3}; |
599 bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, const CFX_DIBSource* p
SrcBitmap, FXDIB_Channel srcChannel) | 599 FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, const CFX_DIBSource
* pSrcBitmap, FXDIB_Channel srcChannel) |
600 { | 600 { |
601 if (m_pBuffer == NULL) { | 601 if (m_pBuffer == NULL) { |
602 return false; | 602 return FALSE; |
603 } | 603 } |
604 CFX_DIBSource* pSrcClone = (CFX_DIBSource*)pSrcBitmap; | 604 CFX_DIBSource* pSrcClone = (CFX_DIBSource*)pSrcBitmap; |
605 CFX_DIBitmap* pDst = this; | 605 CFX_DIBitmap* pDst = this; |
606 int destOffset, srcOffset; | 606 int destOffset, srcOffset; |
607 if (srcChannel == FXDIB_Alpha) { | 607 if (srcChannel == FXDIB_Alpha) { |
608 if (!pSrcBitmap->HasAlpha() && !pSrcBitmap->IsAlphaMask()) { | 608 if (!pSrcBitmap->HasAlpha() && !pSrcBitmap->IsAlphaMask()) { |
609 return false; | 609 return FALSE; |
610 } | 610 } |
611 if (pSrcBitmap->GetBPP() == 1) { | 611 if (pSrcBitmap->GetBPP() == 1) { |
612 pSrcClone = pSrcBitmap->CloneConvert(FXDIB_8bppMask); | 612 pSrcClone = pSrcBitmap->CloneConvert(FXDIB_8bppMask); |
613 if (pSrcClone == NULL) { | 613 if (pSrcClone == NULL) { |
614 return false; | 614 return FALSE; |
615 } | 615 } |
616 } | 616 } |
617 if(pSrcBitmap->GetFormat() == FXDIB_Argb) { | 617 if(pSrcBitmap->GetFormat() == FXDIB_Argb) { |
618 srcOffset = 3; | 618 srcOffset = 3; |
619 } else { | 619 } else { |
620 srcOffset = 0; | 620 srcOffset = 0; |
621 } | 621 } |
622 } else { | 622 } else { |
623 if (pSrcBitmap->IsAlphaMask()) { | 623 if (pSrcBitmap->IsAlphaMask()) { |
624 return false; | 624 return FALSE; |
625 } | 625 } |
626 if (pSrcBitmap->GetBPP() < 24) { | 626 if (pSrcBitmap->GetBPP() < 24) { |
627 if (pSrcBitmap->IsCmykImage()) { | 627 if (pSrcBitmap->IsCmykImage()) { |
628 pSrcClone = pSrcBitmap->CloneConvert((FXDIB_Format)((pSrcBitmap-
>GetFormat() & 0xff00) | 0x20)); | 628 pSrcClone = pSrcBitmap->CloneConvert((FXDIB_Format)((pSrcBitmap-
>GetFormat() & 0xff00) | 0x20)); |
629 } else { | 629 } else { |
630 pSrcClone = pSrcBitmap->CloneConvert((FXDIB_Format)((pSrcBitmap-
>GetFormat() & 0xff00) | 0x18)); | 630 pSrcClone = pSrcBitmap->CloneConvert((FXDIB_Format)((pSrcBitmap-
>GetFormat() & 0xff00) | 0x18)); |
631 } | 631 } |
632 if (pSrcClone == NULL) { | 632 if (pSrcClone == NULL) { |
633 return false; | 633 return FALSE; |
634 } | 634 } |
635 } | 635 } |
636 srcOffset = g_ChannelOffset[srcChannel]; | 636 srcOffset = g_ChannelOffset[srcChannel]; |
637 } | 637 } |
638 if (destChannel == FXDIB_Alpha) { | 638 if (destChannel == FXDIB_Alpha) { |
639 if (IsAlphaMask()) { | 639 if (IsAlphaMask()) { |
640 if(!ConvertFormat(FXDIB_8bppMask)) { | 640 if(!ConvertFormat(FXDIB_8bppMask)) { |
641 if (pSrcClone != pSrcBitmap) { | 641 if (pSrcClone != pSrcBitmap) { |
642 delete pSrcClone; | 642 delete pSrcClone; |
643 } | 643 } |
644 return false; | 644 return FALSE; |
645 } | 645 } |
646 destOffset = 0; | 646 destOffset = 0; |
647 } else { | 647 } else { |
648 destOffset = 0; | 648 destOffset = 0; |
649 if(!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb)) { | 649 if(!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb)) { |
650 if (pSrcClone != pSrcBitmap) { | 650 if (pSrcClone != pSrcBitmap) { |
651 delete pSrcClone; | 651 delete pSrcClone; |
652 } | 652 } |
653 return false; | 653 return FALSE; |
654 } | 654 } |
655 if (GetFormat() == FXDIB_Argb) { | 655 if (GetFormat() == FXDIB_Argb) { |
656 destOffset = 3; | 656 destOffset = 3; |
657 } | 657 } |
658 } | 658 } |
659 } else { | 659 } else { |
660 if (IsAlphaMask()) { | 660 if (IsAlphaMask()) { |
661 if (pSrcClone != pSrcBitmap) { | 661 if (pSrcClone != pSrcBitmap) { |
662 delete pSrcClone; | 662 delete pSrcClone; |
663 } | 663 } |
664 return false; | 664 return FALSE; |
665 } | 665 } |
666 if (GetBPP() < 24) { | 666 if (GetBPP() < 24) { |
667 if (HasAlpha()) { | 667 if (HasAlpha()) { |
668 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb)) { | 668 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb)) { |
669 if (pSrcClone != pSrcBitmap) { | 669 if (pSrcClone != pSrcBitmap) { |
670 delete pSrcClone; | 670 delete pSrcClone; |
671 } | 671 } |
672 return false; | 672 return FALSE; |
673 } | 673 } |
674 } else | 674 } else |
675 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 675 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
676 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb32)) { | 676 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb32)) { |
677 #else | 677 #else |
678 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb)) { | 678 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb)) { |
679 #endif | 679 #endif |
680 if (pSrcClone != pSrcBitmap) { | 680 if (pSrcClone != pSrcBitmap) { |
681 delete pSrcClone; | 681 delete pSrcClone; |
682 } | 682 } |
683 return false; | 683 return FALSE; |
684 } | 684 } |
685 } | 685 } |
686 destOffset = g_ChannelOffset[destChannel]; | 686 destOffset = g_ChannelOffset[destChannel]; |
687 } | 687 } |
688 if (srcChannel == FXDIB_Alpha && pSrcClone->m_pAlphaMask) { | 688 if (srcChannel == FXDIB_Alpha && pSrcClone->m_pAlphaMask) { |
689 CFX_DIBitmap* pAlphaMask = pSrcClone->m_pAlphaMask; | 689 CFX_DIBitmap* pAlphaMask = pSrcClone->m_pAlphaMask; |
690 if (pSrcClone->GetWidth() != m_Width || pSrcClone->GetHeight() != m_Heig
ht) { | 690 if (pSrcClone->GetWidth() != m_Width || pSrcClone->GetHeight() != m_Heig
ht) { |
691 if (pAlphaMask) { | 691 if (pAlphaMask) { |
692 pAlphaMask = pAlphaMask->StretchTo(m_Width, m_Height); | 692 pAlphaMask = pAlphaMask->StretchTo(m_Width, m_Height); |
693 if (pAlphaMask == NULL) { | 693 if (pAlphaMask == NULL) { |
694 if (pSrcClone != pSrcBitmap) { | 694 if (pSrcClone != pSrcBitmap) { |
695 delete pSrcClone; | 695 delete pSrcClone; |
696 } | 696 } |
697 return false; | 697 return FALSE; |
698 } | 698 } |
699 } | 699 } |
700 } | 700 } |
701 if (pSrcClone != pSrcBitmap) { | 701 if (pSrcClone != pSrcBitmap) { |
702 pSrcClone->m_pAlphaMask = NULL; | 702 pSrcClone->m_pAlphaMask = NULL; |
703 delete pSrcClone; | 703 delete pSrcClone; |
704 } | 704 } |
705 pSrcClone = pAlphaMask; | 705 pSrcClone = pAlphaMask; |
706 srcOffset = 0; | 706 srcOffset = 0; |
707 } else if (pSrcClone->GetWidth() != m_Width || pSrcClone->GetHeight() != m_H
eight) { | 707 } else if (pSrcClone->GetWidth() != m_Width || pSrcClone->GetHeight() != m_H
eight) { |
708 CFX_DIBitmap* pSrcMatched = pSrcClone->StretchTo(m_Width, m_Height); | 708 CFX_DIBitmap* pSrcMatched = pSrcClone->StretchTo(m_Width, m_Height); |
709 if (pSrcClone != pSrcBitmap) { | 709 if (pSrcClone != pSrcBitmap) { |
710 delete pSrcClone; | 710 delete pSrcClone; |
711 } | 711 } |
712 if (pSrcMatched == NULL) { | 712 if (pSrcMatched == NULL) { |
713 return false; | 713 return FALSE; |
714 } | 714 } |
715 pSrcClone = pSrcMatched; | 715 pSrcClone = pSrcMatched; |
716 } | 716 } |
717 if (destChannel == FXDIB_Alpha && m_pAlphaMask) { | 717 if (destChannel == FXDIB_Alpha && m_pAlphaMask) { |
718 pDst = m_pAlphaMask; | 718 pDst = m_pAlphaMask; |
719 destOffset = 0; | 719 destOffset = 0; |
720 } | 720 } |
721 int srcBytes = pSrcClone->GetBPP() / 8; | 721 int srcBytes = pSrcClone->GetBPP() / 8; |
722 int destBytes = pDst->GetBPP() / 8; | 722 int destBytes = pDst->GetBPP() / 8; |
723 for (int row = 0; row < m_Height; row ++) { | 723 for (int row = 0; row < m_Height; row ++) { |
724 uint8_t* dest_pos = (uint8_t*)pDst->GetScanline(row) + destOffset; | 724 uint8_t* dest_pos = (uint8_t*)pDst->GetScanline(row) + destOffset; |
725 const uint8_t* src_pos = pSrcClone->GetScanline(row) + srcOffset; | 725 const uint8_t* src_pos = pSrcClone->GetScanline(row) + srcOffset; |
726 for (int col = 0; col < m_Width; col ++) { | 726 for (int col = 0; col < m_Width; col ++) { |
727 *dest_pos = *src_pos; | 727 *dest_pos = *src_pos; |
728 dest_pos += destBytes; | 728 dest_pos += destBytes; |
729 src_pos += srcBytes; | 729 src_pos += srcBytes; |
730 } | 730 } |
731 } | 731 } |
732 if (pSrcClone != pSrcBitmap && pSrcClone != pSrcBitmap->m_pAlphaMask) { | 732 if (pSrcClone != pSrcBitmap && pSrcClone != pSrcBitmap->m_pAlphaMask) { |
733 delete pSrcClone; | 733 delete pSrcClone; |
734 } | 734 } |
735 return true; | 735 return TRUE; |
736 } | 736 } |
737 bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, int value) | 737 FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, int value) |
738 { | 738 { |
739 if (m_pBuffer == NULL) { | 739 if (m_pBuffer == NULL) { |
740 return false; | 740 return FALSE; |
741 } | 741 } |
742 int destOffset; | 742 int destOffset; |
743 if (destChannel == FXDIB_Alpha) { | 743 if (destChannel == FXDIB_Alpha) { |
744 if (IsAlphaMask()) { | 744 if (IsAlphaMask()) { |
745 if(!ConvertFormat(FXDIB_8bppMask)) { | 745 if(!ConvertFormat(FXDIB_8bppMask)) { |
746 return false; | 746 return FALSE; |
747 } | 747 } |
748 destOffset = 0; | 748 destOffset = 0; |
749 } else { | 749 } else { |
750 destOffset = 0; | 750 destOffset = 0; |
751 if(!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb)) { | 751 if(!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb)) { |
752 return false; | 752 return FALSE; |
753 } | 753 } |
754 if (GetFormat() == FXDIB_Argb) { | 754 if (GetFormat() == FXDIB_Argb) { |
755 destOffset = 3; | 755 destOffset = 3; |
756 } | 756 } |
757 } | 757 } |
758 } else { | 758 } else { |
759 if (IsAlphaMask()) { | 759 if (IsAlphaMask()) { |
760 return false; | 760 return FALSE; |
761 } | 761 } |
762 if (GetBPP() < 24) { | 762 if (GetBPP() < 24) { |
763 if (HasAlpha()) { | 763 if (HasAlpha()) { |
764 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb)) { | 764 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb)) { |
765 return false; | 765 return FALSE; |
766 } | 766 } |
767 } else | 767 } else |
768 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 768 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
769 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb)) { | 769 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb)) { |
770 return false; | 770 return FALSE; |
771 } | 771 } |
772 #else | 772 #else |
773 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb32)) { | 773 if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb32)) { |
774 return false; | 774 return FALSE; |
775 } | 775 } |
776 #endif | 776 #endif |
777 } | 777 } |
778 destOffset = g_ChannelOffset[destChannel]; | 778 destOffset = g_ChannelOffset[destChannel]; |
779 } | 779 } |
780 int Bpp = GetBPP() / 8; | 780 int Bpp = GetBPP() / 8; |
781 if (Bpp == 1) { | 781 if (Bpp == 1) { |
782 FXSYS_memset(m_pBuffer, value, m_Height * m_Pitch); | 782 FXSYS_memset(m_pBuffer, value, m_Height * m_Pitch); |
783 return true; | 783 return TRUE; |
784 } | 784 } |
785 if (destChannel == FXDIB_Alpha && m_pAlphaMask) { | 785 if (destChannel == FXDIB_Alpha && m_pAlphaMask) { |
786 FXSYS_memset(m_pAlphaMask->GetBuffer(), value, m_pAlphaMask->GetHeight()
*m_pAlphaMask->GetPitch()); | 786 FXSYS_memset(m_pAlphaMask->GetBuffer(), value, m_pAlphaMask->GetHeight()
*m_pAlphaMask->GetPitch()); |
787 return true; | 787 return TRUE; |
788 } | 788 } |
789 for (int row = 0; row < m_Height; row ++) { | 789 for (int row = 0; row < m_Height; row ++) { |
790 uint8_t* scan_line = m_pBuffer + row * m_Pitch + destOffset; | 790 uint8_t* scan_line = m_pBuffer + row * m_Pitch + destOffset; |
791 for (int col = 0; col < m_Width; col ++) { | 791 for (int col = 0; col < m_Width; col ++) { |
792 *scan_line = value; | 792 *scan_line = value; |
793 scan_line += Bpp; | 793 scan_line += Bpp; |
794 } | 794 } |
795 } | 795 } |
796 return true; | 796 return TRUE; |
797 } | 797 } |
798 bool CFX_DIBitmap::MultiplyAlpha(const CFX_DIBSource* pSrcBitmap) | 798 FX_BOOL CFX_DIBitmap::MultiplyAlpha(const CFX_DIBSource* pSrcBitmap) |
799 { | 799 { |
800 if (m_pBuffer == NULL) { | 800 if (m_pBuffer == NULL) { |
801 return false; | 801 return FALSE; |
802 } | 802 } |
803 ASSERT(pSrcBitmap->IsAlphaMask()); | 803 ASSERT(pSrcBitmap->IsAlphaMask()); |
804 if (!pSrcBitmap->IsAlphaMask()) { | 804 if (!pSrcBitmap->IsAlphaMask()) { |
805 return false; | 805 return FALSE; |
806 } | 806 } |
807 if (!IsAlphaMask() && !HasAlpha()) { | 807 if (!IsAlphaMask() && !HasAlpha()) { |
808 return LoadChannel(FXDIB_Alpha, pSrcBitmap, FXDIB_Alpha); | 808 return LoadChannel(FXDIB_Alpha, pSrcBitmap, FXDIB_Alpha); |
809 } | 809 } |
810 CFX_DIBitmap* pSrcClone = (CFX_DIBitmap*)pSrcBitmap; | 810 CFX_DIBitmap* pSrcClone = (CFX_DIBitmap*)pSrcBitmap; |
811 if (pSrcBitmap->GetWidth() != m_Width || pSrcBitmap->GetHeight() != m_Height
) { | 811 if (pSrcBitmap->GetWidth() != m_Width || pSrcBitmap->GetHeight() != m_Height
) { |
812 pSrcClone = pSrcBitmap->StretchTo(m_Width, m_Height); | 812 pSrcClone = pSrcBitmap->StretchTo(m_Width, m_Height); |
813 ASSERT(pSrcClone != NULL); | 813 ASSERT(pSrcClone != NULL); |
814 if (pSrcClone == NULL) { | 814 if (pSrcClone == NULL) { |
815 return false; | 815 return FALSE; |
816 } | 816 } |
817 } | 817 } |
818 if (IsAlphaMask()) { | 818 if (IsAlphaMask()) { |
819 if(!ConvertFormat(FXDIB_8bppMask)) { | 819 if(!ConvertFormat(FXDIB_8bppMask)) { |
820 if (pSrcClone != pSrcBitmap) { | 820 if (pSrcClone != pSrcBitmap) { |
821 delete pSrcClone; | 821 delete pSrcClone; |
822 } | 822 } |
823 return false; | 823 return FALSE; |
824 } | 824 } |
825 for (int row = 0; row < m_Height; row ++) { | 825 for (int row = 0; row < m_Height; row ++) { |
826 uint8_t* dest_scan = m_pBuffer + m_Pitch * row; | 826 uint8_t* dest_scan = m_pBuffer + m_Pitch * row; |
827 uint8_t* src_scan = pSrcClone->m_pBuffer + pSrcClone->m_Pitch * row; | 827 uint8_t* src_scan = pSrcClone->m_pBuffer + pSrcClone->m_Pitch * row; |
828 if (pSrcClone->GetBPP() == 1) { | 828 if (pSrcClone->GetBPP() == 1) { |
829 for (int col = 0; col < m_Width; col ++) { | 829 for (int col = 0; col < m_Width; col ++) { |
830 if (!((1 << (7 - col % 8)) & src_scan[col / 8])) { | 830 if (!((1 << (7 - col % 8)) & src_scan[col / 8])) { |
831 dest_scan[col] = 0; | 831 dest_scan[col] = 0; |
832 } | 832 } |
833 } | 833 } |
834 } else { | 834 } else { |
835 for (int col = 0; col < m_Width; col ++) { | 835 for (int col = 0; col < m_Width; col ++) { |
836 *dest_scan = (*dest_scan) * src_scan[col] / 255; | 836 *dest_scan = (*dest_scan) * src_scan[col] / 255; |
837 dest_scan ++; | 837 dest_scan ++; |
838 } | 838 } |
839 } | 839 } |
840 } | 840 } |
841 } else { | 841 } else { |
842 if(GetFormat() == FXDIB_Argb) { | 842 if(GetFormat() == FXDIB_Argb) { |
843 if (pSrcClone->GetBPP() == 1) { | 843 if (pSrcClone->GetBPP() == 1) { |
844 if (pSrcClone != pSrcBitmap) { | 844 if (pSrcClone != pSrcBitmap) { |
845 delete pSrcClone; | 845 delete pSrcClone; |
846 } | 846 } |
847 return false; | 847 return FALSE; |
848 } | 848 } |
849 for (int row = 0; row < m_Height; row ++) { | 849 for (int row = 0; row < m_Height; row ++) { |
850 uint8_t* dest_scan = m_pBuffer + m_Pitch * row + 3; | 850 uint8_t* dest_scan = m_pBuffer + m_Pitch * row + 3; |
851 uint8_t* src_scan = pSrcClone->m_pBuffer + pSrcClone->m_Pitch *
row; | 851 uint8_t* src_scan = pSrcClone->m_pBuffer + pSrcClone->m_Pitch *
row; |
852 for (int col = 0; col < m_Width; col ++) { | 852 for (int col = 0; col < m_Width; col ++) { |
853 *dest_scan = (*dest_scan) * src_scan[col] / 255; | 853 *dest_scan = (*dest_scan) * src_scan[col] / 255; |
854 dest_scan += 4; | 854 dest_scan += 4; |
855 } | 855 } |
856 } | 856 } |
857 } else { | 857 } else { |
858 m_pAlphaMask->MultiplyAlpha(pSrcClone); | 858 m_pAlphaMask->MultiplyAlpha(pSrcClone); |
859 } | 859 } |
860 } | 860 } |
861 if (pSrcClone != pSrcBitmap) { | 861 if (pSrcClone != pSrcBitmap) { |
862 delete pSrcClone; | 862 delete pSrcClone; |
863 } | 863 } |
864 return true; | 864 return TRUE; |
865 } | 865 } |
866 bool CFX_DIBitmap::GetGrayData(void* pIccTransform) | 866 FX_BOOL CFX_DIBitmap::GetGrayData(void* pIccTransform) |
867 { | 867 { |
868 if (m_pBuffer == NULL) { | 868 if (m_pBuffer == NULL) { |
869 return false; | 869 return FALSE; |
870 } | 870 } |
871 switch (GetFormat()) { | 871 switch (GetFormat()) { |
872 case FXDIB_1bppRgb: { | 872 case FXDIB_1bppRgb: { |
873 if (m_pPalette == NULL) { | 873 if (m_pPalette == NULL) { |
874 return false; | 874 return FALSE; |
875 } | 875 } |
876 uint8_t gray[2]; | 876 uint8_t gray[2]; |
877 for (int i = 0; i < 2; i ++) { | 877 for (int i = 0; i < 2; i ++) { |
878 int r = (uint8_t)(m_pPalette[i] >> 16); | 878 int r = (uint8_t)(m_pPalette[i] >> 16); |
879 int g = (uint8_t)(m_pPalette[i] >> 8); | 879 int g = (uint8_t)(m_pPalette[i] >> 8); |
880 int b = (uint8_t)m_pPalette[i]; | 880 int b = (uint8_t)m_pPalette[i]; |
881 gray[i] = (uint8_t)FXRGB2GRAY(r, g, b); | 881 gray[i] = (uint8_t)FXRGB2GRAY(r, g, b); |
882 } | 882 } |
883 CFX_DIBitmap* pMask = new CFX_DIBitmap; | 883 CFX_DIBitmap* pMask = new CFX_DIBitmap; |
884 if (!pMask->Create(m_Width, m_Height, FXDIB_8bppMask)) { | 884 if (!pMask->Create(m_Width, m_Height, FXDIB_8bppMask)) { |
885 delete pMask; | 885 delete pMask; |
886 return false; | 886 return FALSE; |
887 } | 887 } |
888 FXSYS_memset(pMask->GetBuffer(), gray[0], pMask->GetPitch() * m_
Height); | 888 FXSYS_memset(pMask->GetBuffer(), gray[0], pMask->GetPitch() * m_
Height); |
889 for (int row = 0; row < m_Height; row ++) { | 889 for (int row = 0; row < m_Height; row ++) { |
890 uint8_t* src_pos = m_pBuffer + row * m_Pitch; | 890 uint8_t* src_pos = m_pBuffer + row * m_Pitch; |
891 uint8_t* dest_pos = (uint8_t*)pMask->GetScanline(row); | 891 uint8_t* dest_pos = (uint8_t*)pMask->GetScanline(row); |
892 for (int col = 0; col < m_Width; col ++) { | 892 for (int col = 0; col < m_Width; col ++) { |
893 if (src_pos[col / 8] & (1 << (7 - col % 8))) { | 893 if (src_pos[col / 8] & (1 << (7 - col % 8))) { |
894 *dest_pos = gray[1]; | 894 *dest_pos = gray[1]; |
895 } | 895 } |
896 dest_pos ++; | 896 dest_pos ++; |
897 } | 897 } |
898 } | 898 } |
899 TakeOver(pMask); | 899 TakeOver(pMask); |
900 delete pMask; | 900 delete pMask; |
901 break; | 901 break; |
902 } | 902 } |
903 case FXDIB_8bppRgb: { | 903 case FXDIB_8bppRgb: { |
904 if (m_pPalette == NULL) { | 904 if (m_pPalette == NULL) { |
905 return false; | 905 return FALSE; |
906 } | 906 } |
907 uint8_t gray[256]; | 907 uint8_t gray[256]; |
908 for (int i = 0; i < 256; i ++) { | 908 for (int i = 0; i < 256; i ++) { |
909 int r = (uint8_t)(m_pPalette[i] >> 16); | 909 int r = (uint8_t)(m_pPalette[i] >> 16); |
910 int g = (uint8_t)(m_pPalette[i] >> 8); | 910 int g = (uint8_t)(m_pPalette[i] >> 8); |
911 int b = (uint8_t)m_pPalette[i]; | 911 int b = (uint8_t)m_pPalette[i]; |
912 gray[i] = (uint8_t)FXRGB2GRAY(r, g, b); | 912 gray[i] = (uint8_t)FXRGB2GRAY(r, g, b); |
913 } | 913 } |
914 CFX_DIBitmap* pMask = new CFX_DIBitmap; | 914 CFX_DIBitmap* pMask = new CFX_DIBitmap; |
915 if (!pMask->Create(m_Width, m_Height, FXDIB_8bppMask)) { | 915 if (!pMask->Create(m_Width, m_Height, FXDIB_8bppMask)) { |
916 delete pMask; | 916 delete pMask; |
917 return false; | 917 return FALSE; |
918 } | 918 } |
919 for (int row = 0; row < m_Height; row ++) { | 919 for (int row = 0; row < m_Height; row ++) { |
920 uint8_t* dest_pos = pMask->GetBuffer() + row * pMask->GetPit
ch(); | 920 uint8_t* dest_pos = pMask->GetBuffer() + row * pMask->GetPit
ch(); |
921 uint8_t* src_pos = m_pBuffer + row * m_Pitch; | 921 uint8_t* src_pos = m_pBuffer + row * m_Pitch; |
922 for (int col = 0; col < m_Width; col ++) { | 922 for (int col = 0; col < m_Width; col ++) { |
923 *dest_pos ++ = gray[*src_pos ++]; | 923 *dest_pos ++ = gray[*src_pos ++]; |
924 } | 924 } |
925 } | 925 } |
926 TakeOver(pMask); | 926 TakeOver(pMask); |
927 delete pMask; | 927 delete pMask; |
928 break; | 928 break; |
929 } | 929 } |
930 case FXDIB_Rgb: { | 930 case FXDIB_Rgb: { |
931 CFX_DIBitmap* pMask = new CFX_DIBitmap; | 931 CFX_DIBitmap* pMask = new CFX_DIBitmap; |
932 if (!pMask->Create(m_Width, m_Height, FXDIB_8bppMask)) { | 932 if (!pMask->Create(m_Width, m_Height, FXDIB_8bppMask)) { |
933 delete pMask; | 933 delete pMask; |
934 return false; | 934 return FALSE; |
935 } | 935 } |
936 for (int row = 0; row < m_Height; row ++) { | 936 for (int row = 0; row < m_Height; row ++) { |
937 uint8_t* src_pos = m_pBuffer + row * m_Pitch; | 937 uint8_t* src_pos = m_pBuffer + row * m_Pitch; |
938 uint8_t* dest_pos = pMask->GetBuffer() + row * pMask->GetPit
ch(); | 938 uint8_t* dest_pos = pMask->GetBuffer() + row * pMask->GetPit
ch(); |
939 for (int col = 0; col < m_Width; col ++) { | 939 for (int col = 0; col < m_Width; col ++) { |
940 *dest_pos ++ = FXRGB2GRAY(src_pos[2], src_pos[1], *src_p
os); | 940 *dest_pos ++ = FXRGB2GRAY(src_pos[2], src_pos[1], *src_p
os); |
941 src_pos += 3; | 941 src_pos += 3; |
942 } | 942 } |
943 } | 943 } |
944 TakeOver(pMask); | 944 TakeOver(pMask); |
945 delete pMask; | 945 delete pMask; |
946 break; | 946 break; |
947 } | 947 } |
948 case FXDIB_Rgb32: { | 948 case FXDIB_Rgb32: { |
949 CFX_DIBitmap* pMask = new CFX_DIBitmap; | 949 CFX_DIBitmap* pMask = new CFX_DIBitmap; |
950 if (!pMask->Create(m_Width, m_Height, FXDIB_8bppMask)) { | 950 if (!pMask->Create(m_Width, m_Height, FXDIB_8bppMask)) { |
951 delete pMask; | 951 delete pMask; |
952 return false; | 952 return FALSE; |
953 } | 953 } |
954 for (int row = 0; row < m_Height; row ++) { | 954 for (int row = 0; row < m_Height; row ++) { |
955 uint8_t* src_pos = m_pBuffer + row * m_Pitch; | 955 uint8_t* src_pos = m_pBuffer + row * m_Pitch; |
956 uint8_t* dest_pos = pMask->GetBuffer() + row * pMask->GetPit
ch(); | 956 uint8_t* dest_pos = pMask->GetBuffer() + row * pMask->GetPit
ch(); |
957 for (int col = 0; col < m_Width; col ++) { | 957 for (int col = 0; col < m_Width; col ++) { |
958 *dest_pos ++ = FXRGB2GRAY(src_pos[2], src_pos[1], *src_p
os); | 958 *dest_pos ++ = FXRGB2GRAY(src_pos[2], src_pos[1], *src_p
os); |
959 src_pos += 4; | 959 src_pos += 4; |
960 } | 960 } |
961 } | 961 } |
962 TakeOver(pMask); | 962 TakeOver(pMask); |
963 delete pMask; | 963 delete pMask; |
964 break; | 964 break; |
965 } | 965 } |
966 default: | 966 default: |
967 return false; | 967 return FALSE; |
968 } | 968 } |
969 return true; | 969 return TRUE; |
970 } | 970 } |
971 bool CFX_DIBitmap::MultiplyAlpha(int alpha) | 971 FX_BOOL CFX_DIBitmap::MultiplyAlpha(int alpha) |
972 { | 972 { |
973 if (m_pBuffer == NULL) { | 973 if (m_pBuffer == NULL) { |
974 return false; | 974 return FALSE; |
975 } | 975 } |
976 switch (GetFormat()) { | 976 switch (GetFormat()) { |
977 case FXDIB_1bppMask: | 977 case FXDIB_1bppMask: |
978 if (!ConvertFormat(FXDIB_8bppMask)) { | 978 if (!ConvertFormat(FXDIB_8bppMask)) { |
979 return false; | 979 return FALSE; |
980 } | 980 } |
981 MultiplyAlpha(alpha); | 981 MultiplyAlpha(alpha); |
982 break; | 982 break; |
983 case FXDIB_8bppMask: { | 983 case FXDIB_8bppMask: { |
984 for (int row = 0; row < m_Height; row ++) { | 984 for (int row = 0; row < m_Height; row ++) { |
985 uint8_t* scan_line = m_pBuffer + row * m_Pitch; | 985 uint8_t* scan_line = m_pBuffer + row * m_Pitch; |
986 for (int col = 0; col < m_Width; col ++) { | 986 for (int col = 0; col < m_Width; col ++) { |
987 scan_line[col] = scan_line[col] * alpha / 255; | 987 scan_line[col] = scan_line[col] * alpha / 255; |
988 } | 988 } |
989 } | 989 } |
990 break; | 990 break; |
991 } | 991 } |
992 case FXDIB_Argb: { | 992 case FXDIB_Argb: { |
993 for (int row = 0; row < m_Height; row ++) { | 993 for (int row = 0; row < m_Height; row ++) { |
994 uint8_t* scan_line = m_pBuffer + row * m_Pitch + 3; | 994 uint8_t* scan_line = m_pBuffer + row * m_Pitch + 3; |
995 for (int col = 0; col < m_Width; col ++) { | 995 for (int col = 0; col < m_Width; col ++) { |
996 *scan_line = (*scan_line) * alpha / 255; | 996 *scan_line = (*scan_line) * alpha / 255; |
997 scan_line += 4; | 997 scan_line += 4; |
998 } | 998 } |
999 } | 999 } |
1000 break; | 1000 break; |
1001 } | 1001 } |
1002 default: | 1002 default: |
1003 if (HasAlpha()) { | 1003 if (HasAlpha()) { |
1004 m_pAlphaMask->MultiplyAlpha(alpha); | 1004 m_pAlphaMask->MultiplyAlpha(alpha); |
1005 } else if (IsCmykImage()) { | 1005 } else if (IsCmykImage()) { |
1006 if (!ConvertFormat((FXDIB_Format)(GetFormat() | 0x0200))) { | 1006 if (!ConvertFormat((FXDIB_Format)(GetFormat() | 0x0200))) { |
1007 return false; | 1007 return FALSE; |
1008 } | 1008 } |
1009 m_pAlphaMask->MultiplyAlpha(alpha); | 1009 m_pAlphaMask->MultiplyAlpha(alpha); |
1010 } else { | 1010 } else { |
1011 if (!ConvertFormat(FXDIB_Argb)) { | 1011 if (!ConvertFormat(FXDIB_Argb)) { |
1012 return false; | 1012 return FALSE; |
1013 } | 1013 } |
1014 MultiplyAlpha(alpha); | 1014 MultiplyAlpha(alpha); |
1015 } | 1015 } |
1016 break; | 1016 break; |
1017 } | 1017 } |
1018 return true; | 1018 return TRUE; |
1019 } | 1019 } |
1020 FX_DWORD CFX_DIBitmap::GetPixel(int x, int y) const | 1020 FX_DWORD CFX_DIBitmap::GetPixel(int x, int y) const |
1021 { | 1021 { |
1022 if (m_pBuffer == NULL) { | 1022 if (m_pBuffer == NULL) { |
1023 return 0; | 1023 return 0; |
1024 } | 1024 } |
1025 uint8_t* pos = m_pBuffer + y * m_Pitch + x * GetBPP() / 8; | 1025 uint8_t* pos = m_pBuffer + y * m_Pitch + x * GetBPP() / 8; |
1026 switch (GetFormat()) { | 1026 switch (GetFormat()) { |
1027 case FXDIB_1bppMask: { | 1027 case FXDIB_1bppMask: { |
1028 if ((*pos) & (1 << (7 - x % 8))) { | 1028 if ((*pos) & (1 << (7 - x % 8))) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 break; | 1115 break; |
1116 } | 1116 } |
1117 case FXDIB_Argb: | 1117 case FXDIB_Argb: |
1118 FXARGB_SETDIB(pos, color); | 1118 FXARGB_SETDIB(pos, color); |
1119 break; | 1119 break; |
1120 default: | 1120 default: |
1121 break; | 1121 break; |
1122 } | 1122 } |
1123 } | 1123 } |
1124 void CFX_DIBitmap::DownSampleScanline(int line, uint8_t* dest_scan, int dest_bpp
, | 1124 void CFX_DIBitmap::DownSampleScanline(int line, uint8_t* dest_scan, int dest_bpp
, |
1125 int dest_width, bool bFlipX, int clip_left
, int clip_width) const | 1125 int dest_width, FX_BOOL bFlipX, int clip_l
eft, int clip_width) const |
1126 { | 1126 { |
1127 if (m_pBuffer == NULL) { | 1127 if (m_pBuffer == NULL) { |
1128 return; | 1128 return; |
1129 } | 1129 } |
1130 int src_Bpp = m_bpp / 8; | 1130 int src_Bpp = m_bpp / 8; |
1131 uint8_t* scanline = m_pBuffer + line * m_Pitch; | 1131 uint8_t* scanline = m_pBuffer + line * m_Pitch; |
1132 if (src_Bpp == 0) { | 1132 if (src_Bpp == 0) { |
1133 for (int i = 0; i < clip_width; i ++) { | 1133 for (int i = 0; i < clip_width; i ++) { |
1134 FX_DWORD dest_x = clip_left + i; | 1134 FX_DWORD dest_x = clip_left + i; |
1135 FX_DWORD src_x = dest_x * m_Width / dest_width; | 1135 FX_DWORD src_x = dest_x * m_Width / dest_width; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 FX_DWORD dest_x = clip_left + i; | 1172 FX_DWORD dest_x = clip_left + i; |
1173 FX_DWORD src_x = bFlipX ? (m_Width - dest_x * m_Width / dest_width -
1) * src_Bpp : (dest_x * m_Width / dest_width) * src_Bpp; | 1173 FX_DWORD src_x = bFlipX ? (m_Width - dest_x * m_Width / dest_width -
1) * src_Bpp : (dest_x * m_Width / dest_width) * src_Bpp; |
1174 src_x %= m_Width * src_Bpp; | 1174 src_x %= m_Width * src_Bpp; |
1175 int dest_pos = i * src_Bpp; | 1175 int dest_pos = i * src_Bpp; |
1176 for (int b = 0; b < src_Bpp; b ++) { | 1176 for (int b = 0; b < src_Bpp; b ++) { |
1177 dest_scan[dest_pos + b] = scanline[src_x + b]; | 1177 dest_scan[dest_pos + b] = scanline[src_x + b]; |
1178 } | 1178 } |
1179 } | 1179 } |
1180 } | 1180 } |
1181 } | 1181 } |
1182 bool CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor, FX_DWORD backcolor) | 1182 FX_BOOL CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor, FX_DWORD backcolor) |
1183 { | 1183 { |
1184 ASSERT(!IsAlphaMask()); | 1184 ASSERT(!IsAlphaMask()); |
1185 if (m_pBuffer == NULL || IsAlphaMask()) { | 1185 if (m_pBuffer == NULL || IsAlphaMask()) { |
1186 return false; | 1186 return FALSE; |
1187 } | 1187 } |
1188 int fc, fm, fy, fk, bc, bm, by, bk; | 1188 int fc, fm, fy, fk, bc, bm, by, bk; |
1189 int fr, fg, fb, br, bg, bb; | 1189 int fr, fg, fb, br, bg, bb; |
1190 bool isCmykImage = IsCmykImage(); | 1190 FX_BOOL isCmykImage = IsCmykImage(); |
1191 if (isCmykImage) { | 1191 if (isCmykImage) { |
1192 fc = FXSYS_GetCValue(forecolor); | 1192 fc = FXSYS_GetCValue(forecolor); |
1193 fm = FXSYS_GetMValue(forecolor); | 1193 fm = FXSYS_GetMValue(forecolor); |
1194 fy = FXSYS_GetYValue(forecolor); | 1194 fy = FXSYS_GetYValue(forecolor); |
1195 fk = FXSYS_GetKValue(forecolor); | 1195 fk = FXSYS_GetKValue(forecolor); |
1196 bc = FXSYS_GetCValue(backcolor); | 1196 bc = FXSYS_GetCValue(backcolor); |
1197 bm = FXSYS_GetMValue(backcolor); | 1197 bm = FXSYS_GetMValue(backcolor); |
1198 by = FXSYS_GetYValue(backcolor); | 1198 by = FXSYS_GetYValue(backcolor); |
1199 bk = FXSYS_GetKValue(backcolor); | 1199 bk = FXSYS_GetKValue(backcolor); |
1200 } else { | 1200 } else { |
1201 fr = FXSYS_GetRValue(forecolor); | 1201 fr = FXSYS_GetRValue(forecolor); |
1202 fg = FXSYS_GetGValue(forecolor); | 1202 fg = FXSYS_GetGValue(forecolor); |
1203 fb = FXSYS_GetBValue(forecolor); | 1203 fb = FXSYS_GetBValue(forecolor); |
1204 br = FXSYS_GetRValue(backcolor); | 1204 br = FXSYS_GetRValue(backcolor); |
1205 bg = FXSYS_GetGValue(backcolor); | 1205 bg = FXSYS_GetGValue(backcolor); |
1206 bb = FXSYS_GetBValue(backcolor); | 1206 bb = FXSYS_GetBValue(backcolor); |
1207 } | 1207 } |
1208 if (m_bpp <= 8) { | 1208 if (m_bpp <= 8) { |
1209 if (isCmykImage) { | 1209 if (isCmykImage) { |
1210 if (forecolor == 0xff && backcolor == 0 && m_pPalette == NULL) { | 1210 if (forecolor == 0xff && backcolor == 0 && m_pPalette == NULL) { |
1211 return true; | 1211 return TRUE; |
1212 } | 1212 } |
1213 } else if (forecolor == 0 && backcolor == 0xffffff && m_pPalette == NULL
) { | 1213 } else if (forecolor == 0 && backcolor == 0xffffff && m_pPalette == NULL
) { |
1214 return true; | 1214 return TRUE; |
1215 } | 1215 } |
1216 if (m_pPalette == NULL) { | 1216 if (m_pPalette == NULL) { |
1217 BuildPalette(); | 1217 BuildPalette(); |
1218 } | 1218 } |
1219 int size = 1 << m_bpp; | 1219 int size = 1 << m_bpp; |
1220 if (isCmykImage) { | 1220 if (isCmykImage) { |
1221 for (int i = 0; i < size; i ++) { | 1221 for (int i = 0; i < size; i ++) { |
1222 uint8_t b, g, r; | 1222 uint8_t b, g, r; |
1223 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(m_pPalette[i]), FXSYS_GetMVal
ue(m_pPalette[i]), FXSYS_GetYValue(m_pPalette[i]), FXSYS_GetKValue(m_pPalette[i]
), | 1223 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(m_pPalette[i]), FXSYS_GetMVal
ue(m_pPalette[i]), FXSYS_GetYValue(m_pPalette[i]), FXSYS_GetKValue(m_pPalette[i]
), |
1224 r, g, b); | 1224 r, g, b); |
1225 int gray = 255 - FXRGB2GRAY(r, g, b); | 1225 int gray = 255 - FXRGB2GRAY(r, g, b); |
1226 m_pPalette[i] = CmykEncode(bc + (fc - bc) * gray / 255, bm + (fm
- bm) * gray / 255, | 1226 m_pPalette[i] = CmykEncode(bc + (fc - bc) * gray / 255, bm + (fm
- bm) * gray / 255, |
1227 by + (fy - by) * gray / 255, bk + (fk
- bk) * gray / 255); | 1227 by + (fy - by) * gray / 255, bk + (fk
- bk) * gray / 255); |
1228 } | 1228 } |
1229 } else | 1229 } else |
1230 for (int i = 0; i < size; i ++) { | 1230 for (int i = 0; i < size; i ++) { |
1231 int gray = FXRGB2GRAY(FXARGB_R(m_pPalette[i]), FXARGB_G(m_pPalet
te[i]), FXARGB_B(m_pPalette[i])); | 1231 int gray = FXRGB2GRAY(FXARGB_R(m_pPalette[i]), FXARGB_G(m_pPalet
te[i]), FXARGB_B(m_pPalette[i])); |
1232 m_pPalette[i] = FXARGB_MAKE(0xff, br + (fr - br) * gray / 255, b
g + (fg - bg) * gray / 255, | 1232 m_pPalette[i] = FXARGB_MAKE(0xff, br + (fr - br) * gray / 255, b
g + (fg - bg) * gray / 255, |
1233 bb + (fb - bb) * gray / 255); | 1233 bb + (fb - bb) * gray / 255); |
1234 } | 1234 } |
1235 return true; | 1235 return TRUE; |
1236 } | 1236 } |
1237 if (isCmykImage) { | 1237 if (isCmykImage) { |
1238 if (forecolor == 0xff && backcolor == 0x00) { | 1238 if (forecolor == 0xff && backcolor == 0x00) { |
1239 for (int row = 0; row < m_Height; row ++) { | 1239 for (int row = 0; row < m_Height; row ++) { |
1240 uint8_t* scanline = m_pBuffer + row * m_Pitch; | 1240 uint8_t* scanline = m_pBuffer + row * m_Pitch; |
1241 for (int col = 0; col < m_Width; col ++) { | 1241 for (int col = 0; col < m_Width; col ++) { |
1242 uint8_t b, g, r; | 1242 uint8_t b, g, r; |
1243 AdobeCMYK_to_sRGB1(scanline[0], scanline[1], scanline[2], sc
anline[3], | 1243 AdobeCMYK_to_sRGB1(scanline[0], scanline[1], scanline[2], sc
anline[3], |
1244 r, g, b); | 1244 r, g, b); |
1245 *scanline ++ = 0; | 1245 *scanline ++ = 0; |
1246 *scanline ++ = 0; | 1246 *scanline ++ = 0; |
1247 *scanline ++ = 0; | 1247 *scanline ++ = 0; |
1248 *scanline ++ = 255 - FXRGB2GRAY(r, g, b); | 1248 *scanline ++ = 255 - FXRGB2GRAY(r, g, b); |
1249 } | 1249 } |
1250 } | 1250 } |
1251 return true; | 1251 return TRUE; |
1252 } | 1252 } |
1253 } else if (forecolor == 0 && backcolor == 0xffffff) { | 1253 } else if (forecolor == 0 && backcolor == 0xffffff) { |
1254 for (int row = 0; row < m_Height; row ++) { | 1254 for (int row = 0; row < m_Height; row ++) { |
1255 uint8_t* scanline = m_pBuffer + row * m_Pitch; | 1255 uint8_t* scanline = m_pBuffer + row * m_Pitch; |
1256 int gap = m_bpp / 8 - 2; | 1256 int gap = m_bpp / 8 - 2; |
1257 for (int col = 0; col < m_Width; col ++) { | 1257 for (int col = 0; col < m_Width; col ++) { |
1258 int gray = FXRGB2GRAY(scanline[2], scanline[1], scanline[0]); | 1258 int gray = FXRGB2GRAY(scanline[2], scanline[1], scanline[0]); |
1259 *scanline ++ = gray; | 1259 *scanline ++ = gray; |
1260 *scanline ++ = gray; | 1260 *scanline ++ = gray; |
1261 *scanline = gray; | 1261 *scanline = gray; |
1262 scanline += gap; | 1262 scanline += gap; |
1263 } | 1263 } |
1264 } | 1264 } |
1265 return true; | 1265 return TRUE; |
1266 } | 1266 } |
1267 if (isCmykImage) { | 1267 if (isCmykImage) { |
1268 for (int row = 0; row < m_Height; row ++) { | 1268 for (int row = 0; row < m_Height; row ++) { |
1269 uint8_t* scanline = m_pBuffer + row * m_Pitch; | 1269 uint8_t* scanline = m_pBuffer + row * m_Pitch; |
1270 for (int col = 0; col < m_Width; col ++) { | 1270 for (int col = 0; col < m_Width; col ++) { |
1271 uint8_t b, g, r; | 1271 uint8_t b, g, r; |
1272 AdobeCMYK_to_sRGB1(scanline[0], scanline[1], scanline[2], scanli
ne[3], | 1272 AdobeCMYK_to_sRGB1(scanline[0], scanline[1], scanline[2], scanli
ne[3], |
1273 r, g, b); | 1273 r, g, b); |
1274 int gray = 255 - FXRGB2GRAY(r, g, b); | 1274 int gray = 255 - FXRGB2GRAY(r, g, b); |
1275 *scanline ++ = bc + (fc - bc) * gray / 255; | 1275 *scanline ++ = bc + (fc - bc) * gray / 255; |
1276 *scanline ++ = bm + (fm - bm) * gray / 255; | 1276 *scanline ++ = bm + (fm - bm) * gray / 255; |
1277 *scanline ++ = by + (fy - by) * gray / 255; | 1277 *scanline ++ = by + (fy - by) * gray / 255; |
1278 *scanline ++ = bk + (fk - bk) * gray / 255; | 1278 *scanline ++ = bk + (fk - bk) * gray / 255; |
1279 } | 1279 } |
1280 } | 1280 } |
1281 } else { | 1281 } else { |
1282 for (int row = 0; row < m_Height; row ++) { | 1282 for (int row = 0; row < m_Height; row ++) { |
1283 uint8_t* scanline = m_pBuffer + row * m_Pitch; | 1283 uint8_t* scanline = m_pBuffer + row * m_Pitch; |
1284 int gap = m_bpp / 8 - 2; | 1284 int gap = m_bpp / 8 - 2; |
1285 for (int col = 0; col < m_Width; col ++) { | 1285 for (int col = 0; col < m_Width; col ++) { |
1286 int gray = FXRGB2GRAY(scanline[2], scanline[1], scanline[0]); | 1286 int gray = FXRGB2GRAY(scanline[2], scanline[1], scanline[0]); |
1287 *scanline ++ = bb + (fb - bb) * gray / 255; | 1287 *scanline ++ = bb + (fb - bb) * gray / 255; |
1288 *scanline ++ = bg + (fg - bg) * gray / 255; | 1288 *scanline ++ = bg + (fg - bg) * gray / 255; |
1289 *scanline = br + (fr - br) * gray / 255; | 1289 *scanline = br + (fr - br) * gray / 255; |
1290 scanline += gap; | 1290 scanline += gap; |
1291 } | 1291 } |
1292 } | 1292 } |
1293 } | 1293 } |
1294 return true; | 1294 return TRUE; |
1295 } | 1295 } |
1296 bool CFX_DIBitmap::DitherFS(const FX_DWORD* pPalette, int pal_size, const FX_REC
T* pRect) | 1296 FX_BOOL CFX_DIBitmap::DitherFS(const FX_DWORD* pPalette, int pal_size, const FX_
RECT* pRect) |
1297 { | 1297 { |
1298 if (m_pBuffer == NULL) { | 1298 if (m_pBuffer == NULL) { |
1299 return false; | 1299 return FALSE; |
1300 } | 1300 } |
1301 if (m_bpp != 8 && m_pPalette != NULL && m_AlphaFlag != 0) { | 1301 if (m_bpp != 8 && m_pPalette != NULL && m_AlphaFlag != 0) { |
1302 return false; | 1302 return FALSE; |
1303 } | 1303 } |
1304 if (m_Width < 4 && m_Height < 4) { | 1304 if (m_Width < 4 && m_Height < 4) { |
1305 return false; | 1305 return FALSE; |
1306 } | 1306 } |
1307 FX_RECT rect(0, 0, m_Width, m_Height); | 1307 FX_RECT rect(0, 0, m_Width, m_Height); |
1308 if (pRect) { | 1308 if (pRect) { |
1309 rect.Intersect(*pRect); | 1309 rect.Intersect(*pRect); |
1310 } | 1310 } |
1311 uint8_t translate[256]; | 1311 uint8_t translate[256]; |
1312 for (int i = 0; i < 256; i ++) { | 1312 for (int i = 0; i < 256; i ++) { |
1313 int err2 = 65536; | 1313 int err2 = 65536; |
1314 for (int j = 0; j < pal_size; j ++) { | 1314 for (int j = 0; j < pal_size; j ++) { |
1315 uint8_t entry = (uint8_t)pPalette[j]; | 1315 uint8_t entry = (uint8_t)pPalette[j]; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 if (src > 255) { | 1367 if (src > 255) { |
1368 next_scan[col - 1] = 255; | 1368 next_scan[col - 1] = 255; |
1369 } else if (src < 0) { | 1369 } else if (src < 0) { |
1370 next_scan[col - 1] = 0; | 1370 next_scan[col - 1] = 0; |
1371 } else { | 1371 } else { |
1372 next_scan[col - 1] = src; | 1372 next_scan[col - 1] = src; |
1373 } | 1373 } |
1374 } | 1374 } |
1375 } | 1375 } |
1376 } | 1376 } |
1377 return true; | 1377 return TRUE; |
1378 } | 1378 } |
1379 CFX_DIBitmap* CFX_DIBSource::FlipImage(bool bXFlip, bool bYFlip) const | 1379 CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const |
1380 { | 1380 { |
1381 CFX_DIBitmap* pFlipped = new CFX_DIBitmap; | 1381 CFX_DIBitmap* pFlipped = new CFX_DIBitmap; |
1382 if (!pFlipped->Create(m_Width, m_Height, GetFormat())) { | 1382 if (!pFlipped->Create(m_Width, m_Height, GetFormat())) { |
1383 delete pFlipped; | 1383 delete pFlipped; |
1384 return NULL; | 1384 return NULL; |
1385 } | 1385 } |
1386 pFlipped->CopyPalette(m_pPalette); | 1386 pFlipped->CopyPalette(m_pPalette); |
1387 uint8_t* pDestBuffer = pFlipped->GetBuffer(); | 1387 uint8_t* pDestBuffer = pFlipped->GetBuffer(); |
1388 int Bpp = m_bpp / 8; | 1388 int Bpp = m_bpp / 8; |
1389 for (int row = 0; row < m_Height; row ++) { | 1389 for (int row = 0; row < m_Height; row ++) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 } | 1473 } |
1474 CFX_FilteredDIB::~CFX_FilteredDIB() | 1474 CFX_FilteredDIB::~CFX_FilteredDIB() |
1475 { | 1475 { |
1476 if (m_bAutoDropSrc) { | 1476 if (m_bAutoDropSrc) { |
1477 delete m_pSrc; | 1477 delete m_pSrc; |
1478 } | 1478 } |
1479 if (m_pScanline) { | 1479 if (m_pScanline) { |
1480 FX_Free(m_pScanline); | 1480 FX_Free(m_pScanline); |
1481 } | 1481 } |
1482 } | 1482 } |
1483 void CFX_FilteredDIB::LoadSrc(const CFX_DIBSource* pSrc, bool bAutoDropSrc) | 1483 void CFX_FilteredDIB::LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc) |
1484 { | 1484 { |
1485 m_pSrc = pSrc; | 1485 m_pSrc = pSrc; |
1486 m_bAutoDropSrc = bAutoDropSrc; | 1486 m_bAutoDropSrc = bAutoDropSrc; |
1487 m_Width = pSrc->GetWidth(); | 1487 m_Width = pSrc->GetWidth(); |
1488 m_Height = pSrc->GetHeight(); | 1488 m_Height = pSrc->GetHeight(); |
1489 FXDIB_Format format = GetDestFormat(); | 1489 FXDIB_Format format = GetDestFormat(); |
1490 m_bpp = (uint8_t)format; | 1490 m_bpp = (uint8_t)format; |
1491 m_AlphaFlag = (uint8_t)(format >> 8); | 1491 m_AlphaFlag = (uint8_t)(format >> 8); |
1492 m_Pitch = (m_Width * (format & 0xff) + 31) / 32 * 4; | 1492 m_Pitch = (m_Width * (format & 0xff) + 31) / 32 * 4; |
1493 m_pPalette = GetDestPalette(); | 1493 m_pPalette = GetDestPalette(); |
1494 m_pScanline = FX_Alloc(uint8_t, m_Pitch); | 1494 m_pScanline = FX_Alloc(uint8_t, m_Pitch); |
1495 } | 1495 } |
1496 const uint8_t* CFX_FilteredDIB::GetScanline(int line) const | 1496 const uint8_t* CFX_FilteredDIB::GetScanline(int line) const |
1497 { | 1497 { |
1498 TranslateScanline(m_pScanline, m_pSrc->GetScanline(line)); | 1498 TranslateScanline(m_pScanline, m_pSrc->GetScanline(line)); |
1499 return m_pScanline; | 1499 return m_pScanline; |
1500 } | 1500 } |
1501 void CFX_FilteredDIB::DownSampleScanline(int line, uint8_t* dest_scan, int dest_
bpp, | 1501 void CFX_FilteredDIB::DownSampleScanline(int line, uint8_t* dest_scan, int dest_
bpp, |
1502 int dest_width, bool bFlipX, int clip_left, int clip_width) const | 1502 int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const |
1503 { | 1503 { |
1504 m_pSrc->DownSampleScanline(line, dest_scan, dest_bpp, dest_width, bFlipX, cl
ip_left, clip_width); | 1504 m_pSrc->DownSampleScanline(line, dest_scan, dest_bpp, dest_width, bFlipX, cl
ip_left, clip_width); |
1505 TranslateDownSamples(dest_scan, dest_scan, clip_width, dest_bpp); | 1505 TranslateDownSamples(dest_scan, dest_scan, clip_width, dest_bpp); |
1506 } | 1506 } |
1507 CFX_ImageRenderer::CFX_ImageRenderer() | 1507 CFX_ImageRenderer::CFX_ImageRenderer() |
1508 { | 1508 { |
1509 m_Status = 0; | 1509 m_Status = 0; |
1510 m_pTransformer = NULL; | 1510 m_pTransformer = NULL; |
1511 m_bRgbByteOrder = false; | 1511 m_bRgbByteOrder = FALSE; |
1512 m_BlendType = FXDIB_BLEND_NORMAL; | 1512 m_BlendType = FXDIB_BLEND_NORMAL; |
1513 } | 1513 } |
1514 CFX_ImageRenderer::~CFX_ImageRenderer() | 1514 CFX_ImageRenderer::~CFX_ImageRenderer() |
1515 { | 1515 { |
1516 delete m_pTransformer; | 1516 delete m_pTransformer; |
1517 } | 1517 } |
1518 extern FX_RECT _FXDIB_SwapClipBox(FX_RECT& clip, int width, int height, bool bFl
ipX, bool bFlipY); | 1518 extern FX_RECT _FXDIB_SwapClipBox(FX_RECT& clip, int width, int height, FX_BOOL
bFlipX, FX_BOOL bFlipY); |
1519 bool CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice, const CFX_ClipRgn* pClipRgn
, | 1519 FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice, const CFX_ClipRgn* pClip
Rgn, |
1520 const CFX_DIBSource* pSource, int bitmap_alpha, | 1520 const CFX_DIBSource* pSource, int bitmap_alpha, |
1521 FX_DWORD mask_color, const CFX_AffineMatrix* pM
atrix, | 1521 FX_DWORD mask_color, const CFX_AffineMatrix* pM
atrix, |
1522 FX_DWORD dib_flags, bool bRgbByteOrder, | 1522 FX_DWORD dib_flags, FX_BOOL bRgbByteOrder, |
1523 int alpha_flag, void* pIccTransform, int blend_
type) | 1523 int alpha_flag, void* pIccTransform, int blend_
type) |
1524 { | 1524 { |
1525 m_Matrix = *pMatrix; | 1525 m_Matrix = *pMatrix; |
1526 CFX_FloatRect image_rect_f = m_Matrix.GetUnitRect(); | 1526 CFX_FloatRect image_rect_f = m_Matrix.GetUnitRect(); |
1527 FX_RECT image_rect = image_rect_f.GetOutterRect(); | 1527 FX_RECT image_rect = image_rect_f.GetOutterRect(); |
1528 m_ClipBox = pClipRgn ? pClipRgn->GetBox() : FX_RECT(0, 0, pDevice->GetWidth(
), pDevice->GetHeight()); | 1528 m_ClipBox = pClipRgn ? pClipRgn->GetBox() : FX_RECT(0, 0, pDevice->GetWidth(
), pDevice->GetHeight()); |
1529 m_ClipBox.Intersect(image_rect); | 1529 m_ClipBox.Intersect(image_rect); |
1530 if (m_ClipBox.IsEmpty()) { | 1530 if (m_ClipBox.IsEmpty()) { |
1531 return false; | 1531 return FALSE; |
1532 } | 1532 } |
1533 m_pDevice = pDevice; | 1533 m_pDevice = pDevice; |
1534 m_pClipRgn = pClipRgn; | 1534 m_pClipRgn = pClipRgn; |
1535 m_MaskColor = mask_color; | 1535 m_MaskColor = mask_color; |
1536 m_BitmapAlpha = bitmap_alpha; | 1536 m_BitmapAlpha = bitmap_alpha; |
1537 m_Matrix = *pMatrix; | 1537 m_Matrix = *pMatrix; |
1538 m_Flags = dib_flags; | 1538 m_Flags = dib_flags; |
1539 m_AlphaFlag = alpha_flag; | 1539 m_AlphaFlag = alpha_flag; |
1540 m_pIccTransform = pIccTransform; | 1540 m_pIccTransform = pIccTransform; |
1541 m_bRgbByteOrder = bRgbByteOrder; | 1541 m_bRgbByteOrder = bRgbByteOrder; |
1542 m_BlendType = blend_type; | 1542 m_BlendType = blend_type; |
1543 bool ret = true; | 1543 FX_BOOL ret = TRUE; |
1544 if ((FXSYS_fabs(m_Matrix.b) >= 0.5f || m_Matrix.a == 0) || | 1544 if ((FXSYS_fabs(m_Matrix.b) >= 0.5f || m_Matrix.a == 0) || |
1545 (FXSYS_fabs(m_Matrix.c) >= 0.5f || m_Matrix.d == 0) ) { | 1545 (FXSYS_fabs(m_Matrix.c) >= 0.5f || m_Matrix.d == 0) ) { |
1546 if (FXSYS_fabs(m_Matrix.a) < FXSYS_fabs(m_Matrix.b) / 20 && FXSYS_fabs(m
_Matrix.d) < FXSYS_fabs(m_Matrix.c) / 20 && | 1546 if (FXSYS_fabs(m_Matrix.a) < FXSYS_fabs(m_Matrix.b) / 20 && FXSYS_fabs(m
_Matrix.d) < FXSYS_fabs(m_Matrix.c) / 20 && |
1547 FXSYS_fabs(m_Matrix.a) < 0.5f && FXSYS_fabs(m_Matrix.d) < 0.5f)
{ | 1547 FXSYS_fabs(m_Matrix.a) < 0.5f && FXSYS_fabs(m_Matrix.d) < 0.5f)
{ |
1548 int dest_width = image_rect.Width(); | 1548 int dest_width = image_rect.Width(); |
1549 int dest_height = image_rect.Height(); | 1549 int dest_height = image_rect.Height(); |
1550 FX_RECT bitmap_clip = m_ClipBox; | 1550 FX_RECT bitmap_clip = m_ClipBox; |
1551 bitmap_clip.Offset(-image_rect.left, -image_rect.top); | 1551 bitmap_clip.Offset(-image_rect.left, -image_rect.top); |
1552 bitmap_clip = _FXDIB_SwapClipBox(bitmap_clip, dest_width, dest_heigh
t, m_Matrix.c > 0, m_Matrix.b < 0); | 1552 bitmap_clip = _FXDIB_SwapClipBox(bitmap_clip, dest_width, dest_heigh
t, m_Matrix.c > 0, m_Matrix.b < 0); |
1553 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_Cl
ipBox, true, | 1553 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_Cl
ipBox, TRUE, |
1554 m_Matrix.c > 0, m_Matrix.b < 0, m_bRgbByteOrder,
alpha_flag, pIccTransform, m_BlendType); | 1554 m_Matrix.c > 0, m_Matrix.b < 0, m_bRgbByteOrder,
alpha_flag, pIccTransform, m_BlendType); |
1555 if (!m_Stretcher.Start(&m_Composer, pSource, dest_height, dest_width
, bitmap_clip, dib_flags)) { | 1555 if (!m_Stretcher.Start(&m_Composer, pSource, dest_height, dest_width
, bitmap_clip, dib_flags)) { |
1556 return false; | 1556 return FALSE; |
1557 } | 1557 } |
1558 m_Status = 1; | 1558 m_Status = 1; |
1559 return true; | 1559 return TRUE; |
1560 } | 1560 } |
1561 m_Status = 2; | 1561 m_Status = 2; |
1562 m_pTransformer = new CFX_ImageTransformer; | 1562 m_pTransformer = new CFX_ImageTransformer; |
1563 m_pTransformer->Start(pSource, &m_Matrix, dib_flags, &m_ClipBox); | 1563 m_pTransformer->Start(pSource, &m_Matrix, dib_flags, &m_ClipBox); |
1564 return true; | 1564 return TRUE; |
1565 } | 1565 } |
1566 int dest_width = image_rect.Width(); | 1566 int dest_width = image_rect.Width(); |
1567 if (m_Matrix.a < 0) { | 1567 if (m_Matrix.a < 0) { |
1568 dest_width = -dest_width; | 1568 dest_width = -dest_width; |
1569 } | 1569 } |
1570 int dest_height = image_rect.Height(); | 1570 int dest_height = image_rect.Height(); |
1571 if (m_Matrix.d > 0) { | 1571 if (m_Matrix.d > 0) { |
1572 dest_height = -dest_height; | 1572 dest_height = -dest_height; |
1573 } | 1573 } |
1574 if (dest_width == 0 || dest_height == 0) { | 1574 if (dest_width == 0 || dest_height == 0) { |
1575 return false; | 1575 return FALSE; |
1576 } | 1576 } |
1577 FX_RECT bitmap_clip = m_ClipBox; | 1577 FX_RECT bitmap_clip = m_ClipBox; |
1578 bitmap_clip.Offset(-image_rect.left, -image_rect.top); | 1578 bitmap_clip.Offset(-image_rect.left, -image_rect.top); |
1579 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, | 1579 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, |
1580 m_ClipBox, false, false, false, m_bRgbByteOrder, alpha_fl
ag, pIccTransform, m_BlendType); | 1580 m_ClipBox, FALSE, FALSE, FALSE, m_bRgbByteOrder, alpha_fl
ag, pIccTransform, m_BlendType); |
1581 m_Status = 1; | 1581 m_Status = 1; |
1582 ret = m_Stretcher.Start(&m_Composer, pSource, dest_width, dest_height, bitma
p_clip, dib_flags); | 1582 ret = m_Stretcher.Start(&m_Composer, pSource, dest_width, dest_height, bitma
p_clip, dib_flags); |
1583 return ret; | 1583 return ret; |
1584 } | 1584 } |
1585 bool CFX_ImageRenderer::Continue(IFX_Pause* pPause) | 1585 FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) |
1586 { | 1586 { |
1587 if (m_Status == 1) { | 1587 if (m_Status == 1) { |
1588 return m_Stretcher.Continue(pPause); | 1588 return m_Stretcher.Continue(pPause); |
1589 } | 1589 } |
1590 if (m_Status == 2) { | 1590 if (m_Status == 2) { |
1591 if (m_pTransformer->Continue(pPause)) { | 1591 if (m_pTransformer->Continue(pPause)) { |
1592 return true; | 1592 return TRUE; |
1593 } | 1593 } |
1594 CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach(); | 1594 CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach(); |
1595 if (pBitmap == NULL) { | 1595 if (pBitmap == NULL) { |
1596 return false; | 1596 return FALSE; |
1597 } | 1597 } |
1598 if (pBitmap->GetBuffer() == NULL) { | 1598 if (pBitmap->GetBuffer() == NULL) { |
1599 delete pBitmap; | 1599 delete pBitmap; |
1600 return false; | 1600 return FALSE; |
1601 } | 1601 } |
1602 if (pBitmap->IsAlphaMask()) { | 1602 if (pBitmap->IsAlphaMask()) { |
1603 if (m_BitmapAlpha != 255) { | 1603 if (m_BitmapAlpha != 255) { |
1604 if (m_AlphaFlag >> 8) { | 1604 if (m_AlphaFlag >> 8) { |
1605 m_AlphaFlag = (((uint8_t)((m_AlphaFlag & 0xff) * m_BitmapAlp
ha / 255)) | ((m_AlphaFlag >> 8) << 8)); | 1605 m_AlphaFlag = (((uint8_t)((m_AlphaFlag & 0xff) * m_BitmapAlp
ha / 255)) | ((m_AlphaFlag >> 8) << 8)); |
1606 } else { | 1606 } else { |
1607 m_MaskColor = FXARGB_MUL_ALPHA(m_MaskColor, m_BitmapAlpha); | 1607 m_MaskColor = FXARGB_MUL_ALPHA(m_MaskColor, m_BitmapAlpha); |
1608 } | 1608 } |
1609 } | 1609 } |
1610 m_pDevice->CompositeMask(m_pTransformer->m_ResultLeft, m_pTransforme
r->m_ResultTop, | 1610 m_pDevice->CompositeMask(m_pTransformer->m_ResultLeft, m_pTransforme
r->m_ResultTop, |
1611 pBitmap->GetWidth(), pBitmap->GetHeight(),
pBitmap, m_MaskColor, | 1611 pBitmap->GetWidth(), pBitmap->GetHeight(),
pBitmap, m_MaskColor, |
1612 0, 0, m_BlendType, m_pClipRgn, m_bRgbByteOr
der, m_AlphaFlag, m_pIccTransform); | 1612 0, 0, m_BlendType, m_pClipRgn, m_bRgbByteOr
der, m_AlphaFlag, m_pIccTransform); |
1613 } else { | 1613 } else { |
1614 if (m_BitmapAlpha != 255) { | 1614 if (m_BitmapAlpha != 255) { |
1615 pBitmap->MultiplyAlpha(m_BitmapAlpha); | 1615 pBitmap->MultiplyAlpha(m_BitmapAlpha); |
1616 } | 1616 } |
1617 m_pDevice->CompositeBitmap(m_pTransformer->m_ResultLeft, m_pTransfor
mer->m_ResultTop, | 1617 m_pDevice->CompositeBitmap(m_pTransformer->m_ResultLeft, m_pTransfor
mer->m_ResultTop, |
1618 pBitmap->GetWidth(), pBitmap->GetHeight()
, pBitmap, 0, 0, m_BlendType, m_pClipRgn, m_bRgbByteOrder, m_pIccTransform); | 1618 pBitmap->GetWidth(), pBitmap->GetHeight()
, pBitmap, 0, 0, m_BlendType, m_pClipRgn, m_bRgbByteOrder, m_pIccTransform); |
1619 } | 1619 } |
1620 delete pBitmap; | 1620 delete pBitmap; |
1621 return false; | 1621 return FALSE; |
1622 } | 1622 } |
1623 return false; | 1623 return FALSE; |
1624 } | 1624 } |
1625 CFX_BitmapStorer::CFX_BitmapStorer() | 1625 CFX_BitmapStorer::CFX_BitmapStorer() |
1626 { | 1626 { |
1627 m_pBitmap = NULL; | 1627 m_pBitmap = NULL; |
1628 } | 1628 } |
1629 CFX_BitmapStorer::~CFX_BitmapStorer() | 1629 CFX_BitmapStorer::~CFX_BitmapStorer() |
1630 { | 1630 { |
1631 delete m_pBitmap; | 1631 delete m_pBitmap; |
1632 } | 1632 } |
1633 CFX_DIBitmap* CFX_BitmapStorer::Detach() | 1633 CFX_DIBitmap* CFX_BitmapStorer::Detach() |
(...skipping 12 matching lines...) Expand all Loading... |
1646 uint8_t* dest_buf = (uint8_t*)m_pBitmap->GetScanline(line); | 1646 uint8_t* dest_buf = (uint8_t*)m_pBitmap->GetScanline(line); |
1647 uint8_t* dest_alpha_buf = m_pBitmap->m_pAlphaMask ? | 1647 uint8_t* dest_alpha_buf = m_pBitmap->m_pAlphaMask ? |
1648 (uint8_t*)m_pBitmap->m_pAlphaMask->GetScanline(li
ne) : NULL; | 1648 (uint8_t*)m_pBitmap->m_pAlphaMask->GetScanline(li
ne) : NULL; |
1649 if (dest_buf) { | 1649 if (dest_buf) { |
1650 FXSYS_memcpy(dest_buf, scanline, m_pBitmap->GetPitch()); | 1650 FXSYS_memcpy(dest_buf, scanline, m_pBitmap->GetPitch()); |
1651 } | 1651 } |
1652 if (dest_alpha_buf) { | 1652 if (dest_alpha_buf) { |
1653 FXSYS_memcpy(dest_alpha_buf, scan_extra_alpha, m_pBitmap->m_pAlphaMask->
GetPitch()); | 1653 FXSYS_memcpy(dest_alpha_buf, scan_extra_alpha, m_pBitmap->m_pAlphaMask->
GetPitch()); |
1654 } | 1654 } |
1655 } | 1655 } |
1656 bool CFX_BitmapStorer::SetInfo(int width, int height, FXDIB_Format src_format, F
X_DWORD* pSrcPalette) | 1656 FX_BOOL CFX_BitmapStorer::SetInfo(int width, int height, FXDIB_Format src_format
, FX_DWORD* pSrcPalette) |
1657 { | 1657 { |
1658 m_pBitmap = new CFX_DIBitmap; | 1658 m_pBitmap = new CFX_DIBitmap; |
1659 if (!m_pBitmap->Create(width, height, src_format)) { | 1659 if (!m_pBitmap->Create(width, height, src_format)) { |
1660 delete m_pBitmap; | 1660 delete m_pBitmap; |
1661 m_pBitmap = NULL; | 1661 m_pBitmap = NULL; |
1662 return false; | 1662 return FALSE; |
1663 } | 1663 } |
1664 if (pSrcPalette) { | 1664 if (pSrcPalette) { |
1665 m_pBitmap->CopyPalette(pSrcPalette); | 1665 m_pBitmap->CopyPalette(pSrcPalette); |
1666 } | 1666 } |
1667 return true; | 1667 return TRUE; |
1668 } | 1668 } |
OLD | NEW |