Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: core/src/fxge/dib/fx_dib_main.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxge/dib/fx_dib_engine.cpp ('k') | core/src/fxge/dib/fx_dib_transform.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 FX_BOOL ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitc h, int width, int height, 12 bool ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitch, 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
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 FX_BOOL CFX_DIBitmap::Create(int width, int height, FXDIB_Format format, uint8_t * pBuffer, int pitch) 60 bool CFX_DIBitmap::Create(int width, int height, FXDIB_Format format, uint8_t* p Buffer, 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 FX_BOOL ret = TRUE; 97 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 FX_BOOL CFX_DIBitmap::Copy(const CFX_DIBSource* pSrc) 110 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
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 FX_BOOL CFX_DIBSource::BuildAlphaMask() 221 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
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 FX_BOOL CFX_DIBitmap::TransferBitmap(int dest_left, int dest_top, int width, int height, 370 bool CFX_DIBitmap::TransferBitmap(int dest_left, int dest_top, int width, int he ight,
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 FX_BOOL CFX_DIBitmap::TransferMask(int dest_left, int dest_top, int width, int h eight, 418 bool CFX_DIBitmap::TransferMask(int dest_left, int dest_top, int width, int heig ht,
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
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
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 FX_BOOL CFX_DIBSource::CopyAlphaMask(const CFX_DIBSource* pAlphaMask, const FX_R ECT* pClip) 573 bool CFX_DIBSource::CopyAlphaMask(const CFX_DIBSource* pAlphaMask, const FX_RECT * 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 FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, const CFX_DIBSource * pSrcBitmap, FXDIB_Channel srcChannel) 599 bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, const CFX_DIBSource* p SrcBitmap, 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 FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, int value) 737 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 FX_BOOL CFX_DIBitmap::MultiplyAlpha(const CFX_DIBSource* pSrcBitmap) 798 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 FX_BOOL CFX_DIBitmap::GetGrayData(void* pIccTransform) 866 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 FX_BOOL CFX_DIBitmap::MultiplyAlpha(int alpha) 971 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 break; 1117 break;
1118 } 1118 }
1119 case FXDIB_Argb: 1119 case FXDIB_Argb:
1120 FXARGB_SETDIB(pos, color); 1120 FXARGB_SETDIB(pos, color);
1121 break; 1121 break;
1122 default: 1122 default:
1123 break; 1123 break;
1124 } 1124 }
1125 } 1125 }
1126 void CFX_DIBitmap::DownSampleScanline(int line, uint8_t* dest_scan, int dest_bpp , 1126 void CFX_DIBitmap::DownSampleScanline(int line, uint8_t* dest_scan, int dest_bpp ,
1127 int dest_width, FX_BOOL bFlipX, int clip_l eft, int clip_width) const 1127 int dest_width, bool bFlipX, int clip_left , int clip_width) const
1128 { 1128 {
1129 if (m_pBuffer == NULL) { 1129 if (m_pBuffer == NULL) {
1130 return; 1130 return;
1131 } 1131 }
1132 int src_Bpp = m_bpp / 8; 1132 int src_Bpp = m_bpp / 8;
1133 uint8_t* scanline = m_pBuffer + line * m_Pitch; 1133 uint8_t* scanline = m_pBuffer + line * m_Pitch;
1134 if (src_Bpp == 0) { 1134 if (src_Bpp == 0) {
1135 for (int i = 0; i < clip_width; i ++) { 1135 for (int i = 0; i < clip_width; i ++) {
1136 FX_DWORD dest_x = clip_left + i; 1136 FX_DWORD dest_x = clip_left + i;
1137 FX_DWORD src_x = dest_x * m_Width / dest_width; 1137 FX_DWORD src_x = dest_x * m_Width / dest_width;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 FX_DWORD dest_x = clip_left + i; 1174 FX_DWORD dest_x = clip_left + i;
1175 FX_DWORD src_x = bFlipX ? (m_Width - dest_x * m_Width / dest_width - 1) * src_Bpp : (dest_x * m_Width / dest_width) * src_Bpp; 1175 FX_DWORD src_x = bFlipX ? (m_Width - dest_x * m_Width / dest_width - 1) * src_Bpp : (dest_x * m_Width / dest_width) * src_Bpp;
1176 src_x %= m_Width * src_Bpp; 1176 src_x %= m_Width * src_Bpp;
1177 int dest_pos = i * src_Bpp; 1177 int dest_pos = i * src_Bpp;
1178 for (int b = 0; b < src_Bpp; b ++) { 1178 for (int b = 0; b < src_Bpp; b ++) {
1179 dest_scan[dest_pos + b] = scanline[src_x + b]; 1179 dest_scan[dest_pos + b] = scanline[src_x + b];
1180 } 1180 }
1181 } 1181 }
1182 } 1182 }
1183 } 1183 }
1184 FX_BOOL CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor, FX_DWORD backcolor) 1184 bool CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor, FX_DWORD backcolor)
1185 { 1185 {
1186 ASSERT(!IsAlphaMask()); 1186 ASSERT(!IsAlphaMask());
1187 if (m_pBuffer == NULL || IsAlphaMask()) { 1187 if (m_pBuffer == NULL || IsAlphaMask()) {
1188 return FALSE; 1188 return false;
1189 } 1189 }
1190 int fc, fm, fy, fk, bc, bm, by, bk; 1190 int fc, fm, fy, fk, bc, bm, by, bk;
1191 int fr, fg, fb, br, bg, bb; 1191 int fr, fg, fb, br, bg, bb;
1192 FX_BOOL isCmykImage = IsCmykImage(); 1192 bool isCmykImage = IsCmykImage();
1193 if (isCmykImage) { 1193 if (isCmykImage) {
1194 fc = FXSYS_GetCValue(forecolor); 1194 fc = FXSYS_GetCValue(forecolor);
1195 fm = FXSYS_GetMValue(forecolor); 1195 fm = FXSYS_GetMValue(forecolor);
1196 fy = FXSYS_GetYValue(forecolor); 1196 fy = FXSYS_GetYValue(forecolor);
1197 fk = FXSYS_GetKValue(forecolor); 1197 fk = FXSYS_GetKValue(forecolor);
1198 bc = FXSYS_GetCValue(backcolor); 1198 bc = FXSYS_GetCValue(backcolor);
1199 bm = FXSYS_GetMValue(backcolor); 1199 bm = FXSYS_GetMValue(backcolor);
1200 by = FXSYS_GetYValue(backcolor); 1200 by = FXSYS_GetYValue(backcolor);
1201 bk = FXSYS_GetKValue(backcolor); 1201 bk = FXSYS_GetKValue(backcolor);
1202 } else { 1202 } else {
1203 fr = FXSYS_GetRValue(forecolor); 1203 fr = FXSYS_GetRValue(forecolor);
1204 fg = FXSYS_GetGValue(forecolor); 1204 fg = FXSYS_GetGValue(forecolor);
1205 fb = FXSYS_GetBValue(forecolor); 1205 fb = FXSYS_GetBValue(forecolor);
1206 br = FXSYS_GetRValue(backcolor); 1206 br = FXSYS_GetRValue(backcolor);
1207 bg = FXSYS_GetGValue(backcolor); 1207 bg = FXSYS_GetGValue(backcolor);
1208 bb = FXSYS_GetBValue(backcolor); 1208 bb = FXSYS_GetBValue(backcolor);
1209 } 1209 }
1210 if (m_bpp <= 8) { 1210 if (m_bpp <= 8) {
1211 if (isCmykImage) { 1211 if (isCmykImage) {
1212 if (forecolor == 0xff && backcolor == 0 && m_pPalette == NULL) { 1212 if (forecolor == 0xff && backcolor == 0 && m_pPalette == NULL) {
1213 return TRUE; 1213 return true;
1214 } 1214 }
1215 } else if (forecolor == 0 && backcolor == 0xffffff && m_pPalette == NULL ) { 1215 } else if (forecolor == 0 && backcolor == 0xffffff && m_pPalette == NULL ) {
1216 return TRUE; 1216 return true;
1217 } 1217 }
1218 if (m_pPalette == NULL) { 1218 if (m_pPalette == NULL) {
1219 BuildPalette(); 1219 BuildPalette();
1220 } 1220 }
1221 int size = 1 << m_bpp; 1221 int size = 1 << m_bpp;
1222 if (isCmykImage) { 1222 if (isCmykImage) {
1223 for (int i = 0; i < size; i ++) { 1223 for (int i = 0; i < size; i ++) {
1224 uint8_t b, g, r; 1224 uint8_t b, g, r;
1225 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(m_pPalette[i]), FXSYS_GetMVal ue(m_pPalette[i]), FXSYS_GetYValue(m_pPalette[i]), FXSYS_GetKValue(m_pPalette[i] ), 1225 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(m_pPalette[i]), FXSYS_GetMVal ue(m_pPalette[i]), FXSYS_GetYValue(m_pPalette[i]), FXSYS_GetKValue(m_pPalette[i] ),
1226 r, g, b); 1226 r, g, b);
1227 int gray = 255 - FXRGB2GRAY(r, g, b); 1227 int gray = 255 - FXRGB2GRAY(r, g, b);
1228 m_pPalette[i] = CmykEncode(bc + (fc - bc) * gray / 255, bm + (fm - bm) * gray / 255, 1228 m_pPalette[i] = CmykEncode(bc + (fc - bc) * gray / 255, bm + (fm - bm) * gray / 255,
1229 by + (fy - by) * gray / 255, bk + (fk - bk) * gray / 255); 1229 by + (fy - by) * gray / 255, bk + (fk - bk) * gray / 255);
1230 } 1230 }
1231 } else 1231 } else
1232 for (int i = 0; i < size; i ++) { 1232 for (int i = 0; i < size; i ++) {
1233 int gray = FXRGB2GRAY(FXARGB_R(m_pPalette[i]), FXARGB_G(m_pPalet te[i]), FXARGB_B(m_pPalette[i])); 1233 int gray = FXRGB2GRAY(FXARGB_R(m_pPalette[i]), FXARGB_G(m_pPalet te[i]), FXARGB_B(m_pPalette[i]));
1234 m_pPalette[i] = FXARGB_MAKE(0xff, br + (fr - br) * gray / 255, b g + (fg - bg) * gray / 255, 1234 m_pPalette[i] = FXARGB_MAKE(0xff, br + (fr - br) * gray / 255, b g + (fg - bg) * gray / 255,
1235 bb + (fb - bb) * gray / 255); 1235 bb + (fb - bb) * gray / 255);
1236 } 1236 }
1237 return TRUE; 1237 return true;
1238 } 1238 }
1239 if (isCmykImage) { 1239 if (isCmykImage) {
1240 if (forecolor == 0xff && backcolor == 0x00) { 1240 if (forecolor == 0xff && backcolor == 0x00) {
1241 for (int row = 0; row < m_Height; row ++) { 1241 for (int row = 0; row < m_Height; row ++) {
1242 uint8_t* scanline = m_pBuffer + row * m_Pitch; 1242 uint8_t* scanline = m_pBuffer + row * m_Pitch;
1243 for (int col = 0; col < m_Width; col ++) { 1243 for (int col = 0; col < m_Width; col ++) {
1244 uint8_t b, g, r; 1244 uint8_t b, g, r;
1245 AdobeCMYK_to_sRGB1(scanline[0], scanline[1], scanline[2], sc anline[3], 1245 AdobeCMYK_to_sRGB1(scanline[0], scanline[1], scanline[2], sc anline[3],
1246 r, g, b); 1246 r, g, b);
1247 *scanline ++ = 0; 1247 *scanline ++ = 0;
1248 *scanline ++ = 0; 1248 *scanline ++ = 0;
1249 *scanline ++ = 0; 1249 *scanline ++ = 0;
1250 *scanline ++ = 255 - FXRGB2GRAY(r, g, b); 1250 *scanline ++ = 255 - FXRGB2GRAY(r, g, b);
1251 } 1251 }
1252 } 1252 }
1253 return TRUE; 1253 return true;
1254 } 1254 }
1255 } else if (forecolor == 0 && backcolor == 0xffffff) { 1255 } else if (forecolor == 0 && backcolor == 0xffffff) {
1256 for (int row = 0; row < m_Height; row ++) { 1256 for (int row = 0; row < m_Height; row ++) {
1257 uint8_t* scanline = m_pBuffer + row * m_Pitch; 1257 uint8_t* scanline = m_pBuffer + row * m_Pitch;
1258 int gap = m_bpp / 8 - 2; 1258 int gap = m_bpp / 8 - 2;
1259 for (int col = 0; col < m_Width; col ++) { 1259 for (int col = 0; col < m_Width; col ++) {
1260 int gray = FXRGB2GRAY(scanline[2], scanline[1], scanline[0]); 1260 int gray = FXRGB2GRAY(scanline[2], scanline[1], scanline[0]);
1261 *scanline ++ = gray; 1261 *scanline ++ = gray;
1262 *scanline ++ = gray; 1262 *scanline ++ = gray;
1263 *scanline = gray; 1263 *scanline = gray;
1264 scanline += gap; 1264 scanline += gap;
1265 } 1265 }
1266 } 1266 }
1267 return TRUE; 1267 return true;
1268 } 1268 }
1269 if (isCmykImage) { 1269 if (isCmykImage) {
1270 for (int row = 0; row < m_Height; row ++) { 1270 for (int row = 0; row < m_Height; row ++) {
1271 uint8_t* scanline = m_pBuffer + row * m_Pitch; 1271 uint8_t* scanline = m_pBuffer + row * m_Pitch;
1272 for (int col = 0; col < m_Width; col ++) { 1272 for (int col = 0; col < m_Width; col ++) {
1273 uint8_t b, g, r; 1273 uint8_t b, g, r;
1274 AdobeCMYK_to_sRGB1(scanline[0], scanline[1], scanline[2], scanli ne[3], 1274 AdobeCMYK_to_sRGB1(scanline[0], scanline[1], scanline[2], scanli ne[3],
1275 r, g, b); 1275 r, g, b);
1276 int gray = 255 - FXRGB2GRAY(r, g, b); 1276 int gray = 255 - FXRGB2GRAY(r, g, b);
1277 *scanline ++ = bc + (fc - bc) * gray / 255; 1277 *scanline ++ = bc + (fc - bc) * gray / 255;
1278 *scanline ++ = bm + (fm - bm) * gray / 255; 1278 *scanline ++ = bm + (fm - bm) * gray / 255;
1279 *scanline ++ = by + (fy - by) * gray / 255; 1279 *scanline ++ = by + (fy - by) * gray / 255;
1280 *scanline ++ = bk + (fk - bk) * gray / 255; 1280 *scanline ++ = bk + (fk - bk) * gray / 255;
1281 } 1281 }
1282 } 1282 }
1283 } else { 1283 } else {
1284 for (int row = 0; row < m_Height; row ++) { 1284 for (int row = 0; row < m_Height; row ++) {
1285 uint8_t* scanline = m_pBuffer + row * m_Pitch; 1285 uint8_t* scanline = m_pBuffer + row * m_Pitch;
1286 int gap = m_bpp / 8 - 2; 1286 int gap = m_bpp / 8 - 2;
1287 for (int col = 0; col < m_Width; col ++) { 1287 for (int col = 0; col < m_Width; col ++) {
1288 int gray = FXRGB2GRAY(scanline[2], scanline[1], scanline[0]); 1288 int gray = FXRGB2GRAY(scanline[2], scanline[1], scanline[0]);
1289 *scanline ++ = bb + (fb - bb) * gray / 255; 1289 *scanline ++ = bb + (fb - bb) * gray / 255;
1290 *scanline ++ = bg + (fg - bg) * gray / 255; 1290 *scanline ++ = bg + (fg - bg) * gray / 255;
1291 *scanline = br + (fr - br) * gray / 255; 1291 *scanline = br + (fr - br) * gray / 255;
1292 scanline += gap; 1292 scanline += gap;
1293 } 1293 }
1294 } 1294 }
1295 } 1295 }
1296 return TRUE; 1296 return true;
1297 } 1297 }
1298 FX_BOOL CFX_DIBitmap::DitherFS(const FX_DWORD* pPalette, int pal_size, const FX_ RECT* pRect) 1298 bool CFX_DIBitmap::DitherFS(const FX_DWORD* pPalette, int pal_size, const FX_REC T* pRect)
1299 { 1299 {
1300 if (m_pBuffer == NULL) { 1300 if (m_pBuffer == NULL) {
1301 return FALSE; 1301 return false;
1302 } 1302 }
1303 if (m_bpp != 8 && m_pPalette != NULL && m_AlphaFlag != 0) { 1303 if (m_bpp != 8 && m_pPalette != NULL && m_AlphaFlag != 0) {
1304 return FALSE; 1304 return false;
1305 } 1305 }
1306 if (m_Width < 4 && m_Height < 4) { 1306 if (m_Width < 4 && m_Height < 4) {
1307 return FALSE; 1307 return false;
1308 } 1308 }
1309 FX_RECT rect(0, 0, m_Width, m_Height); 1309 FX_RECT rect(0, 0, m_Width, m_Height);
1310 if (pRect) { 1310 if (pRect) {
1311 rect.Intersect(*pRect); 1311 rect.Intersect(*pRect);
1312 } 1312 }
1313 uint8_t translate[256]; 1313 uint8_t translate[256];
1314 for (int i = 0; i < 256; i ++) { 1314 for (int i = 0; i < 256; i ++) {
1315 int err2 = 65536; 1315 int err2 = 65536;
1316 for (int j = 0; j < pal_size; j ++) { 1316 for (int j = 0; j < pal_size; j ++) {
1317 uint8_t entry = (uint8_t)pPalette[j]; 1317 uint8_t entry = (uint8_t)pPalette[j];
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 if (src > 255) { 1369 if (src > 255) {
1370 next_scan[col - 1] = 255; 1370 next_scan[col - 1] = 255;
1371 } else if (src < 0) { 1371 } else if (src < 0) {
1372 next_scan[col - 1] = 0; 1372 next_scan[col - 1] = 0;
1373 } else { 1373 } else {
1374 next_scan[col - 1] = src; 1374 next_scan[col - 1] = src;
1375 } 1375 }
1376 } 1376 }
1377 } 1377 }
1378 } 1378 }
1379 return TRUE; 1379 return true;
1380 } 1380 }
1381 CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const 1381 CFX_DIBitmap* CFX_DIBSource::FlipImage(bool bXFlip, bool bYFlip) const
1382 { 1382 {
1383 CFX_DIBitmap* pFlipped = new CFX_DIBitmap; 1383 CFX_DIBitmap* pFlipped = new CFX_DIBitmap;
1384 if (!pFlipped->Create(m_Width, m_Height, GetFormat())) { 1384 if (!pFlipped->Create(m_Width, m_Height, GetFormat())) {
1385 delete pFlipped; 1385 delete pFlipped;
1386 return NULL; 1386 return NULL;
1387 } 1387 }
1388 pFlipped->CopyPalette(m_pPalette); 1388 pFlipped->CopyPalette(m_pPalette);
1389 uint8_t* pDestBuffer = pFlipped->GetBuffer(); 1389 uint8_t* pDestBuffer = pFlipped->GetBuffer();
1390 int Bpp = m_bpp / 8; 1390 int Bpp = m_bpp / 8;
1391 for (int row = 0; row < m_Height; row ++) { 1391 for (int row = 0; row < m_Height; row ++) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 } 1475 }
1476 CFX_FilteredDIB::~CFX_FilteredDIB() 1476 CFX_FilteredDIB::~CFX_FilteredDIB()
1477 { 1477 {
1478 if (m_bAutoDropSrc) { 1478 if (m_bAutoDropSrc) {
1479 delete m_pSrc; 1479 delete m_pSrc;
1480 } 1480 }
1481 if (m_pScanline) { 1481 if (m_pScanline) {
1482 FX_Free(m_pScanline); 1482 FX_Free(m_pScanline);
1483 } 1483 }
1484 } 1484 }
1485 void CFX_FilteredDIB::LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc) 1485 void CFX_FilteredDIB::LoadSrc(const CFX_DIBSource* pSrc, bool bAutoDropSrc)
1486 { 1486 {
1487 m_pSrc = pSrc; 1487 m_pSrc = pSrc;
1488 m_bAutoDropSrc = bAutoDropSrc; 1488 m_bAutoDropSrc = bAutoDropSrc;
1489 m_Width = pSrc->GetWidth(); 1489 m_Width = pSrc->GetWidth();
1490 m_Height = pSrc->GetHeight(); 1490 m_Height = pSrc->GetHeight();
1491 FXDIB_Format format = GetDestFormat(); 1491 FXDIB_Format format = GetDestFormat();
1492 m_bpp = (uint8_t)format; 1492 m_bpp = (uint8_t)format;
1493 m_AlphaFlag = (uint8_t)(format >> 8); 1493 m_AlphaFlag = (uint8_t)(format >> 8);
1494 m_Pitch = (m_Width * (format & 0xff) + 31) / 32 * 4; 1494 m_Pitch = (m_Width * (format & 0xff) + 31) / 32 * 4;
1495 m_pPalette = GetDestPalette(); 1495 m_pPalette = GetDestPalette();
1496 m_pScanline = FX_Alloc(uint8_t, m_Pitch); 1496 m_pScanline = FX_Alloc(uint8_t, m_Pitch);
1497 } 1497 }
1498 const uint8_t* CFX_FilteredDIB::GetScanline(int line) const 1498 const uint8_t* CFX_FilteredDIB::GetScanline(int line) const
1499 { 1499 {
1500 TranslateScanline(m_pScanline, m_pSrc->GetScanline(line)); 1500 TranslateScanline(m_pScanline, m_pSrc->GetScanline(line));
1501 return m_pScanline; 1501 return m_pScanline;
1502 } 1502 }
1503 void CFX_FilteredDIB::DownSampleScanline(int line, uint8_t* dest_scan, int dest_ bpp, 1503 void CFX_FilteredDIB::DownSampleScanline(int line, uint8_t* dest_scan, int dest_ bpp,
1504 int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const 1504 int dest_width, bool bFlipX, int clip_left, int clip_width) const
1505 { 1505 {
1506 m_pSrc->DownSampleScanline(line, dest_scan, dest_bpp, dest_width, bFlipX, cl ip_left, clip_width); 1506 m_pSrc->DownSampleScanline(line, dest_scan, dest_bpp, dest_width, bFlipX, cl ip_left, clip_width);
1507 TranslateDownSamples(dest_scan, dest_scan, clip_width, dest_bpp); 1507 TranslateDownSamples(dest_scan, dest_scan, clip_width, dest_bpp);
1508 } 1508 }
1509 CFX_ImageRenderer::CFX_ImageRenderer() 1509 CFX_ImageRenderer::CFX_ImageRenderer()
1510 { 1510 {
1511 m_Status = 0; 1511 m_Status = 0;
1512 m_pTransformer = NULL; 1512 m_pTransformer = NULL;
1513 m_bRgbByteOrder = FALSE; 1513 m_bRgbByteOrder = false;
1514 m_BlendType = FXDIB_BLEND_NORMAL; 1514 m_BlendType = FXDIB_BLEND_NORMAL;
1515 } 1515 }
1516 CFX_ImageRenderer::~CFX_ImageRenderer() 1516 CFX_ImageRenderer::~CFX_ImageRenderer()
1517 { 1517 {
1518 delete m_pTransformer; 1518 delete m_pTransformer;
1519 } 1519 }
1520 extern FX_RECT _FXDIB_SwapClipBox(FX_RECT& clip, int width, int height, FX_BOOL bFlipX, FX_BOOL bFlipY); 1520 extern FX_RECT _FXDIB_SwapClipBox(FX_RECT& clip, int width, int height, bool bFl ipX, bool bFlipY);
1521 FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice, const CFX_ClipRgn* pClip Rgn, 1521 bool CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice, const CFX_ClipRgn* pClipRgn ,
1522 const CFX_DIBSource* pSource, int bitmap_alpha, 1522 const CFX_DIBSource* pSource, int bitmap_alpha,
1523 FX_DWORD mask_color, const CFX_AffineMatrix* pM atrix, 1523 FX_DWORD mask_color, const CFX_AffineMatrix* pM atrix,
1524 FX_DWORD dib_flags, FX_BOOL bRgbByteOrder, 1524 FX_DWORD dib_flags, bool bRgbByteOrder,
1525 int alpha_flag, void* pIccTransform, int blend_ type) 1525 int alpha_flag, void* pIccTransform, int blend_ type)
1526 { 1526 {
1527 m_Matrix = *pMatrix; 1527 m_Matrix = *pMatrix;
1528 CFX_FloatRect image_rect_f = m_Matrix.GetUnitRect(); 1528 CFX_FloatRect image_rect_f = m_Matrix.GetUnitRect();
1529 FX_RECT image_rect = image_rect_f.GetOutterRect(); 1529 FX_RECT image_rect = image_rect_f.GetOutterRect();
1530 m_ClipBox = pClipRgn ? pClipRgn->GetBox() : FX_RECT(0, 0, pDevice->GetWidth( ), pDevice->GetHeight()); 1530 m_ClipBox = pClipRgn ? pClipRgn->GetBox() : FX_RECT(0, 0, pDevice->GetWidth( ), pDevice->GetHeight());
1531 m_ClipBox.Intersect(image_rect); 1531 m_ClipBox.Intersect(image_rect);
1532 if (m_ClipBox.IsEmpty()) { 1532 if (m_ClipBox.IsEmpty()) {
1533 return FALSE; 1533 return false;
1534 } 1534 }
1535 m_pDevice = pDevice; 1535 m_pDevice = pDevice;
1536 m_pClipRgn = pClipRgn; 1536 m_pClipRgn = pClipRgn;
1537 m_MaskColor = mask_color; 1537 m_MaskColor = mask_color;
1538 m_BitmapAlpha = bitmap_alpha; 1538 m_BitmapAlpha = bitmap_alpha;
1539 m_Matrix = *pMatrix; 1539 m_Matrix = *pMatrix;
1540 m_Flags = dib_flags; 1540 m_Flags = dib_flags;
1541 m_AlphaFlag = alpha_flag; 1541 m_AlphaFlag = alpha_flag;
1542 m_pIccTransform = pIccTransform; 1542 m_pIccTransform = pIccTransform;
1543 m_bRgbByteOrder = bRgbByteOrder; 1543 m_bRgbByteOrder = bRgbByteOrder;
1544 m_BlendType = blend_type; 1544 m_BlendType = blend_type;
1545 FX_BOOL ret = TRUE; 1545 bool ret = true;
1546 if ((FXSYS_fabs(m_Matrix.b) >= 0.5f || m_Matrix.a == 0) || 1546 if ((FXSYS_fabs(m_Matrix.b) >= 0.5f || m_Matrix.a == 0) ||
1547 (FXSYS_fabs(m_Matrix.c) >= 0.5f || m_Matrix.d == 0) ) { 1547 (FXSYS_fabs(m_Matrix.c) >= 0.5f || m_Matrix.d == 0) ) {
1548 if (FXSYS_fabs(m_Matrix.a) < FXSYS_fabs(m_Matrix.b) / 20 && FXSYS_fabs(m _Matrix.d) < FXSYS_fabs(m_Matrix.c) / 20 && 1548 if (FXSYS_fabs(m_Matrix.a) < FXSYS_fabs(m_Matrix.b) / 20 && FXSYS_fabs(m _Matrix.d) < FXSYS_fabs(m_Matrix.c) / 20 &&
1549 FXSYS_fabs(m_Matrix.a) < 0.5f && FXSYS_fabs(m_Matrix.d) < 0.5f) { 1549 FXSYS_fabs(m_Matrix.a) < 0.5f && FXSYS_fabs(m_Matrix.d) < 0.5f) {
1550 int dest_width = image_rect.Width(); 1550 int dest_width = image_rect.Width();
1551 int dest_height = image_rect.Height(); 1551 int dest_height = image_rect.Height();
1552 FX_RECT bitmap_clip = m_ClipBox; 1552 FX_RECT bitmap_clip = m_ClipBox;
1553 bitmap_clip.Offset(-image_rect.left, -image_rect.top); 1553 bitmap_clip.Offset(-image_rect.left, -image_rect.top);
1554 bitmap_clip = _FXDIB_SwapClipBox(bitmap_clip, dest_width, dest_heigh t, m_Matrix.c > 0, m_Matrix.b < 0); 1554 bitmap_clip = _FXDIB_SwapClipBox(bitmap_clip, dest_width, dest_heigh t, m_Matrix.c > 0, m_Matrix.b < 0);
1555 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_Cl ipBox, TRUE, 1555 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_Cl ipBox, true,
1556 m_Matrix.c > 0, m_Matrix.b < 0, m_bRgbByteOrder, alpha_flag, pIccTransform, m_BlendType); 1556 m_Matrix.c > 0, m_Matrix.b < 0, m_bRgbByteOrder, alpha_flag, pIccTransform, m_BlendType);
1557 if (!m_Stretcher.Start(&m_Composer, pSource, dest_height, dest_width , bitmap_clip, dib_flags)) { 1557 if (!m_Stretcher.Start(&m_Composer, pSource, dest_height, dest_width , bitmap_clip, dib_flags)) {
1558 return FALSE; 1558 return false;
1559 } 1559 }
1560 m_Status = 1; 1560 m_Status = 1;
1561 return TRUE; 1561 return true;
1562 } 1562 }
1563 m_Status = 2; 1563 m_Status = 2;
1564 m_pTransformer = new CFX_ImageTransformer; 1564 m_pTransformer = new CFX_ImageTransformer;
1565 m_pTransformer->Start(pSource, &m_Matrix, dib_flags, &m_ClipBox); 1565 m_pTransformer->Start(pSource, &m_Matrix, dib_flags, &m_ClipBox);
1566 return TRUE; 1566 return true;
1567 } 1567 }
1568 int dest_width = image_rect.Width(); 1568 int dest_width = image_rect.Width();
1569 if (m_Matrix.a < 0) { 1569 if (m_Matrix.a < 0) {
1570 dest_width = -dest_width; 1570 dest_width = -dest_width;
1571 } 1571 }
1572 int dest_height = image_rect.Height(); 1572 int dest_height = image_rect.Height();
1573 if (m_Matrix.d > 0) { 1573 if (m_Matrix.d > 0) {
1574 dest_height = -dest_height; 1574 dest_height = -dest_height;
1575 } 1575 }
1576 if (dest_width == 0 || dest_height == 0) { 1576 if (dest_width == 0 || dest_height == 0) {
1577 return FALSE; 1577 return false;
1578 } 1578 }
1579 FX_RECT bitmap_clip = m_ClipBox; 1579 FX_RECT bitmap_clip = m_ClipBox;
1580 bitmap_clip.Offset(-image_rect.left, -image_rect.top); 1580 bitmap_clip.Offset(-image_rect.left, -image_rect.top);
1581 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, 1581 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color,
1582 m_ClipBox, FALSE, FALSE, FALSE, m_bRgbByteOrder, alpha_fl ag, pIccTransform, m_BlendType); 1582 m_ClipBox, false, false, false, m_bRgbByteOrder, alpha_fl ag, pIccTransform, m_BlendType);
1583 m_Status = 1; 1583 m_Status = 1;
1584 ret = m_Stretcher.Start(&m_Composer, pSource, dest_width, dest_height, bitma p_clip, dib_flags); 1584 ret = m_Stretcher.Start(&m_Composer, pSource, dest_width, dest_height, bitma p_clip, dib_flags);
1585 return ret; 1585 return ret;
1586 } 1586 }
1587 FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) 1587 bool CFX_ImageRenderer::Continue(IFX_Pause* pPause)
1588 { 1588 {
1589 if (m_Status == 1) { 1589 if (m_Status == 1) {
1590 return m_Stretcher.Continue(pPause); 1590 return m_Stretcher.Continue(pPause);
1591 } else if (m_Status == 2) { 1591 } else if (m_Status == 2) {
1592 if (m_pTransformer->Continue(pPause)) { 1592 if (m_pTransformer->Continue(pPause)) {
1593 return TRUE; 1593 return true;
1594 } 1594 }
1595 CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach(); 1595 CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
1596 if (pBitmap == NULL) { 1596 if (pBitmap == NULL) {
1597 return FALSE; 1597 return false;
1598 } 1598 }
1599 if (pBitmap->GetBuffer() == NULL) { 1599 if (pBitmap->GetBuffer() == NULL) {
1600 delete pBitmap; 1600 delete pBitmap;
1601 return FALSE; 1601 return false;
1602 } 1602 }
1603 if (pBitmap->IsAlphaMask()) { 1603 if (pBitmap->IsAlphaMask()) {
1604 if (m_BitmapAlpha != 255) { 1604 if (m_BitmapAlpha != 255) {
1605 if (m_AlphaFlag >> 8) { 1605 if (m_AlphaFlag >> 8) {
1606 m_AlphaFlag = (((uint8_t)((m_AlphaFlag & 0xff) * m_BitmapAlp ha / 255)) | ((m_AlphaFlag >> 8) << 8)); 1606 m_AlphaFlag = (((uint8_t)((m_AlphaFlag & 0xff) * m_BitmapAlp ha / 255)) | ((m_AlphaFlag >> 8) << 8));
1607 } else { 1607 } else {
1608 m_MaskColor = FXARGB_MUL_ALPHA(m_MaskColor, m_BitmapAlpha); 1608 m_MaskColor = FXARGB_MUL_ALPHA(m_MaskColor, m_BitmapAlpha);
1609 } 1609 }
1610 } 1610 }
1611 m_pDevice->CompositeMask(m_pTransformer->m_ResultLeft, m_pTransforme r->m_ResultTop, 1611 m_pDevice->CompositeMask(m_pTransformer->m_ResultLeft, m_pTransforme r->m_ResultTop,
1612 pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap, m_MaskColor, 1612 pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap, m_MaskColor,
1613 0, 0, m_BlendType, m_pClipRgn, m_bRgbByteOr der, m_AlphaFlag, m_pIccTransform); 1613 0, 0, m_BlendType, m_pClipRgn, m_bRgbByteOr der, m_AlphaFlag, m_pIccTransform);
1614 } else { 1614 } else {
1615 if (m_BitmapAlpha != 255) { 1615 if (m_BitmapAlpha != 255) {
1616 pBitmap->MultiplyAlpha(m_BitmapAlpha); 1616 pBitmap->MultiplyAlpha(m_BitmapAlpha);
1617 } 1617 }
1618 m_pDevice->CompositeBitmap(m_pTransformer->m_ResultLeft, m_pTransfor mer->m_ResultTop, 1618 m_pDevice->CompositeBitmap(m_pTransformer->m_ResultLeft, m_pTransfor mer->m_ResultTop,
1619 pBitmap->GetWidth(), pBitmap->GetHeight() , pBitmap, 0, 0, m_BlendType, m_pClipRgn, m_bRgbByteOrder, m_pIccTransform); 1619 pBitmap->GetWidth(), pBitmap->GetHeight() , pBitmap, 0, 0, m_BlendType, m_pClipRgn, m_bRgbByteOrder, m_pIccTransform);
1620 } 1620 }
1621 delete pBitmap; 1621 delete pBitmap;
1622 return FALSE; 1622 return false;
1623 } 1623 }
1624 return FALSE; 1624 return false;
1625 } 1625 }
1626 CFX_BitmapStorer::CFX_BitmapStorer() 1626 CFX_BitmapStorer::CFX_BitmapStorer()
1627 { 1627 {
1628 m_pBitmap = NULL; 1628 m_pBitmap = NULL;
1629 } 1629 }
1630 CFX_BitmapStorer::~CFX_BitmapStorer() 1630 CFX_BitmapStorer::~CFX_BitmapStorer()
1631 { 1631 {
1632 delete m_pBitmap; 1632 delete m_pBitmap;
1633 } 1633 }
1634 CFX_DIBitmap* CFX_BitmapStorer::Detach() 1634 CFX_DIBitmap* CFX_BitmapStorer::Detach()
(...skipping 12 matching lines...) Expand all
1647 uint8_t* dest_buf = (uint8_t*)m_pBitmap->GetScanline(line); 1647 uint8_t* dest_buf = (uint8_t*)m_pBitmap->GetScanline(line);
1648 uint8_t* dest_alpha_buf = m_pBitmap->m_pAlphaMask ? 1648 uint8_t* dest_alpha_buf = m_pBitmap->m_pAlphaMask ?
1649 (uint8_t*)m_pBitmap->m_pAlphaMask->GetScanline(li ne) : NULL; 1649 (uint8_t*)m_pBitmap->m_pAlphaMask->GetScanline(li ne) : NULL;
1650 if (dest_buf) { 1650 if (dest_buf) {
1651 FXSYS_memcpy(dest_buf, scanline, m_pBitmap->GetPitch()); 1651 FXSYS_memcpy(dest_buf, scanline, m_pBitmap->GetPitch());
1652 } 1652 }
1653 if (dest_alpha_buf) { 1653 if (dest_alpha_buf) {
1654 FXSYS_memcpy(dest_alpha_buf, scan_extra_alpha, m_pBitmap->m_pAlphaMask-> GetPitch()); 1654 FXSYS_memcpy(dest_alpha_buf, scan_extra_alpha, m_pBitmap->m_pAlphaMask-> GetPitch());
1655 } 1655 }
1656 } 1656 }
1657 FX_BOOL CFX_BitmapStorer::SetInfo(int width, int height, FXDIB_Format src_format , FX_DWORD* pSrcPalette) 1657 bool CFX_BitmapStorer::SetInfo(int width, int height, FXDIB_Format src_format, F X_DWORD* pSrcPalette)
1658 { 1658 {
1659 m_pBitmap = new CFX_DIBitmap; 1659 m_pBitmap = new CFX_DIBitmap;
1660 if (!m_pBitmap->Create(width, height, src_format)) { 1660 if (!m_pBitmap->Create(width, height, src_format)) {
1661 delete m_pBitmap; 1661 delete m_pBitmap;
1662 m_pBitmap = NULL; 1662 m_pBitmap = NULL;
1663 return FALSE; 1663 return false;
1664 } 1664 }
1665 if (pSrcPalette) { 1665 if (pSrcPalette) {
1666 m_pBitmap->CopyPalette(pSrcPalette); 1666 m_pBitmap->CopyPalette(pSrcPalette);
1667 } 1667 }
1668 return TRUE; 1668 return true;
1669 } 1669 }
OLDNEW
« no previous file with comments | « core/src/fxge/dib/fx_dib_engine.cpp ('k') | core/src/fxge/dib/fx_dib_transform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698