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

Side by Side Diff: core/src/fxge/dib/fx_dib_convert.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_composite.cpp ('k') | core/src/fxge/dib/fx_dib_engine.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 const FX_DWORD g_dwWinPalette[256] = { 10 const FX_DWORD g_dwWinPalette[256] = {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 0xff000088, 0xff000077, 0xff000055, 0xff000044, 0xff000022, 0xff000011, 96 0xff000088, 0xff000077, 0xff000055, 0xff000044, 0xff000022, 0xff000011,
97 0xffEEEEEE, 0xffDDDDDD, 0xffBBBBBB, 0xffAAAAAA, 0xff888888, 0xff777777, 97 0xffEEEEEE, 0xffDDDDDD, 0xffBBBBBB, 0xffAAAAAA, 0xff888888, 0xff777777,
98 0xff555555, 0xff444444, 0xff222222, 0xff111111, 0xff000000 98 0xff555555, 0xff444444, 0xff222222, 0xff111111, 0xff000000
99 }; 99 };
100 class CFX_Palette 100 class CFX_Palette
101 { 101 {
102 public: 102 public:
103 CFX_Palette(); 103 CFX_Palette();
104 ~CFX_Palette(); 104 ~CFX_Palette();
105 public: 105 public:
106 FX_BOOL BuildPalette(const CFX_DIBSource* pBitmap, int dwPaletteType); 106 bool BuildPalette(const CFX_DIBSource* pBitmap, int dwPaletteType);
107 FX_DWORD* GetPalette() const 107 FX_DWORD* GetPalette() const
108 { 108 {
109 return m_pPalette; 109 return m_pPalette;
110 } 110 }
111 111
112 FX_DWORD* GetColorLut()const 112 FX_DWORD* GetColorLut()const
113 { 113 {
114 return m_cLut; 114 return m_cLut;
115 } 115 }
116 FX_DWORD* GetAmountLut()const 116 FX_DWORD* GetAmountLut()const
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 FX_Free(m_pPalette); 220 FX_Free(m_pPalette);
221 } 221 }
222 if (m_cLut) { 222 if (m_cLut) {
223 FX_Free(m_cLut); 223 FX_Free(m_cLut);
224 } 224 }
225 if (m_aLut) { 225 if (m_aLut) {
226 FX_Free(m_aLut); 226 FX_Free(m_aLut);
227 } 227 }
228 m_lut = 0; 228 m_lut = 0;
229 } 229 }
230 FX_BOOL CFX_Palette::BuildPalette(const CFX_DIBSource* pBitmap, int pal_type) 230 bool CFX_Palette::BuildPalette(const CFX_DIBSource* pBitmap, int pal_type)
231 { 231 {
232 if (pBitmap == NULL) { 232 if (pBitmap == NULL) {
233 return FALSE; 233 return false;
234 } 234 }
235 if (m_pPalette != NULL) { 235 if (m_pPalette != NULL) {
236 FX_Free(m_pPalette); 236 FX_Free(m_pPalette);
237 } 237 }
238 m_pPalette = FX_Alloc(FX_DWORD, 256); 238 m_pPalette = FX_Alloc(FX_DWORD, 256);
239 int bpp = pBitmap->GetBPP() / 8; 239 int bpp = pBitmap->GetBPP() / 8;
240 int width = pBitmap->GetWidth(); 240 int width = pBitmap->GetWidth();
241 int height = pBitmap->GetHeight(); 241 int height = pBitmap->GetHeight();
242 if (m_cLut) { 242 if (m_cLut) {
243 FX_Free(m_cLut); 243 FX_Free(m_cLut);
(...skipping 26 matching lines...) Expand all
270 } 270 }
271 } 271 }
272 _Qsort(m_aLut, m_cLut, 0, m_lut - 1); 272 _Qsort(m_aLut, m_cLut, 0, m_lut - 1);
273 FX_DWORD* win_mac_pal = NULL; 273 FX_DWORD* win_mac_pal = NULL;
274 if (pal_type == FXDIB_PALETTE_WIN) { 274 if (pal_type == FXDIB_PALETTE_WIN) {
275 win_mac_pal = (FX_DWORD*)g_dwWinPalette; 275 win_mac_pal = (FX_DWORD*)g_dwWinPalette;
276 } else if (pal_type == FXDIB_PALETTE_MAC) { 276 } else if (pal_type == FXDIB_PALETTE_MAC) {
277 win_mac_pal = (FX_DWORD*)g_dwMacPalette; 277 win_mac_pal = (FX_DWORD*)g_dwMacPalette;
278 } 278 }
279 _Obtain_Pal(m_aLut, m_cLut, m_pPalette, pal_type, win_mac_pal, m_lut); 279 _Obtain_Pal(m_aLut, m_cLut, m_pPalette, pal_type, win_mac_pal, m_lut);
280 return TRUE; 280 return true;
281 } 281 }
282 FX_BOOL _ConvertBuffer_1bppMask2Gray(uint8_t* dest_buf, int dest_pitch, int widt h, int height, 282 bool _ConvertBuffer_1bppMask2Gray(uint8_t* dest_buf, int dest_pitch, int width, int height,
283 const CFX_DIBSource* pSrcBitmap, int src_le ft, int src_top) 283 const CFX_DIBSource* pSrcBitmap, int src_le ft, int src_top)
284 { 284 {
285 uint8_t set_gray, reset_gray; 285 uint8_t set_gray, reset_gray;
286 set_gray = 0xff; 286 set_gray = 0xff;
287 reset_gray = 0x00; 287 reset_gray = 0x00;
288 for (int row = 0; row < height; row ++) { 288 for (int row = 0; row < height; row ++) {
289 uint8_t* dest_scan = dest_buf + row * dest_pitch; 289 uint8_t* dest_scan = dest_buf + row * dest_pitch;
290 FXSYS_memset(dest_scan, reset_gray, width); 290 FXSYS_memset(dest_scan, reset_gray, width);
291 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); 291 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row);
292 for (int col = src_left; col < src_left + width; col ++) { 292 for (int col = src_left; col < src_left + width; col ++) {
293 if (src_scan[col / 8] & (1 << (7 - col % 8))) { 293 if (src_scan[col / 8] & (1 << (7 - col % 8))) {
294 *dest_scan = set_gray; 294 *dest_scan = set_gray;
295 } 295 }
296 dest_scan ++; 296 dest_scan ++;
297 } 297 }
298 } 298 }
299 return TRUE; 299 return true;
300 } 300 }
301 FX_BOOL _ConvertBuffer_8bppMask2Gray(uint8_t* dest_buf, int dest_pitch, int widt h, int height, 301 bool _ConvertBuffer_8bppMask2Gray(uint8_t* dest_buf, int dest_pitch, int width, int height,
302 const CFX_DIBSource* pSrcBitmap, int src_le ft, int src_top) 302 const CFX_DIBSource* pSrcBitmap, int src_le ft, int src_top)
303 { 303 {
304 for (int row = 0; row < height; row ++) { 304 for (int row = 0; row < height; row ++) {
305 uint8_t* dest_scan = dest_buf + row * dest_pitch; 305 uint8_t* dest_scan = dest_buf + row * dest_pitch;
306 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l eft; 306 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l eft;
307 FXSYS_memcpy(dest_scan, src_scan, width); 307 FXSYS_memcpy(dest_scan, src_scan, width);
308 } 308 }
309 return TRUE; 309 return true;
310 } 310 }
311 FX_BOOL _ConvertBuffer_1bppPlt2Gray(uint8_t* dest_buf, int dest_pitch, int width , int height, 311 bool _ConvertBuffer_1bppPlt2Gray(uint8_t* dest_buf, int dest_pitch, int width, i nt height,
312 const CFX_DIBSource* pSrcBitmap, int src_lef t, int src_top, void* pIccTransform) 312 const CFX_DIBSource* pSrcBitmap, int src_lef t, int src_top, void* pIccTransform)
313 { 313 {
314 FX_DWORD* src_plt = pSrcBitmap->GetPalette(); 314 FX_DWORD* src_plt = pSrcBitmap->GetPalette();
315 uint8_t gray[2]; 315 uint8_t gray[2];
316 if (pIccTransform) { 316 if (pIccTransform) {
317 FX_DWORD plt[2]; 317 FX_DWORD plt[2];
318 if (pSrcBitmap->IsCmykImage()) { 318 if (pSrcBitmap->IsCmykImage()) {
319 plt[0] = FXCMYK_TODIB(src_plt[0]); 319 plt[0] = FXCMYK_TODIB(src_plt[0]);
320 plt[1] = FXCMYK_TODIB(src_plt[1]); 320 plt[1] = FXCMYK_TODIB(src_plt[1]);
321 } else { 321 } else {
(...skipping 30 matching lines...) Expand all
352 uint8_t* dest_scan = dest_buf + row * dest_pitch; 352 uint8_t* dest_scan = dest_buf + row * dest_pitch;
353 FXSYS_memset(dest_scan, gray[0], width); 353 FXSYS_memset(dest_scan, gray[0], width);
354 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); 354 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row);
355 for (int col = src_left; col < src_left + width; col ++) { 355 for (int col = src_left; col < src_left + width; col ++) {
356 if (src_scan[col / 8] & (1 << (7 - col % 8))) { 356 if (src_scan[col / 8] & (1 << (7 - col % 8))) {
357 *dest_scan = gray[1]; 357 *dest_scan = gray[1];
358 } 358 }
359 dest_scan ++; 359 dest_scan ++;
360 } 360 }
361 } 361 }
362 return TRUE; 362 return true;
363 } 363 }
364 FX_BOOL _ConvertBuffer_8bppPlt2Gray(uint8_t* dest_buf, int dest_pitch, int width , int height, 364 bool _ConvertBuffer_8bppPlt2Gray(uint8_t* dest_buf, int dest_pitch, int width, i nt height,
365 const CFX_DIBSource* pSrcBitmap, int src_lef t, int src_top, void* pIccTransform) 365 const CFX_DIBSource* pSrcBitmap, int src_lef t, int src_top, void* pIccTransform)
366 { 366 {
367 FX_DWORD* src_plt = pSrcBitmap->GetPalette(); 367 FX_DWORD* src_plt = pSrcBitmap->GetPalette();
368 uint8_t gray[256]; 368 uint8_t gray[256];
369 if (pIccTransform) { 369 if (pIccTransform) {
370 FX_DWORD plt[256]; 370 FX_DWORD plt[256];
371 if (pSrcBitmap->IsCmykImage()) { 371 if (pSrcBitmap->IsCmykImage()) {
372 for (int i = 0; i < 256; i ++) { 372 for (int i = 0; i < 256; i ++) {
373 plt[i] = FXCMYK_TODIB(src_plt[i]); 373 plt[i] = FXCMYK_TODIB(src_plt[i]);
374 } 374 }
(...skipping 20 matching lines...) Expand all
395 gray[i] = FXRGB2GRAY(FXARGB_R(src_plt[i]), FXARGB_G(src_plt[i]), FXARGB_B(src_plt[i])); 395 gray[i] = FXRGB2GRAY(FXARGB_R(src_plt[i]), FXARGB_G(src_plt[i]), FXARGB_B(src_plt[i]));
396 } 396 }
397 } 397 }
398 for (int row = 0; row < height; row ++) { 398 for (int row = 0; row < height; row ++) {
399 uint8_t* dest_scan = dest_buf + row * dest_pitch; 399 uint8_t* dest_scan = dest_buf + row * dest_pitch;
400 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l eft; 400 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l eft;
401 for (int col = 0; col < width; col ++) { 401 for (int col = 0; col < width; col ++) {
402 *dest_scan++ = gray[*src_scan++]; 402 *dest_scan++ = gray[*src_scan++];
403 } 403 }
404 } 404 }
405 return TRUE; 405 return true;
406 } 406 }
407 FX_BOOL _ConvertBuffer_RgbOrCmyk2Gray(uint8_t* dest_buf, int dest_pitch, int wid th, int height, 407 bool _ConvertBuffer_RgbOrCmyk2Gray(uint8_t* dest_buf, int dest_pitch, int width, int height,
408 const CFX_DIBSource* pSrcBitmap, int src_l eft, int src_top, void* pIccTransform) 408 const CFX_DIBSource* pSrcBitmap, int src_l eft, int src_top, void* pIccTransform)
409 { 409 {
410 int Bpp = pSrcBitmap->GetBPP() / 8; 410 int Bpp = pSrcBitmap->GetBPP() / 8;
411 if (pIccTransform) { 411 if (pIccTransform) {
412 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge tIccModule(); 412 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge tIccModule();
413 if (Bpp == 3 || pSrcBitmap->IsCmykImage()) { 413 if (Bpp == 3 || pSrcBitmap->IsCmykImage()) {
414 for (int row = 0; row < height; row ++) { 414 for (int row = 0; row < height; row ++) {
415 uint8_t* dest_scan = dest_buf + row * dest_pitch; 415 uint8_t* dest_scan = dest_buf + row * dest_pitch;
416 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp; 416 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp;
417 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan , width); 417 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan , width);
(...skipping 26 matching lines...) Expand all
444 for (int row = 0; row < height; row ++) { 444 for (int row = 0; row < height; row ++) {
445 uint8_t* dest_scan = dest_buf + row * dest_pitch; 445 uint8_t* dest_scan = dest_buf + row * dest_pitch;
446 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp; 446 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp;
447 for (int col = 0; col < width; col ++) { 447 for (int col = 0; col < width; col ++) {
448 *dest_scan++ = FXRGB2GRAY(src_scan[2], src_scan[1], src_scan [0]); 448 *dest_scan++ = FXRGB2GRAY(src_scan[2], src_scan[1], src_scan [0]);
449 src_scan += Bpp; 449 src_scan += Bpp;
450 } 450 }
451 } 451 }
452 } 452 }
453 } 453 }
454 return TRUE; 454 return true;
455 } 455 }
456 inline void _ConvertBuffer_IndexCopy(uint8_t* dest_buf, int dest_pitch, int widt h, int height, 456 inline void _ConvertBuffer_IndexCopy(uint8_t* dest_buf, int dest_pitch, int widt h, int height,
457 const CFX_DIBSource* pSrcBitmap, int src_le ft, int src_top) 457 const CFX_DIBSource* pSrcBitmap, int src_le ft, int src_top)
458 { 458 {
459 if (pSrcBitmap->GetBPP() == 1) { 459 if (pSrcBitmap->GetBPP() == 1) {
460 for (int row = 0; row < height; row ++) { 460 for (int row = 0; row < height; row ++) {
461 uint8_t* dest_scan = dest_buf + row * dest_pitch; 461 uint8_t* dest_scan = dest_buf + row * dest_pitch;
462 FXSYS_memset(dest_scan, 0, width); 462 FXSYS_memset(dest_scan, 0, width);
463 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); 463 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row);
464 for (int col = src_left; col < src_left + width; col ++) { 464 for (int col = src_left; col < src_left + width; col ++) {
465 if (src_scan[col / 8] & (1 << (7 - col % 8))) { 465 if (src_scan[col / 8] & (1 << (7 - col % 8))) {
466 *dest_scan = 1; 466 *dest_scan = 1;
467 } 467 }
468 dest_scan ++; 468 dest_scan ++;
469 } 469 }
470 } 470 }
471 } else { 471 } else {
472 for (int row = 0; row < height; row ++) { 472 for (int row = 0; row < height; row ++) {
473 uint8_t* dest_scan = dest_buf + row * dest_pitch; 473 uint8_t* dest_scan = dest_buf + row * dest_pitch;
474 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left; 474 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left;
475 FXSYS_memcpy(dest_scan, src_scan, width); 475 FXSYS_memcpy(dest_scan, src_scan, width);
476 } 476 }
477 } 477 }
478 } 478 }
479 FX_BOOL _ConvertBuffer_Plt2PltRgb8(uint8_t* dest_buf, int dest_pitch, int width, int height, 479 bool _ConvertBuffer_Plt2PltRgb8(uint8_t* dest_buf, int dest_pitch, int width, in t height,
480 const CFX_DIBSource* pSrcBitmap, int src_left , int src_top, FX_DWORD* dst_plt, void* pIccTransform) 480 const CFX_DIBSource* pSrcBitmap, int src_left , int src_top, FX_DWORD* dst_plt, void* pIccTransform)
481 { 481 {
482 _ConvertBuffer_IndexCopy(dest_buf, dest_pitch, width, height, pSrcBitmap, sr c_left, src_top); 482 _ConvertBuffer_IndexCopy(dest_buf, dest_pitch, width, height, pSrcBitmap, sr c_left, src_top);
483 FX_DWORD* src_plt = pSrcBitmap->GetPalette(); 483 FX_DWORD* src_plt = pSrcBitmap->GetPalette();
484 int plt_size = pSrcBitmap->GetPaletteSize(); 484 int plt_size = pSrcBitmap->GetPaletteSize();
485 if (pIccTransform) { 485 if (pIccTransform) {
486 FX_DWORD plt[256]; 486 FX_DWORD plt[256];
487 uint8_t* bgr_ptr = (uint8_t*)plt; 487 uint8_t* bgr_ptr = (uint8_t*)plt;
488 if (pSrcBitmap->IsCmykImage()) { 488 if (pSrcBitmap->IsCmykImage()) {
489 for (int i = 0; i < plt_size; i ++) { 489 for (int i = 0; i < plt_size; i ++) {
(...skipping 18 matching lines...) Expand all
508 for (int i = 0; i < plt_size; i ++) { 508 for (int i = 0; i < plt_size; i ++) {
509 uint8_t r, g, b; 509 uint8_t r, g, b;
510 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue( src_plt[i]), FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]), 510 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue( src_plt[i]), FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]),
511 r, g, b); 511 r, g, b);
512 dst_plt[i] = FXARGB_MAKE(0xff, r, g, b); 512 dst_plt[i] = FXARGB_MAKE(0xff, r, g, b);
513 } 513 }
514 } else { 514 } else {
515 FXSYS_memcpy(dst_plt, src_plt, plt_size * 4); 515 FXSYS_memcpy(dst_plt, src_plt, plt_size * 4);
516 } 516 }
517 } 517 }
518 return TRUE; 518 return true;
519 } 519 }
520 inline FX_BOOL _ConvertBuffer_Rgb2PltRgb8_NoTransform(uint8_t* dest_buf, int des t_pitch, int width, int height, 520 inline bool _ConvertBuffer_Rgb2PltRgb8_NoTransform(uint8_t* dest_buf, int dest_p itch, int width, int height,
521 const CFX_DIBSource* pSrcBitmap, int src_left, int src_top, FX_DWORD* ds t_plt) 521 const CFX_DIBSource* pSrcBitmap, int src_left, int src_top, FX_DWORD* ds t_plt)
522 { 522 {
523 int bpp = pSrcBitmap->GetBPP() / 8; 523 int bpp = pSrcBitmap->GetBPP() / 8;
524 int row, col; 524 int row, col;
525 CFX_Palette palette; 525 CFX_Palette palette;
526 palette.BuildPalette(pSrcBitmap, FXDIB_PALETTE_LOC); 526 palette.BuildPalette(pSrcBitmap, FXDIB_PALETTE_LOC);
527 FX_DWORD* cLut = palette.GetColorLut(); 527 FX_DWORD* cLut = palette.GetColorLut();
528 FX_DWORD* aLut = palette.GetAmountLut(); 528 FX_DWORD* aLut = palette.GetAmountLut();
529 if (cLut == NULL || aLut == NULL) { 529 if (cLut == NULL || aLut == NULL) {
530 return FALSE; 530 return false;
531 } 531 }
532 int lut = palette.Getlut(); 532 int lut = palette.Getlut();
533 FX_DWORD* pPalette = palette.GetPalette(); 533 FX_DWORD* pPalette = palette.GetPalette();
534 if (lut > 256) { 534 if (lut > 256) {
535 int err, min_err; 535 int err, min_err;
536 int lut_256 = lut - 256; 536 int lut_256 = lut - 256;
537 for (row = 0; row < lut_256; row++) { 537 for (row = 0; row < lut_256; row++) {
538 min_err = 1000000; 538 min_err = 1000000;
539 uint8_t r, g, b; 539 uint8_t r, g, b;
540 _ColorDecode(cLut[row], r, g, b); 540 _ColorDecode(cLut[row], r, g, b);
(...skipping 23 matching lines...) Expand all
564 int b = src_port[0] & 0xf0; 564 int b = src_port[0] & 0xf0;
565 FX_DWORD clrindex = (r << 4) + g + (b >> 4); 565 FX_DWORD clrindex = (r << 4) + g + (b >> 4);
566 for (int i = lut_1; i >= 0; i--) 566 for (int i = lut_1; i >= 0; i--)
567 if (clrindex == cLut[i]) { 567 if (clrindex == cLut[i]) {
568 *(dest_scan + col) = (uint8_t)(aLut[i]); 568 *(dest_scan + col) = (uint8_t)(aLut[i]);
569 break; 569 break;
570 } 570 }
571 } 571 }
572 } 572 }
573 FXSYS_memcpy(dst_plt, pPalette, sizeof(FX_DWORD) * 256); 573 FXSYS_memcpy(dst_plt, pPalette, sizeof(FX_DWORD) * 256);
574 return TRUE; 574 return true;
575 } 575 }
576 FX_BOOL _ConvertBuffer_Rgb2PltRgb8(uint8_t* dest_buf, int dest_pitch, int width, int height, 576 bool _ConvertBuffer_Rgb2PltRgb8(uint8_t* dest_buf, int dest_pitch, int width, in t height,
577 const CFX_DIBSource* pSrcBitmap, int src_left , int src_top, FX_DWORD* dst_plt, void* pIccTransform) 577 const CFX_DIBSource* pSrcBitmap, int src_left , int src_top, FX_DWORD* dst_plt, void* pIccTransform)
578 { 578 {
579 FX_BOOL ret = _ConvertBuffer_Rgb2PltRgb8_NoTransform(dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, dst_plt); 579 bool ret = _ConvertBuffer_Rgb2PltRgb8_NoTransform(dest_buf, dest_pitch, widt h, height, pSrcBitmap, src_left, src_top, dst_plt);
580 if (ret && pIccTransform) { 580 if (ret && pIccTransform) {
581 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge tIccModule(); 581 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge tIccModule();
582 for (int i = 0; i < 256; i++) { 582 for (int i = 0; i < 256; i++) {
583 FX_ARGB* plt = dst_plt + i; 583 FX_ARGB* plt = dst_plt + i;
584 FX_ARGB plt_entry = FXARGB_TODIB(*plt); 584 FX_ARGB plt_entry = FXARGB_TODIB(*plt);
585 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&plt_entry, ( const uint8_t*)&plt_entry, 1); 585 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&plt_entry, ( const uint8_t*)&plt_entry, 1);
586 *plt = FXARGB_TODIB(plt_entry); 586 *plt = FXARGB_TODIB(plt_entry);
587 } 587 }
588 } 588 }
589 return ret; 589 return ret;
590 } 590 }
591 FX_BOOL _ConvertBuffer_1bppMask2Rgb(FXDIB_Format dst_format, uint8_t* dest_buf, int dest_pitch, int width, int height, 591 bool _ConvertBuffer_1bppMask2Rgb(FXDIB_Format dst_format, uint8_t* dest_buf, int dest_pitch, int width, int height,
592 const CFX_DIBSource* pSrcBitmap, int src_lef t, int src_top) 592 const CFX_DIBSource* pSrcBitmap, int src_lef t, int src_top)
593 { 593 {
594 int comps = (dst_format & 0xff) / 8; 594 int comps = (dst_format & 0xff) / 8;
595 uint8_t set_gray, reset_gray; 595 uint8_t set_gray, reset_gray;
596 set_gray = 0xff; 596 set_gray = 0xff;
597 reset_gray = 0x00; 597 reset_gray = 0x00;
598 for (int row = 0; row < height; row ++) { 598 for (int row = 0; row < height; row ++) {
599 uint8_t* dest_scan = dest_buf + row * dest_pitch; 599 uint8_t* dest_scan = dest_buf + row * dest_pitch;
600 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); 600 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row);
601 for (int col = src_left; col < src_left + width; col ++) { 601 for (int col = src_left; col < src_left + width; col ++) {
602 if (src_scan[col / 8] & (1 << (7 - col % 8))) { 602 if (src_scan[col / 8] & (1 << (7 - col % 8))) {
603 dest_scan[0] = set_gray; 603 dest_scan[0] = set_gray;
604 dest_scan[1] = set_gray; 604 dest_scan[1] = set_gray;
605 dest_scan[2] = set_gray; 605 dest_scan[2] = set_gray;
606 } else { 606 } else {
607 dest_scan[0] = reset_gray; 607 dest_scan[0] = reset_gray;
608 dest_scan[1] = reset_gray; 608 dest_scan[1] = reset_gray;
609 dest_scan[2] = reset_gray; 609 dest_scan[2] = reset_gray;
610 } 610 }
611 dest_scan += comps; 611 dest_scan += comps;
612 } 612 }
613 } 613 }
614 return TRUE; 614 return true;
615 } 615 }
616 FX_BOOL _ConvertBuffer_8bppMask2Rgb(FXDIB_Format dst_format, uint8_t* dest_buf, int dest_pitch, int width, int height, 616 bool _ConvertBuffer_8bppMask2Rgb(FXDIB_Format dst_format, uint8_t* dest_buf, int dest_pitch, int width, int height,
617 const CFX_DIBSource* pSrcBitmap, int src_lef t, int src_top) 617 const CFX_DIBSource* pSrcBitmap, int src_lef t, int src_top)
618 { 618 {
619 int comps = (dst_format & 0xff) / 8; 619 int comps = (dst_format & 0xff) / 8;
620 for (int row = 0; row < height; row ++) { 620 for (int row = 0; row < height; row ++) {
621 uint8_t* dest_scan = dest_buf + row * dest_pitch; 621 uint8_t* dest_scan = dest_buf + row * dest_pitch;
622 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l eft; 622 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l eft;
623 uint8_t src_pixel; 623 uint8_t src_pixel;
624 for (int col = 0; col < width; col ++) { 624 for (int col = 0; col < width; col ++) {
625 src_pixel = *src_scan++; 625 src_pixel = *src_scan++;
626 *dest_scan++ = src_pixel; 626 *dest_scan++ = src_pixel;
627 *dest_scan++ = src_pixel; 627 *dest_scan++ = src_pixel;
628 *dest_scan = src_pixel; 628 *dest_scan = src_pixel;
629 dest_scan += comps - 2; 629 dest_scan += comps - 2;
630 } 630 }
631 } 631 }
632 return TRUE; 632 return true;
633 } 633 }
634 FX_BOOL _ConvertBuffer_1bppPlt2Rgb(FXDIB_Format dst_format, uint8_t* dest_buf, i nt dest_pitch, int width, int height, 634 bool _ConvertBuffer_1bppPlt2Rgb(FXDIB_Format dst_format, uint8_t* dest_buf, int dest_pitch, int width, int height,
635 const CFX_DIBSource* pSrcBitmap, int src_left , int src_top, void* pIccTransform) 635 const CFX_DIBSource* pSrcBitmap, int src_left , int src_top, void* pIccTransform)
636 { 636 {
637 int comps = (dst_format & 0xff) / 8; 637 int comps = (dst_format & 0xff) / 8;
638 FX_DWORD* src_plt = pSrcBitmap->GetPalette(); 638 FX_DWORD* src_plt = pSrcBitmap->GetPalette();
639 FX_DWORD plt[2]; 639 FX_DWORD plt[2];
640 uint8_t* bgr_ptr = (uint8_t*)plt; 640 uint8_t* bgr_ptr = (uint8_t*)plt;
641 if (pSrcBitmap->IsCmykImage()) { 641 if (pSrcBitmap->IsCmykImage()) {
642 plt[0] = FXCMYK_TODIB(src_plt[0]); 642 plt[0] = FXCMYK_TODIB(src_plt[0]);
643 plt[1] = FXCMYK_TODIB(src_plt[1]); 643 plt[1] = FXCMYK_TODIB(src_plt[1]);
644 } else { 644 } else {
(...skipping 24 matching lines...) Expand all
669 *dest_scan++ = bgr_ptr[4]; 669 *dest_scan++ = bgr_ptr[4];
670 *dest_scan = bgr_ptr[5]; 670 *dest_scan = bgr_ptr[5];
671 } else { 671 } else {
672 *dest_scan++ = bgr_ptr[0]; 672 *dest_scan++ = bgr_ptr[0];
673 *dest_scan++ = bgr_ptr[1]; 673 *dest_scan++ = bgr_ptr[1];
674 *dest_scan = bgr_ptr[2]; 674 *dest_scan = bgr_ptr[2];
675 } 675 }
676 dest_scan += comps - 2; 676 dest_scan += comps - 2;
677 } 677 }
678 } 678 }
679 return TRUE; 679 return true;
680 } 680 }
681 FX_BOOL _ConvertBuffer_8bppPlt2Rgb(FXDIB_Format dst_format, uint8_t* dest_buf, i nt dest_pitch, int width, int height, 681 bool _ConvertBuffer_8bppPlt2Rgb(FXDIB_Format dst_format, uint8_t* dest_buf, int dest_pitch, int width, int height,
682 const CFX_DIBSource* pSrcBitmap, int src_left , int src_top, void* pIccTransform) 682 const CFX_DIBSource* pSrcBitmap, int src_left , int src_top, void* pIccTransform)
683 { 683 {
684 int comps = (dst_format & 0xff) / 8; 684 int comps = (dst_format & 0xff) / 8;
685 FX_DWORD* src_plt = pSrcBitmap->GetPalette(); 685 FX_DWORD* src_plt = pSrcBitmap->GetPalette();
686 FX_DWORD plt[256]; 686 FX_DWORD plt[256];
687 uint8_t* bgr_ptr = (uint8_t*)plt; 687 uint8_t* bgr_ptr = (uint8_t*)plt;
688 if (!pSrcBitmap->IsCmykImage()) { 688 if (!pSrcBitmap->IsCmykImage()) {
689 for (int i = 0; i < 256; i++) { 689 for (int i = 0; i < 256; i++) {
690 *bgr_ptr++ = FXARGB_B(src_plt[i]); 690 *bgr_ptr++ = FXARGB_B(src_plt[i]);
691 *bgr_ptr++ = FXARGB_G(src_plt[i]); 691 *bgr_ptr++ = FXARGB_G(src_plt[i]);
(...skipping 23 matching lines...) Expand all
715 uint8_t* dest_scan = dest_buf + row * dest_pitch; 715 uint8_t* dest_scan = dest_buf + row * dest_pitch;
716 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l eft; 716 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l eft;
717 for (int col = 0; col < width; col ++) { 717 for (int col = 0; col < width; col ++) {
718 uint8_t* src_pixel = bgr_ptr + 3 * (*src_scan++); 718 uint8_t* src_pixel = bgr_ptr + 3 * (*src_scan++);
719 *dest_scan++ = *src_pixel++; 719 *dest_scan++ = *src_pixel++;
720 *dest_scan++ = *src_pixel++; 720 *dest_scan++ = *src_pixel++;
721 *dest_scan = *src_pixel++; 721 *dest_scan = *src_pixel++;
722 dest_scan += comps - 2; 722 dest_scan += comps - 2;
723 } 723 }
724 } 724 }
725 return TRUE; 725 return true;
726 } 726 }
727 FX_BOOL _ConvertBuffer_24bppRgb2Rgb24(uint8_t* dest_buf, int dest_pitch, int wid th, int height, 727 bool _ConvertBuffer_24bppRgb2Rgb24(uint8_t* dest_buf, int dest_pitch, int width, int height,
728 const CFX_DIBSource* pSrcBitmap, int src_l eft, int src_top, void* pIccTransform) 728 const CFX_DIBSource* pSrcBitmap, int src_l eft, int src_top, void* pIccTransform)
729 { 729 {
730 if (pIccTransform) { 730 if (pIccTransform) {
731 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge tIccModule(); 731 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge tIccModule();
732 for (int row = 0; row < height; row ++) { 732 for (int row = 0; row < height; row ++) {
733 uint8_t* dest_scan = dest_buf + row * dest_pitch; 733 uint8_t* dest_scan = dest_buf + row * dest_pitch;
734 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left * 3; 734 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left * 3;
735 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan, wi dth); 735 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan, wi dth);
736 } 736 }
737 } else { 737 } else {
738 for (int row = 0; row < height; row ++) { 738 for (int row = 0; row < height; row ++) {
739 uint8_t* dest_scan = dest_buf + row * dest_pitch; 739 uint8_t* dest_scan = dest_buf + row * dest_pitch;
740 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left * 3; 740 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left * 3;
741 FXSYS_memcpy(dest_scan, src_scan, width * 3); 741 FXSYS_memcpy(dest_scan, src_scan, width * 3);
742 } 742 }
743 } 743 }
744 return TRUE; 744 return true;
745 } 745 }
746 FX_BOOL _ConvertBuffer_32bppRgb2Rgb24(uint8_t* dest_buf, int dest_pitch, int wid th, int height, 746 bool _ConvertBuffer_32bppRgb2Rgb24(uint8_t* dest_buf, int dest_pitch, int width, int height,
747 const CFX_DIBSource* pSrcBitmap, int src_l eft, int src_top, void* pIccTransform) 747 const CFX_DIBSource* pSrcBitmap, int src_l eft, int src_top, void* pIccTransform)
748 { 748 {
749 for (int row = 0; row < height; row ++) { 749 for (int row = 0; row < height; row ++) {
750 uint8_t* dest_scan = dest_buf + row * dest_pitch; 750 uint8_t* dest_scan = dest_buf + row * dest_pitch;
751 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l eft * 4; 751 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l eft * 4;
752 for (int col = 0; col < width; col ++) { 752 for (int col = 0; col < width; col ++) {
753 *dest_scan++ = *src_scan++; 753 *dest_scan++ = *src_scan++;
754 *dest_scan++ = *src_scan++; 754 *dest_scan++ = *src_scan++;
755 *dest_scan++ = *src_scan++; 755 *dest_scan++ = *src_scan++;
756 src_scan++; 756 src_scan++;
757 } 757 }
758 } 758 }
759 if (pIccTransform) { 759 if (pIccTransform) {
760 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge tIccModule(); 760 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge tIccModule();
761 for (int row = 0; row < height; row ++) { 761 for (int row = 0; row < height; row ++) {
762 uint8_t* dest_scan = dest_buf + row * dest_pitch; 762 uint8_t* dest_scan = dest_buf + row * dest_pitch;
763 pIccModule->TranslateScanline(pIccTransform, dest_scan, dest_scan, w idth); 763 pIccModule->TranslateScanline(pIccTransform, dest_scan, dest_scan, w idth);
764 } 764 }
765 } 765 }
766 return TRUE; 766 return true;
767 } 767 }
768 FX_BOOL _ConvertBuffer_Rgb2Rgb32(uint8_t* dest_buf, int dest_pitch, int width, i nt height, 768 bool _ConvertBuffer_Rgb2Rgb32(uint8_t* dest_buf, int dest_pitch, int width, int height,
769 const CFX_DIBSource* pSrcBitmap, int src_left, int src_top, void* pIccTransform) 769 const CFX_DIBSource* pSrcBitmap, int src_left, int src_top, void* pIccTransform)
770 { 770 {
771 int comps = pSrcBitmap->GetBPP() / 8; 771 int comps = pSrcBitmap->GetBPP() / 8;
772 if (pIccTransform) { 772 if (pIccTransform) {
773 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge tIccModule(); 773 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge tIccModule();
774 for (int row = 0; row < height; row ++) { 774 for (int row = 0; row < height; row ++) {
775 uint8_t* dest_scan = dest_buf + row * dest_pitch; 775 uint8_t* dest_scan = dest_buf + row * dest_pitch;
776 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left * comps; 776 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left * comps;
777 for (int col = 0; col < width; col ++) { 777 for (int col = 0; col < width; col ++) {
778 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan , 1); 778 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan , 1);
779 dest_scan += 4; 779 dest_scan += 4;
780 src_scan += comps; 780 src_scan += comps;
781 } 781 }
782 } 782 }
783 } else { 783 } else {
784 for (int row = 0; row < height; row ++) { 784 for (int row = 0; row < height; row ++) {
785 uint8_t* dest_scan = dest_buf + row * dest_pitch; 785 uint8_t* dest_scan = dest_buf + row * dest_pitch;
786 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left * comps; 786 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left * comps;
787 for (int col = 0; col < width; col ++) { 787 for (int col = 0; col < width; col ++) {
788 *dest_scan++ = *src_scan++; 788 *dest_scan++ = *src_scan++;
789 *dest_scan++ = *src_scan++; 789 *dest_scan++ = *src_scan++;
790 *dest_scan++ = *src_scan++; 790 *dest_scan++ = *src_scan++;
791 dest_scan++; 791 dest_scan++;
792 src_scan += comps - 3; 792 src_scan += comps - 3;
793 } 793 }
794 } 794 }
795 } 795 }
796 return TRUE; 796 return true;
797 } 797 }
798 FX_BOOL _ConvertBuffer_32bppCmyk2Rgb32(uint8_t* dest_buf, int dest_pitch, int wi dth, int height, 798 bool _ConvertBuffer_32bppCmyk2Rgb32(uint8_t* dest_buf, int dest_pitch, int width , int height,
799 const CFX_DIBSource* pSrcBitmap, int src_ left, int src_top, void* pIccTransform) 799 const CFX_DIBSource* pSrcBitmap, int src_ left, int src_top, void* pIccTransform)
800 { 800 {
801 if (pIccTransform) { 801 if (pIccTransform) {
802 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge tIccModule(); 802 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge tIccModule();
803 for (int row = 0; row < height; row ++) { 803 for (int row = 0; row < height; row ++) {
804 uint8_t* dest_scan = dest_buf + row * dest_pitch; 804 uint8_t* dest_scan = dest_buf + row * dest_pitch;
805 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left * 4; 805 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left * 4;
806 for (int col = 0; col < width; col ++) { 806 for (int col = 0; col < width; col ++) {
807 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan , 1); 807 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan , 1);
808 dest_scan += 4; 808 dest_scan += 4;
809 src_scan += 4; 809 src_scan += 4;
810 } 810 }
811 } 811 }
812 } else { 812 } else {
813 for (int row = 0; row < height; row ++) { 813 for (int row = 0; row < height; row ++) {
814 uint8_t* dest_scan = dest_buf + row * dest_pitch; 814 uint8_t* dest_scan = dest_buf + row * dest_pitch;
815 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left * 4; 815 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s rc_left * 4;
816 for (int col = 0; col < width; col ++) { 816 for (int col = 0; col < width; col ++) {
817 AdobeCMYK_to_sRGB1(src_scan[0], src_scan[1], src_scan[2], src_sc an[3], 817 AdobeCMYK_to_sRGB1(src_scan[0], src_scan[1], src_scan[2], src_sc an[3],
818 dest_scan[2], dest_scan[1], dest_scan[0]); 818 dest_scan[2], dest_scan[1], dest_scan[0]);
819 dest_scan += 4; 819 dest_scan += 4;
820 src_scan += 4; 820 src_scan += 4;
821 } 821 }
822 } 822 }
823 } 823 }
824 return TRUE; 824 return true;
825 } 825 }
826 FX_BOOL ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitc h, int width, int height, 826 bool ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitch, int width, int height,
827 const CFX_DIBSource* pSrcBitmap, int src_left, int src_top , FX_DWORD*& d_pal, void* pIccTransform) 827 const CFX_DIBSource* pSrcBitmap, int src_left, int src_top , FX_DWORD*& d_pal, void* pIccTransform)
828 { 828 {
829 FXDIB_Format src_format = pSrcBitmap->GetFormat(); 829 FXDIB_Format src_format = pSrcBitmap->GetFormat();
830 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodec Module()->GetIccModule()) { 830 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodec Module()->GetIccModule()) {
831 pIccTransform = NULL; 831 pIccTransform = NULL;
832 } 832 }
833 switch (dest_format) { 833 switch (dest_format) {
834 case FXDIB_Invalid: 834 case FXDIB_Invalid:
835 case FXDIB_1bppCmyk: 835 case FXDIB_1bppCmyk:
836 case FXDIB_1bppMask: 836 case FXDIB_1bppMask:
837 case FXDIB_1bppRgb: 837 case FXDIB_1bppRgb:
838 ASSERT(FALSE); 838 ASSERT(false);
839 return FALSE; 839 return false;
840 case FXDIB_8bppMask: { 840 case FXDIB_8bppMask: {
841 if ((src_format & 0xff) == 1) { 841 if ((src_format & 0xff) == 1) {
842 if (pSrcBitmap->GetPalette()) { 842 if (pSrcBitmap->GetPalette()) {
843 return _ConvertBuffer_1bppPlt2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); 843 return _ConvertBuffer_1bppPlt2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
844 } 844 }
845 return _ConvertBuffer_1bppMask2Gray(dest_buf, dest_pitch, wi dth, height, pSrcBitmap, src_left, src_top); 845 return _ConvertBuffer_1bppMask2Gray(dest_buf, dest_pitch, wi dth, height, pSrcBitmap, src_left, src_top);
846 } else if ((src_format & 0xff) == 8) { 846 } else if ((src_format & 0xff) == 8) {
847 if (pSrcBitmap->GetPalette()) { 847 if (pSrcBitmap->GetPalette()) {
848 return _ConvertBuffer_8bppPlt2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); 848 return _ConvertBuffer_8bppPlt2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
849 } 849 }
850 return _ConvertBuffer_8bppMask2Gray(dest_buf, dest_pitch, wi dth, height, pSrcBitmap, src_left, src_top); 850 return _ConvertBuffer_8bppMask2Gray(dest_buf, dest_pitch, wi dth, height, pSrcBitmap, src_left, src_top);
851 } else if ((src_format & 0xff) >= 24) { 851 } else if ((src_format & 0xff) >= 24) {
852 return _ConvertBuffer_RgbOrCmyk2Gray(dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, pIccTransform); 852 return _ConvertBuffer_RgbOrCmyk2Gray(dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, pIccTransform);
853 } 853 }
854 return FALSE; 854 return false;
855 } 855 }
856 case FXDIB_8bppRgb: 856 case FXDIB_8bppRgb:
857 case FXDIB_8bppRgba: { 857 case FXDIB_8bppRgba: {
858 if ((src_format & 0xff) == 8 && pSrcBitmap->GetPalette() == NULL ) { 858 if ((src_format & 0xff) == 8 && pSrcBitmap->GetPalette() == NULL ) {
859 return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); 859 return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
860 } 860 }
861 d_pal = FX_Alloc(FX_DWORD, 256); 861 d_pal = FX_Alloc(FX_DWORD, 256);
862 if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) && pS rcBitmap->GetPalette()) { 862 if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) && pS rcBitmap->GetPalette()) {
863 return _ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, widt h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); 863 return _ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, widt h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
864 } else if ((src_format & 0xff) >= 24) { 864 } else if ((src_format & 0xff) >= 24) {
865 return _ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, widt h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); 865 return _ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, widt h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
866 } 866 }
867 return FALSE; 867 return false;
868 } 868 }
869 case FXDIB_Rgb: 869 case FXDIB_Rgb:
870 case FXDIB_Rgba: { 870 case FXDIB_Rgba: {
871 if ((src_format & 0xff) == 1) { 871 if ((src_format & 0xff) == 1) {
872 if (pSrcBitmap->GetPalette()) { 872 if (pSrcBitmap->GetPalette()) {
873 return _ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); 873 return _ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
874 } 874 }
875 return _ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, de st_pitch, width, height, pSrcBitmap, src_left, src_top); 875 return _ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, de st_pitch, width, height, pSrcBitmap, src_left, src_top);
876 } else if ((src_format & 0xff) == 8) { 876 } else if ((src_format & 0xff) == 8) {
877 if (pSrcBitmap->GetPalette()) { 877 if (pSrcBitmap->GetPalette()) {
878 return _ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); 878 return _ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
879 } 879 }
880 return _ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, de st_pitch, width, height, pSrcBitmap, src_left, src_top); 880 return _ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, de st_pitch, width, height, pSrcBitmap, src_left, src_top);
881 } else if ((src_format & 0xff) == 24) { 881 } else if ((src_format & 0xff) == 24) {
882 return _ConvertBuffer_24bppRgb2Rgb24(dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, pIccTransform); 882 return _ConvertBuffer_24bppRgb2Rgb24(dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, pIccTransform);
883 } else if ((src_format & 0xff) == 32) { 883 } else if ((src_format & 0xff) == 32) {
884 return _ConvertBuffer_32bppRgb2Rgb24(dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, pIccTransform); 884 return _ConvertBuffer_32bppRgb2Rgb24(dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, pIccTransform);
885 } 885 }
886 return FALSE; 886 return false;
887 } 887 }
888 case FXDIB_Argb: 888 case FXDIB_Argb:
889 case FXDIB_Rgb32: { 889 case FXDIB_Rgb32: {
890 if ((src_format & 0xff) == 1) { 890 if ((src_format & 0xff) == 1) {
891 if (pSrcBitmap->GetPalette()) { 891 if (pSrcBitmap->GetPalette()) {
892 return _ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); 892 return _ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
893 } 893 }
894 return _ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, de st_pitch, width, height, pSrcBitmap, src_left, src_top); 894 return _ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, de st_pitch, width, height, pSrcBitmap, src_left, src_top);
895 } else if ((src_format & 0xff) == 8) { 895 } else if ((src_format & 0xff) == 8) {
896 if (pSrcBitmap->GetPalette()) { 896 if (pSrcBitmap->GetPalette()) {
897 return _ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); 897 return _ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
898 } 898 }
899 return _ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, de st_pitch, width, height, pSrcBitmap, src_left, src_top); 899 return _ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, de st_pitch, width, height, pSrcBitmap, src_left, src_top);
900 } else if ((src_format & 0xff) >= 24) { 900 } else if ((src_format & 0xff) >= 24) {
901 if (src_format & 0x0400) { 901 if (src_format & 0x0400) {
902 return _ConvertBuffer_32bppCmyk2Rgb32(dest_buf, dest_pit ch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); 902 return _ConvertBuffer_32bppCmyk2Rgb32(dest_buf, dest_pit ch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
903 } 903 }
904 return _ConvertBuffer_Rgb2Rgb32(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); 904 return _ConvertBuffer_Rgb2Rgb32(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
905 } 905 }
906 return FALSE; 906 return false;
907 } 907 }
908 default: 908 default:
909 return FALSE; 909 return false;
910 } 910 }
911 return FALSE; 911 return false;
912 } 912 }
913 CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format, const FX_REC T* pClip, void* pIccTransform) const 913 CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format, const FX_REC T* pClip, void* pIccTransform) const
914 { 914 {
915 if(dest_format == GetFormat() && pIccTransform == NULL) { 915 if(dest_format == GetFormat() && pIccTransform == NULL) {
916 return Clone(pClip); 916 return Clone(pClip);
917 } 917 }
918 if (pClip) { 918 if (pClip) {
919 CFX_DIBitmap* pClone = Clone(pClip); 919 CFX_DIBitmap* pClone = Clone(pClip);
920 if (pClone == NULL) { 920 if (pClone == NULL) {
921 return NULL; 921 return NULL;
922 } 922 }
923 if(!pClone->ConvertFormat(dest_format, pIccTransform)) { 923 if(!pClone->ConvertFormat(dest_format, pIccTransform)) {
924 delete pClone; 924 delete pClone;
925 return NULL; 925 return NULL;
926 } 926 }
927 return pClone; 927 return pClone;
928 } 928 }
929 CFX_DIBitmap* pClone = new CFX_DIBitmap; 929 CFX_DIBitmap* pClone = new CFX_DIBitmap;
930 if(!pClone->Create(m_Width, m_Height, dest_format)) { 930 if(!pClone->Create(m_Width, m_Height, dest_format)) {
931 delete pClone; 931 delete pClone;
932 return NULL; 932 return NULL;
933 } 933 }
934 FX_BOOL ret = TRUE; 934 bool ret = true;
935 CFX_DIBitmap* pSrcAlpha = NULL; 935 CFX_DIBitmap* pSrcAlpha = NULL;
936 if (m_AlphaFlag & 2) { 936 if (m_AlphaFlag & 2) {
937 pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask; 937 pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask;
938 if (pSrcAlpha == NULL) { 938 if (pSrcAlpha == NULL) {
939 delete pClone; 939 delete pClone;
940 return NULL; 940 return NULL;
941 } 941 }
942 } 942 }
943 if (dest_format & 0x0200) { 943 if (dest_format & 0x0200) {
944 if (dest_format == FXDIB_Argb) 944 if (dest_format == FXDIB_Argb)
(...skipping 21 matching lines...) Expand all
966 delete pClone; 966 delete pClone;
967 return NULL; 967 return NULL;
968 } 968 }
969 if (pal_8bpp) { 969 if (pal_8bpp) {
970 pClone->CopyPalette(pal_8bpp); 970 pClone->CopyPalette(pal_8bpp);
971 FX_Free(pal_8bpp); 971 FX_Free(pal_8bpp);
972 pal_8bpp = NULL; 972 pal_8bpp = NULL;
973 } 973 }
974 return pClone; 974 return pClone;
975 } 975 }
976 FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format, void* pIccTransfor m) 976 bool CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format, void* pIccTransform)
977 { 977 {
978 FXDIB_Format src_format = GetFormat(); 978 FXDIB_Format src_format = GetFormat();
979 if (dest_format == src_format && pIccTransform == NULL) { 979 if (dest_format == src_format && pIccTransform == NULL) {
980 return TRUE; 980 return true;
981 } 981 }
982 if (dest_format == FXDIB_8bppMask && src_format == FXDIB_8bppRgb && m_pPalet te == NULL) { 982 if (dest_format == FXDIB_8bppMask && src_format == FXDIB_8bppRgb && m_pPalet te == NULL) {
983 m_AlphaFlag = 1; 983 m_AlphaFlag = 1;
984 return TRUE; 984 return true;
985 } 985 }
986 if (dest_format == FXDIB_Argb && src_format == FXDIB_Rgb32 && pIccTransform == NULL) { 986 if (dest_format == FXDIB_Argb && src_format == FXDIB_Rgb32 && pIccTransform == NULL) {
987 m_AlphaFlag = 2; 987 m_AlphaFlag = 2;
988 for (int row = 0; row < m_Height; row ++) { 988 for (int row = 0; row < m_Height; row ++) {
989 uint8_t* scanline = m_pBuffer + row * m_Pitch + 3; 989 uint8_t* scanline = m_pBuffer + row * m_Pitch + 3;
990 for (int col = 0; col < m_Width; col ++) { 990 for (int col = 0; col < m_Width; col ++) {
991 *scanline = 0xff; 991 *scanline = 0xff;
992 scanline += 4; 992 scanline += 4;
993 } 993 }
994 } 994 }
995 return TRUE; 995 return true;
996 } 996 }
997 int dest_bpp = dest_format & 0xff; 997 int dest_bpp = dest_format & 0xff;
998 int dest_pitch = (dest_bpp * m_Width + 31) / 32 * 4; 998 int dest_pitch = (dest_bpp * m_Width + 31) / 32 * 4;
999 uint8_t* dest_buf = FX_TryAlloc(uint8_t, dest_pitch * m_Height + 4); 999 uint8_t* dest_buf = FX_TryAlloc(uint8_t, dest_pitch * m_Height + 4);
1000 if (dest_buf == NULL) { 1000 if (dest_buf == NULL) {
1001 return FALSE; 1001 return false;
1002 } 1002 }
1003 CFX_DIBitmap* pAlphaMask = NULL; 1003 CFX_DIBitmap* pAlphaMask = NULL;
1004 if (dest_format == FXDIB_Argb) { 1004 if (dest_format == FXDIB_Argb) {
1005 FXSYS_memset(dest_buf, 0xff, dest_pitch * m_Height + 4); 1005 FXSYS_memset(dest_buf, 0xff, dest_pitch * m_Height + 4);
1006 if (m_pAlphaMask) { 1006 if (m_pAlphaMask) {
1007 for (int row = 0; row < m_Height; row ++) { 1007 for (int row = 0; row < m_Height; row ++) {
1008 uint8_t* pDstScanline = dest_buf + row * dest_pitch + 3; 1008 uint8_t* pDstScanline = dest_buf + row * dest_pitch + 3;
1009 const uint8_t* pSrcScanline = m_pAlphaMask->GetScanline(row); 1009 const uint8_t* pSrcScanline = m_pAlphaMask->GetScanline(row);
1010 for (int col = 0; col < m_Width; col ++) { 1010 for (int col = 0; col < m_Width; col ++) {
1011 *pDstScanline = *pSrcScanline++; 1011 *pDstScanline = *pSrcScanline++;
1012 pDstScanline += 4; 1012 pDstScanline += 4;
1013 } 1013 }
1014 } 1014 }
1015 } 1015 }
1016 } else if (dest_format & 0x0200) { 1016 } else if (dest_format & 0x0200) {
1017 if (src_format == FXDIB_Argb) { 1017 if (src_format == FXDIB_Argb) {
1018 pAlphaMask = GetAlphaMask(); 1018 pAlphaMask = GetAlphaMask();
1019 if (pAlphaMask == NULL) { 1019 if (pAlphaMask == NULL) {
1020 FX_Free(dest_buf); 1020 FX_Free(dest_buf);
1021 return FALSE; 1021 return false;
1022 } 1022 }
1023 } else { 1023 } else {
1024 if (m_pAlphaMask == NULL) { 1024 if (m_pAlphaMask == NULL) {
1025 if (!BuildAlphaMask()) { 1025 if (!BuildAlphaMask()) {
1026 FX_Free(dest_buf); 1026 FX_Free(dest_buf);
1027 return FALSE; 1027 return false;
1028 } 1028 }
1029 pAlphaMask = m_pAlphaMask; 1029 pAlphaMask = m_pAlphaMask;
1030 m_pAlphaMask = NULL; 1030 m_pAlphaMask = NULL;
1031 } else { 1031 } else {
1032 pAlphaMask = m_pAlphaMask; 1032 pAlphaMask = m_pAlphaMask;
1033 } 1033 }
1034 } 1034 }
1035 } 1035 }
1036 FX_BOOL ret = FALSE; 1036 bool ret = false;
1037 FX_DWORD* pal_8bpp = NULL; 1037 FX_DWORD* pal_8bpp = NULL;
1038 ret = ConvertBuffer(dest_format, dest_buf, dest_pitch, m_Width, m_Height, th is, 0, 0, pal_8bpp, pIccTransform); 1038 ret = ConvertBuffer(dest_format, dest_buf, dest_pitch, m_Width, m_Height, th is, 0, 0, pal_8bpp, pIccTransform);
1039 if (!ret) { 1039 if (!ret) {
1040 if (pal_8bpp) { 1040 if (pal_8bpp) {
1041 FX_Free(pal_8bpp); 1041 FX_Free(pal_8bpp);
1042 } 1042 }
1043 if (pAlphaMask != m_pAlphaMask) { 1043 if (pAlphaMask != m_pAlphaMask) {
1044 delete pAlphaMask; 1044 delete pAlphaMask;
1045 } 1045 }
1046 if (dest_buf) { 1046 if (dest_buf) {
1047 FX_Free(dest_buf); 1047 FX_Free(dest_buf);
1048 } 1048 }
1049 return FALSE; 1049 return false;
1050 } 1050 }
1051 if (m_pAlphaMask && pAlphaMask != m_pAlphaMask) { 1051 if (m_pAlphaMask && pAlphaMask != m_pAlphaMask) {
1052 delete m_pAlphaMask; 1052 delete m_pAlphaMask;
1053 } 1053 }
1054 m_pAlphaMask = pAlphaMask; 1054 m_pAlphaMask = pAlphaMask;
1055 if (m_pPalette) { 1055 if (m_pPalette) {
1056 FX_Free(m_pPalette); 1056 FX_Free(m_pPalette);
1057 } 1057 }
1058 m_pPalette = pal_8bpp; 1058 m_pPalette = pal_8bpp;
1059 if (!m_bExtBuf) { 1059 if (!m_bExtBuf) {
1060 FX_Free(m_pBuffer); 1060 FX_Free(m_pBuffer);
1061 } 1061 }
1062 m_bExtBuf = FALSE; 1062 m_bExtBuf = false;
1063 m_pBuffer = dest_buf; 1063 m_pBuffer = dest_buf;
1064 m_bpp = (uint8_t)dest_format; 1064 m_bpp = (uint8_t)dest_format;
1065 m_AlphaFlag = (uint8_t)(dest_format >> 8); 1065 m_AlphaFlag = (uint8_t)(dest_format >> 8);
1066 m_Pitch = dest_pitch; 1066 m_Pitch = dest_pitch;
1067 return TRUE; 1067 return true;
1068 } 1068 }
OLDNEW
« no previous file with comments | « core/src/fxge/dib/fx_dib_composite.cpp ('k') | core/src/fxge/dib/fx_dib_engine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698