OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../../include/fxge/fx_dib.h" | 7 #include "../../../include/fxge/fx_dib.h" |
8 #include "../../../include/fxge/fx_ge.h" | 8 #include "../../../include/fxge/fx_ge.h" |
9 #include "../../../include/fxcodec/fx_codec.h" | 9 #include "../../../include/fxcodec/fx_codec.h" |
10 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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 } | 846 } |
847 if ((src_format & 0xff) == 8) { | 847 if ((src_format & 0xff) == 8) { |
848 if (pSrcBitmap->GetPalette()) { | 848 if (pSrcBitmap->GetPalette()) { |
849 return _ConvertBuffer_8bppPlt2Gray(dest_buf, dest_pitch,
width, height, pSrcBitmap, src_left, src_top, pIccTransform); | 849 return _ConvertBuffer_8bppPlt2Gray(dest_buf, dest_pitch,
width, height, pSrcBitmap, src_left, src_top, pIccTransform); |
850 } | 850 } |
851 return _ConvertBuffer_8bppMask2Gray(dest_buf, dest_pitch, wi
dth, height, pSrcBitmap, src_left, src_top); | 851 return _ConvertBuffer_8bppMask2Gray(dest_buf, dest_pitch, wi
dth, height, pSrcBitmap, src_left, src_top); |
852 } | 852 } |
853 if ((src_format & 0xff) >= 24) { | 853 if ((src_format & 0xff) >= 24) { |
854 return _ConvertBuffer_RgbOrCmyk2Gray(dest_buf, dest_pitch, w
idth, height, pSrcBitmap, src_left, src_top, pIccTransform); | 854 return _ConvertBuffer_RgbOrCmyk2Gray(dest_buf, dest_pitch, w
idth, height, pSrcBitmap, src_left, src_top, pIccTransform); |
855 } | 855 } |
856 return FALSE; | 856 return false; |
857 } | 857 } |
858 case FXDIB_8bppRgb: | 858 case FXDIB_8bppRgb: |
859 case FXDIB_8bppRgba: { | 859 case FXDIB_8bppRgba: { |
860 if ((src_format & 0xff) == 8 && pSrcBitmap->GetPalette() == NULL
) { | 860 if ((src_format & 0xff) == 8 && pSrcBitmap->GetPalette() == NULL
) { |
861 return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, w
idth, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); | 861 return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, w
idth, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); |
862 } | 862 } |
863 d_pal = FX_Alloc(FX_DWORD, 256); | 863 d_pal = FX_Alloc(FX_DWORD, 256); |
864 if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) && pS
rcBitmap->GetPalette()) { | 864 if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) && pS
rcBitmap->GetPalette()) { |
865 return _ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, widt
h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); | 865 return _ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, widt
h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); |
866 } | 866 } |
867 if ((src_format & 0xff) >= 24) { | 867 if ((src_format & 0xff) >= 24) { |
868 return _ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, widt
h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); | 868 return _ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, widt
h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); |
869 } | 869 } |
870 return FALSE; | 870 return false; |
871 } | 871 } |
872 case FXDIB_Rgb: | 872 case FXDIB_Rgb: |
873 case FXDIB_Rgba: { | 873 case FXDIB_Rgba: { |
874 if ((src_format & 0xff) == 1) { | 874 if ((src_format & 0xff) == 1) { |
875 if (pSrcBitmap->GetPalette()) { | 875 if (pSrcBitmap->GetPalette()) { |
876 return _ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf,
dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); | 876 return _ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf,
dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); |
877 } | 877 } |
878 return _ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, de
st_pitch, width, height, pSrcBitmap, src_left, src_top); | 878 return _ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, de
st_pitch, width, height, pSrcBitmap, src_left, src_top); |
879 } | 879 } |
880 if ((src_format & 0xff) == 8) { | 880 if ((src_format & 0xff) == 8) { |
881 if (pSrcBitmap->GetPalette()) { | 881 if (pSrcBitmap->GetPalette()) { |
882 return _ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf,
dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); | 882 return _ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf,
dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); |
883 } | 883 } |
884 return _ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, de
st_pitch, width, height, pSrcBitmap, src_left, src_top); | 884 return _ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, de
st_pitch, width, height, pSrcBitmap, src_left, src_top); |
885 } | 885 } |
886 if ((src_format & 0xff) == 24) { | 886 if ((src_format & 0xff) == 24) { |
887 return _ConvertBuffer_24bppRgb2Rgb24(dest_buf, dest_pitch, w
idth, height, pSrcBitmap, src_left, src_top, pIccTransform); | 887 return _ConvertBuffer_24bppRgb2Rgb24(dest_buf, dest_pitch, w
idth, height, pSrcBitmap, src_left, src_top, pIccTransform); |
888 } | 888 } |
889 if ((src_format & 0xff) == 32) { | 889 if ((src_format & 0xff) == 32) { |
890 return _ConvertBuffer_32bppRgb2Rgb24(dest_buf, dest_pitch, w
idth, height, pSrcBitmap, src_left, src_top, pIccTransform); | 890 return _ConvertBuffer_32bppRgb2Rgb24(dest_buf, dest_pitch, w
idth, height, pSrcBitmap, src_left, src_top, pIccTransform); |
891 } | 891 } |
892 return FALSE; | 892 return false; |
893 } | 893 } |
894 case FXDIB_Argb: | 894 case FXDIB_Argb: |
895 case FXDIB_Rgb32: { | 895 case FXDIB_Rgb32: { |
896 if ((src_format & 0xff) == 1) { | 896 if ((src_format & 0xff) == 1) { |
897 if (pSrcBitmap->GetPalette()) { | 897 if (pSrcBitmap->GetPalette()) { |
898 return _ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf,
dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); | 898 return _ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf,
dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); |
899 } | 899 } |
900 return _ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, de
st_pitch, width, height, pSrcBitmap, src_left, src_top); | 900 return _ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, de
st_pitch, width, height, pSrcBitmap, src_left, src_top); |
901 } | 901 } |
902 if ((src_format & 0xff) == 8) { | 902 if ((src_format & 0xff) == 8) { |
903 if (pSrcBitmap->GetPalette()) { | 903 if (pSrcBitmap->GetPalette()) { |
904 return _ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf,
dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); | 904 return _ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf,
dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); |
905 } | 905 } |
906 return _ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, de
st_pitch, width, height, pSrcBitmap, src_left, src_top); | 906 return _ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, de
st_pitch, width, height, pSrcBitmap, src_left, src_top); |
907 } | 907 } |
908 if ((src_format & 0xff) >= 24) { | 908 if ((src_format & 0xff) >= 24) { |
909 if (src_format & 0x0400) { | 909 if (src_format & 0x0400) { |
910 return _ConvertBuffer_32bppCmyk2Rgb32(dest_buf, dest_pit
ch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); | 910 return _ConvertBuffer_32bppCmyk2Rgb32(dest_buf, dest_pit
ch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); |
911 } | 911 } |
912 return _ConvertBuffer_Rgb2Rgb32(dest_buf, dest_pitch, width,
height, pSrcBitmap, src_left, src_top, pIccTransform); | 912 return _ConvertBuffer_Rgb2Rgb32(dest_buf, dest_pitch, width,
height, pSrcBitmap, src_left, src_top, pIccTransform); |
913 } | 913 } |
914 return FALSE; | 914 return false; |
915 } | 915 } |
916 default: | 916 default: |
917 return FALSE; | 917 return false; |
918 } | 918 } |
919 return FALSE; | 919 return false; |
920 } | 920 } |
921 CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format, const FX_REC
T* pClip, void* pIccTransform) const | 921 CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format, const FX_REC
T* pClip, void* pIccTransform) const |
922 { | 922 { |
923 if(dest_format == GetFormat() && pIccTransform == NULL) { | 923 if(dest_format == GetFormat() && pIccTransform == NULL) { |
924 return Clone(pClip); | 924 return Clone(pClip); |
925 } | 925 } |
926 if (pClip) { | 926 if (pClip) { |
927 CFX_DIBitmap* pClone = Clone(pClip); | 927 CFX_DIBitmap* pClone = Clone(pClip); |
928 if (pClone == NULL) { | 928 if (pClone == NULL) { |
929 return NULL; | 929 return NULL; |
930 } | 930 } |
931 if(!pClone->ConvertFormat(dest_format, pIccTransform)) { | 931 if(!pClone->ConvertFormat(dest_format, pIccTransform)) { |
932 delete pClone; | 932 delete pClone; |
933 return NULL; | 933 return NULL; |
934 } | 934 } |
935 return pClone; | 935 return pClone; |
936 } | 936 } |
937 CFX_DIBitmap* pClone = new CFX_DIBitmap; | 937 CFX_DIBitmap* pClone = new CFX_DIBitmap; |
938 if(!pClone->Create(m_Width, m_Height, dest_format)) { | 938 if(!pClone->Create(m_Width, m_Height, dest_format)) { |
939 delete pClone; | 939 delete pClone; |
940 return NULL; | 940 return NULL; |
941 } | 941 } |
942 FX_BOOL ret = TRUE; | 942 bool ret = true; |
943 CFX_DIBitmap* pSrcAlpha = NULL; | 943 CFX_DIBitmap* pSrcAlpha = NULL; |
944 if (m_AlphaFlag & 2) { | 944 if (m_AlphaFlag & 2) { |
945 pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask; | 945 pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask; |
946 if (pSrcAlpha == NULL) { | 946 if (pSrcAlpha == NULL) { |
947 delete pClone; | 947 delete pClone; |
948 return NULL; | 948 return NULL; |
949 } | 949 } |
950 } | 950 } |
951 if (dest_format & 0x0200) { | 951 if (dest_format & 0x0200) { |
952 if (dest_format == FXDIB_Argb) | 952 if (dest_format == FXDIB_Argb) |
(...skipping 21 matching lines...) Expand all Loading... |
974 delete pClone; | 974 delete pClone; |
975 return NULL; | 975 return NULL; |
976 } | 976 } |
977 if (pal_8bpp) { | 977 if (pal_8bpp) { |
978 pClone->CopyPalette(pal_8bpp); | 978 pClone->CopyPalette(pal_8bpp); |
979 FX_Free(pal_8bpp); | 979 FX_Free(pal_8bpp); |
980 pal_8bpp = NULL; | 980 pal_8bpp = NULL; |
981 } | 981 } |
982 return pClone; | 982 return pClone; |
983 } | 983 } |
984 FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format, void* pIccTransfor
m) | 984 bool CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format, void* pIccTransform) |
985 { | 985 { |
986 FXDIB_Format src_format = GetFormat(); | 986 FXDIB_Format src_format = GetFormat(); |
987 if (dest_format == src_format && pIccTransform == NULL) { | 987 if (dest_format == src_format && pIccTransform == NULL) { |
988 return TRUE; | 988 return true; |
989 } | 989 } |
990 if (dest_format == FXDIB_8bppMask && src_format == FXDIB_8bppRgb && m_pPalet
te == NULL) { | 990 if (dest_format == FXDIB_8bppMask && src_format == FXDIB_8bppRgb && m_pPalet
te == NULL) { |
991 m_AlphaFlag = 1; | 991 m_AlphaFlag = 1; |
992 return TRUE; | 992 return true; |
993 } | 993 } |
994 if (dest_format == FXDIB_Argb && src_format == FXDIB_Rgb32 && pIccTransform
== NULL) { | 994 if (dest_format == FXDIB_Argb && src_format == FXDIB_Rgb32 && pIccTransform
== NULL) { |
995 m_AlphaFlag = 2; | 995 m_AlphaFlag = 2; |
996 for (int row = 0; row < m_Height; row ++) { | 996 for (int row = 0; row < m_Height; row ++) { |
997 uint8_t* scanline = m_pBuffer + row * m_Pitch + 3; | 997 uint8_t* scanline = m_pBuffer + row * m_Pitch + 3; |
998 for (int col = 0; col < m_Width; col ++) { | 998 for (int col = 0; col < m_Width; col ++) { |
999 *scanline = 0xff; | 999 *scanline = 0xff; |
1000 scanline += 4; | 1000 scanline += 4; |
1001 } | 1001 } |
1002 } | 1002 } |
1003 return TRUE; | 1003 return true; |
1004 } | 1004 } |
1005 int dest_bpp = dest_format & 0xff; | 1005 int dest_bpp = dest_format & 0xff; |
1006 int dest_pitch = (dest_bpp * m_Width + 31) / 32 * 4; | 1006 int dest_pitch = (dest_bpp * m_Width + 31) / 32 * 4; |
1007 uint8_t* dest_buf = FX_TryAlloc(uint8_t, dest_pitch * m_Height + 4); | 1007 uint8_t* dest_buf = FX_TryAlloc(uint8_t, dest_pitch * m_Height + 4); |
1008 if (dest_buf == NULL) { | 1008 if (dest_buf == NULL) { |
1009 return FALSE; | 1009 return false; |
1010 } | 1010 } |
1011 CFX_DIBitmap* pAlphaMask = NULL; | 1011 CFX_DIBitmap* pAlphaMask = NULL; |
1012 if (dest_format == FXDIB_Argb) { | 1012 if (dest_format == FXDIB_Argb) { |
1013 FXSYS_memset(dest_buf, 0xff, dest_pitch * m_Height + 4); | 1013 FXSYS_memset(dest_buf, 0xff, dest_pitch * m_Height + 4); |
1014 if (m_pAlphaMask) { | 1014 if (m_pAlphaMask) { |
1015 for (int row = 0; row < m_Height; row ++) { | 1015 for (int row = 0; row < m_Height; row ++) { |
1016 uint8_t* pDstScanline = dest_buf + row * dest_pitch + 3; | 1016 uint8_t* pDstScanline = dest_buf + row * dest_pitch + 3; |
1017 const uint8_t* pSrcScanline = m_pAlphaMask->GetScanline(row); | 1017 const uint8_t* pSrcScanline = m_pAlphaMask->GetScanline(row); |
1018 for (int col = 0; col < m_Width; col ++) { | 1018 for (int col = 0; col < m_Width; col ++) { |
1019 *pDstScanline = *pSrcScanline++; | 1019 *pDstScanline = *pSrcScanline++; |
1020 pDstScanline += 4; | 1020 pDstScanline += 4; |
1021 } | 1021 } |
1022 } | 1022 } |
1023 } | 1023 } |
1024 } else if (dest_format & 0x0200) { | 1024 } else if (dest_format & 0x0200) { |
1025 if (src_format == FXDIB_Argb) { | 1025 if (src_format == FXDIB_Argb) { |
1026 pAlphaMask = GetAlphaMask(); | 1026 pAlphaMask = GetAlphaMask(); |
1027 if (pAlphaMask == NULL) { | 1027 if (pAlphaMask == NULL) { |
1028 FX_Free(dest_buf); | 1028 FX_Free(dest_buf); |
1029 return FALSE; | 1029 return false; |
1030 } | 1030 } |
1031 } else { | 1031 } else { |
1032 if (m_pAlphaMask == NULL) { | 1032 if (m_pAlphaMask == NULL) { |
1033 if (!BuildAlphaMask()) { | 1033 if (!BuildAlphaMask()) { |
1034 FX_Free(dest_buf); | 1034 FX_Free(dest_buf); |
1035 return FALSE; | 1035 return false; |
1036 } | 1036 } |
1037 pAlphaMask = m_pAlphaMask; | 1037 pAlphaMask = m_pAlphaMask; |
1038 m_pAlphaMask = NULL; | 1038 m_pAlphaMask = NULL; |
1039 } else { | 1039 } else { |
1040 pAlphaMask = m_pAlphaMask; | 1040 pAlphaMask = m_pAlphaMask; |
1041 } | 1041 } |
1042 } | 1042 } |
1043 } | 1043 } |
1044 FX_BOOL ret = FALSE; | 1044 bool ret = false; |
1045 FX_DWORD* pal_8bpp = NULL; | 1045 FX_DWORD* pal_8bpp = NULL; |
1046 ret = ConvertBuffer(dest_format, dest_buf, dest_pitch, m_Width, m_Height, th
is, 0, 0, pal_8bpp, pIccTransform); | 1046 ret = ConvertBuffer(dest_format, dest_buf, dest_pitch, m_Width, m_Height, th
is, 0, 0, pal_8bpp, pIccTransform); |
1047 if (!ret) { | 1047 if (!ret) { |
1048 if (pal_8bpp) { | 1048 if (pal_8bpp) { |
1049 FX_Free(pal_8bpp); | 1049 FX_Free(pal_8bpp); |
1050 } | 1050 } |
1051 if (pAlphaMask != m_pAlphaMask) { | 1051 if (pAlphaMask != m_pAlphaMask) { |
1052 delete pAlphaMask; | 1052 delete pAlphaMask; |
1053 } | 1053 } |
1054 if (dest_buf) { | 1054 if (dest_buf) { |
1055 FX_Free(dest_buf); | 1055 FX_Free(dest_buf); |
1056 } | 1056 } |
1057 return FALSE; | 1057 return false; |
1058 } | 1058 } |
1059 if (m_pAlphaMask && pAlphaMask != m_pAlphaMask) { | 1059 if (m_pAlphaMask && pAlphaMask != m_pAlphaMask) { |
1060 delete m_pAlphaMask; | 1060 delete m_pAlphaMask; |
1061 } | 1061 } |
1062 m_pAlphaMask = pAlphaMask; | 1062 m_pAlphaMask = pAlphaMask; |
1063 if (m_pPalette) { | 1063 if (m_pPalette) { |
1064 FX_Free(m_pPalette); | 1064 FX_Free(m_pPalette); |
1065 } | 1065 } |
1066 m_pPalette = pal_8bpp; | 1066 m_pPalette = pal_8bpp; |
1067 if (!m_bExtBuf) { | 1067 if (!m_bExtBuf) { |
1068 FX_Free(m_pBuffer); | 1068 FX_Free(m_pBuffer); |
1069 } | 1069 } |
1070 m_bExtBuf = FALSE; | 1070 m_bExtBuf = false; |
1071 m_pBuffer = dest_buf; | 1071 m_pBuffer = dest_buf; |
1072 m_bpp = (uint8_t)dest_format; | 1072 m_bpp = (uint8_t)dest_format; |
1073 m_AlphaFlag = (uint8_t)(dest_format >> 8); | 1073 m_AlphaFlag = (uint8_t)(dest_format >> 8); |
1074 m_Pitch = dest_pitch; | 1074 m_Pitch = dest_pitch; |
1075 return TRUE; | 1075 return true; |
1076 } | 1076 } |
OLD | NEW |