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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(FX_LPBYTE dest_buf, int dest_pitch, int wid
th, int height, | 282 FX_BOOL _ConvertBuffer_1bppMask2Gray(uint8_t* dest_buf, int dest_pitch, int widt
h, 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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 289 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
290 FXSYS_memset8(dest_scan, reset_gray, width); | 290 FXSYS_memset8(dest_scan, reset_gray, width); |
291 FX_LPCBYTE 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(FX_LPBYTE dest_buf, int dest_pitch, int wid
th, int height, | 301 FX_BOOL _ConvertBuffer_8bppMask2Gray(uint8_t* dest_buf, int dest_pitch, int widt
h, 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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 305 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
306 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left; | 306 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l
eft; |
307 FXSYS_memcpy32(dest_scan, src_scan, width); | 307 FXSYS_memcpy32(dest_scan, src_scan, width); |
308 } | 308 } |
309 return TRUE; | 309 return TRUE; |
310 } | 310 } |
311 FX_BOOL _ConvertBuffer_1bppPlt2Gray(FX_LPBYTE dest_buf, int dest_pitch, int widt
h, int height, | 311 FX_BOOL _ConvertBuffer_1bppPlt2Gray(uint8_t* dest_buf, int dest_pitch, int width
, int 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 { |
322 FX_LPBYTE bgr_ptr = (FX_LPBYTE)plt; | 322 uint8_t* bgr_ptr = (uint8_t*)plt; |
323 bgr_ptr[0] = FXARGB_B(src_plt[0]); | 323 bgr_ptr[0] = FXARGB_B(src_plt[0]); |
324 bgr_ptr[1] = FXARGB_G(src_plt[0]); | 324 bgr_ptr[1] = FXARGB_G(src_plt[0]); |
325 bgr_ptr[2] = FXARGB_R(src_plt[0]); | 325 bgr_ptr[2] = FXARGB_R(src_plt[0]); |
326 bgr_ptr[3] = FXARGB_B(src_plt[1]); | 326 bgr_ptr[3] = FXARGB_B(src_plt[1]); |
327 bgr_ptr[4] = FXARGB_G(src_plt[1]); | 327 bgr_ptr[4] = FXARGB_G(src_plt[1]); |
328 bgr_ptr[5] = FXARGB_R(src_plt[1]); | 328 bgr_ptr[5] = FXARGB_R(src_plt[1]); |
329 } | 329 } |
330 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); | 330 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); |
331 pIccModule->TranslateScanline(pIccTransform, gray, (FX_LPCBYTE)plt, 2); | 331 pIccModule->TranslateScanline(pIccTransform, gray, (const uint8_t*)plt,
2); |
332 } else { | 332 } else { |
333 uint8_t reset_r, reset_g, reset_b, | 333 uint8_t reset_r, reset_g, reset_b, |
334 set_r, set_g, set_b; | 334 set_r, set_g, set_b; |
335 if (pSrcBitmap->IsCmykImage()) { | 335 if (pSrcBitmap->IsCmykImage()) { |
336 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[0]), FXSYS_GetMValue(src_
plt[0]), FXSYS_GetYValue(src_plt[0]), FXSYS_GetKValue(src_plt[0]), | 336 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[0]), FXSYS_GetMValue(src_
plt[0]), FXSYS_GetYValue(src_plt[0]), FXSYS_GetKValue(src_plt[0]), |
337 reset_r, reset_g, reset_b); | 337 reset_r, reset_g, reset_b); |
338 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[1]), FXSYS_GetMValue(src_
plt[1]), FXSYS_GetYValue(src_plt[1]), FXSYS_GetKValue(src_plt[1]), | 338 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[1]), FXSYS_GetMValue(src_
plt[1]), FXSYS_GetYValue(src_plt[1]), FXSYS_GetKValue(src_plt[1]), |
339 set_r, set_g, set_b); | 339 set_r, set_g, set_b); |
340 } else { | 340 } else { |
341 reset_r = FXARGB_R(src_plt[0]); | 341 reset_r = FXARGB_R(src_plt[0]); |
342 reset_g = FXARGB_G(src_plt[0]); | 342 reset_g = FXARGB_G(src_plt[0]); |
343 reset_b = FXARGB_B(src_plt[0]); | 343 reset_b = FXARGB_B(src_plt[0]); |
344 set_r = FXARGB_R(src_plt[1]); | 344 set_r = FXARGB_R(src_plt[1]); |
345 set_g = FXARGB_G(src_plt[1]); | 345 set_g = FXARGB_G(src_plt[1]); |
346 set_b = FXARGB_B(src_plt[1]); | 346 set_b = FXARGB_B(src_plt[1]); |
347 } | 347 } |
348 gray[0] = FXRGB2GRAY(reset_r, reset_g, reset_b); | 348 gray[0] = FXRGB2GRAY(reset_r, reset_g, reset_b); |
349 gray[1] = FXRGB2GRAY(set_r, set_g, set_b); | 349 gray[1] = FXRGB2GRAY(set_r, set_g, set_b); |
350 } | 350 } |
351 for (int row = 0; row < height; row ++) { | 351 for (int row = 0; row < height; row ++) { |
352 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 352 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
353 FXSYS_memset8(dest_scan, gray[0], width); | 353 FXSYS_memset8(dest_scan, gray[0], width); |
354 FX_LPCBYTE 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(FX_LPBYTE dest_buf, int dest_pitch, int widt
h, int height, | 364 FX_BOOL _ConvertBuffer_8bppPlt2Gray(uint8_t* dest_buf, int dest_pitch, int width
, int 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 } |
375 } else { | 375 } else { |
376 FX_LPBYTE bgr_ptr = (FX_LPBYTE)plt; | 376 uint8_t* bgr_ptr = (uint8_t*)plt; |
377 for (int i = 0; i < 256; i ++) { | 377 for (int i = 0; i < 256; i ++) { |
378 *bgr_ptr++ = FXARGB_B(src_plt[i]); | 378 *bgr_ptr++ = FXARGB_B(src_plt[i]); |
379 *bgr_ptr++ = FXARGB_G(src_plt[i]); | 379 *bgr_ptr++ = FXARGB_G(src_plt[i]); |
380 *bgr_ptr++ = FXARGB_R(src_plt[i]); | 380 *bgr_ptr++ = FXARGB_R(src_plt[i]); |
381 } | 381 } |
382 } | 382 } |
383 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); | 383 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); |
384 pIccModule->TranslateScanline(pIccTransform, gray, (FX_LPCBYTE)plt, 256)
; | 384 pIccModule->TranslateScanline(pIccTransform, gray, (const uint8_t*)plt,
256); |
385 } else { | 385 } else { |
386 if (pSrcBitmap->IsCmykImage()) { | 386 if (pSrcBitmap->IsCmykImage()) { |
387 uint8_t r, g, b; | 387 uint8_t r, g, b; |
388 for (int i = 0; i < 256; i ++) { | 388 for (int i = 0; i < 256; i ++) { |
389 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(
src_plt[i]), FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]), | 389 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(
src_plt[i]), FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]), |
390 r, g, b); | 390 r, g, b); |
391 gray[i] = FXRGB2GRAY(r, g, b); | 391 gray[i] = FXRGB2GRAY(r, g, b); |
392 } | 392 } |
393 } else | 393 } else |
394 for (int i = 0; i < 256; i ++) { | 394 for (int i = 0; i < 256; i ++) { |
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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 399 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
400 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left; | 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(FX_LPBYTE dest_buf, int dest_pitch, int wi
dth, int height, | 407 FX_BOOL _ConvertBuffer_RgbOrCmyk2Gray(uint8_t* dest_buf, int dest_pitch, int wid
th, 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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 415 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
416 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + s
rc_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); |
418 } | 418 } |
419 } else { | 419 } else { |
420 for (int row = 0; row < height; row ++) { | 420 for (int row = 0; row < height; row ++) { |
421 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 421 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
422 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + s
rc_left * 4; | 422 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row)
+ src_left * 4; |
423 for (int col = 0; col < width; col ++) { | 423 for (int col = 0; col < width; col ++) { |
424 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_
scan, 1); | 424 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_
scan, 1); |
425 dest_scan++; | 425 dest_scan++; |
426 src_scan += 4; | 426 src_scan += 4; |
427 } | 427 } |
428 } | 428 } |
429 } | 429 } |
430 } else { | 430 } else { |
431 if (pSrcBitmap->IsCmykImage()) { | 431 if (pSrcBitmap->IsCmykImage()) { |
432 for (int row = 0; row < height; row ++) { | 432 for (int row = 0; row < height; row ++) { |
433 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 433 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
434 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + s
rc_left * 4; | 434 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row)
+ src_left * 4; |
435 for (int col = 0; col < width; col ++) { | 435 for (int col = 0; col < width; col ++) { |
436 uint8_t r, g, b; | 436 uint8_t r, g, b; |
437 AdobeCMYK_to_sRGB1(FXSYS_GetCValue((FX_DWORD)src_scan[0]), F
XSYS_GetMValue((FX_DWORD)src_scan[1]), FXSYS_GetYValue((FX_DWORD)src_scan[2]), F
XSYS_GetKValue((FX_DWORD)src_scan[3]), | 437 AdobeCMYK_to_sRGB1(FXSYS_GetCValue((FX_DWORD)src_scan[0]), F
XSYS_GetMValue((FX_DWORD)src_scan[1]), FXSYS_GetYValue((FX_DWORD)src_scan[2]), F
XSYS_GetKValue((FX_DWORD)src_scan[3]), |
438 r, g, b); | 438 r, g, b); |
439 *dest_scan++ = FXRGB2GRAY(r, g, b); | 439 *dest_scan++ = FXRGB2GRAY(r, g, b); |
440 src_scan += 4; | 440 src_scan += 4; |
441 } | 441 } |
442 } | 442 } |
443 } else { | 443 } else { |
444 for (int row = 0; row < height; row ++) { | 444 for (int row = 0; row < height; row ++) { |
445 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 445 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
446 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + s
rc_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(FX_LPBYTE dest_buf, int dest_pitch, int wid
th, 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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 461 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
462 FXSYS_memset32(dest_scan, 0, width); | 462 FXSYS_memset32(dest_scan, 0, width); |
463 FX_LPCBYTE 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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 473 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
474 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l
eft; | 474 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s
rc_left; |
475 FXSYS_memcpy32(dest_scan, src_scan, width); | 475 FXSYS_memcpy32(dest_scan, src_scan, width); |
476 } | 476 } |
477 } | 477 } |
478 } | 478 } |
479 FX_BOOL _ConvertBuffer_Plt2PltRgb8(FX_LPBYTE dest_buf, int dest_pitch, int width
, int height, | 479 FX_BOOL _ConvertBuffer_Plt2PltRgb8(uint8_t* dest_buf, int dest_pitch, int width,
int 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 FX_LPBYTE bgr_ptr = (FX_LPBYTE)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 ++) { |
490 plt[i] = FXCMYK_TODIB(src_plt[i]); | 490 plt[i] = FXCMYK_TODIB(src_plt[i]); |
491 } | 491 } |
492 } else { | 492 } else { |
493 for (int i = 0; i < plt_size; i ++) { | 493 for (int i = 0; i < plt_size; i ++) { |
494 *bgr_ptr++ = FXARGB_B(src_plt[i]); | 494 *bgr_ptr++ = FXARGB_B(src_plt[i]); |
495 *bgr_ptr++ = FXARGB_G(src_plt[i]); | 495 *bgr_ptr++ = FXARGB_G(src_plt[i]); |
496 *bgr_ptr++ = FXARGB_R(src_plt[i]); | 496 *bgr_ptr++ = FXARGB_R(src_plt[i]); |
497 } | 497 } |
498 bgr_ptr = (FX_LPBYTE)plt; | 498 bgr_ptr = (uint8_t*)plt; |
499 } | 499 } |
500 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); | 500 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); |
501 pIccModule->TranslateScanline(pIccTransform, (FX_LPBYTE)plt, (FX_LPCBYTE
)plt, plt_size); | 501 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)plt, (const uint8
_t*)plt, plt_size); |
502 for (int i = 0; i < plt_size; i ++) { | 502 for (int i = 0; i < plt_size; i ++) { |
503 dst_plt[i] = FXARGB_MAKE(0xff, bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]); | 503 dst_plt[i] = FXARGB_MAKE(0xff, bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]); |
504 bgr_ptr += 3; | 504 bgr_ptr += 3; |
505 } | 505 } |
506 } else { | 506 } else { |
507 if (pSrcBitmap->IsCmykImage()) { | 507 if (pSrcBitmap->IsCmykImage()) { |
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_memcpy32(dst_plt, src_plt, plt_size * 4); | 515 FXSYS_memcpy32(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(FX_LPBYTE dest_buf, int de
st_pitch, int width, int height, | 520 inline FX_BOOL _ConvertBuffer_Rgb2PltRgb8_NoTransform(uint8_t* dest_buf, int des
t_pitch, 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; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_memcpy32(dst_plt, pPalette, sizeof(FX_DWORD) * 256); | 573 FXSYS_memcpy32(dst_plt, pPalette, sizeof(FX_DWORD) * 256); |
574 return TRUE; | 574 return TRUE; |
575 } | 575 } |
576 FX_BOOL _ConvertBuffer_Rgb2PltRgb8(FX_LPBYTE dest_buf, int dest_pitch, int width
, int height, | 576 FX_BOOL _ConvertBuffer_Rgb2PltRgb8(uint8_t* dest_buf, int dest_pitch, int width,
int 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 FX_BOOL ret = _ConvertBuffer_Rgb2PltRgb8_NoTransform(dest_buf, dest_pitch, w
idth, 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, (FX_LPBYTE)&plt_entry,
(FX_LPCBYTE)&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, FX_LPBYTE dest_buf,
int dest_pitch, int width, int height, | 591 FX_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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 599 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
600 FX_LPCBYTE 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, FX_LPBYTE dest_buf,
int dest_pitch, int width, int height, | 616 FX_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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 621 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
622 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left; | 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, FX_LPBYTE dest_buf,
int dest_pitch, int width, int height, | 634 FX_BOOL _ConvertBuffer_1bppPlt2Rgb(FXDIB_Format dst_format, uint8_t* dest_buf, i
nt 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 FX_LPBYTE bgr_ptr = (FX_LPBYTE)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 { |
645 bgr_ptr[0] = FXARGB_B(src_plt[0]); | 645 bgr_ptr[0] = FXARGB_B(src_plt[0]); |
646 bgr_ptr[1] = FXARGB_G(src_plt[0]); | 646 bgr_ptr[1] = FXARGB_G(src_plt[0]); |
647 bgr_ptr[2] = FXARGB_R(src_plt[0]); | 647 bgr_ptr[2] = FXARGB_R(src_plt[0]); |
648 bgr_ptr[3] = FXARGB_B(src_plt[1]); | 648 bgr_ptr[3] = FXARGB_B(src_plt[1]); |
649 bgr_ptr[4] = FXARGB_G(src_plt[1]); | 649 bgr_ptr[4] = FXARGB_G(src_plt[1]); |
650 bgr_ptr[5] = FXARGB_R(src_plt[1]); | 650 bgr_ptr[5] = FXARGB_R(src_plt[1]); |
651 } | 651 } |
652 if (pIccTransform) { | 652 if (pIccTransform) { |
653 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); | 653 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); |
654 pIccModule->TranslateScanline(pIccTransform, (FX_LPBYTE)plt, (FX_LPCBYTE
)plt, 2); | 654 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)plt, (const uint8
_t*)plt, 2); |
655 } else { | 655 } else { |
656 if (pSrcBitmap->IsCmykImage()) { | 656 if (pSrcBitmap->IsCmykImage()) { |
657 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[0]), FXSYS_GetMValue(src_
plt[0]), FXSYS_GetYValue(src_plt[0]), FXSYS_GetKValue(src_plt[0]), | 657 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[0]), FXSYS_GetMValue(src_
plt[0]), FXSYS_GetYValue(src_plt[0]), FXSYS_GetKValue(src_plt[0]), |
658 bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]); | 658 bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]); |
659 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[1]), FXSYS_GetMValue(src_
plt[1]), FXSYS_GetYValue(src_plt[1]), FXSYS_GetKValue(src_plt[1]), | 659 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[1]), FXSYS_GetMValue(src_
plt[1]), FXSYS_GetYValue(src_plt[1]), FXSYS_GetKValue(src_plt[1]), |
660 bgr_ptr[5], bgr_ptr[4], bgr_ptr[3]); | 660 bgr_ptr[5], bgr_ptr[4], bgr_ptr[3]); |
661 } | 661 } |
662 } | 662 } |
663 for (int row = 0; row < height; row ++) { | 663 for (int row = 0; row < height; row ++) { |
664 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 664 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
665 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row); | 665 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); |
666 for (int col = src_left; col < src_left + width; col ++) { | 666 for (int col = src_left; col < src_left + width; col ++) { |
667 if (src_scan[col / 8] & (1 << (7 - col % 8))) { | 667 if (src_scan[col / 8] & (1 << (7 - col % 8))) { |
668 *dest_scan++ = bgr_ptr[3]; | 668 *dest_scan++ = bgr_ptr[3]; |
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, FX_LPBYTE dest_buf,
int dest_pitch, int width, int height, | 681 FX_BOOL _ConvertBuffer_8bppPlt2Rgb(FXDIB_Format dst_format, uint8_t* dest_buf, i
nt 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 FX_LPBYTE bgr_ptr = (FX_LPBYTE)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]); |
692 *bgr_ptr++ = FXARGB_R(src_plt[i]); | 692 *bgr_ptr++ = FXARGB_R(src_plt[i]); |
693 } | 693 } |
694 bgr_ptr = (FX_LPBYTE)plt; | 694 bgr_ptr = (uint8_t*)plt; |
695 } | 695 } |
696 if (pIccTransform) { | 696 if (pIccTransform) { |
697 if (pSrcBitmap->IsCmykImage()) { | 697 if (pSrcBitmap->IsCmykImage()) { |
698 for (int i = 0; i < 256; i++) { | 698 for (int i = 0; i < 256; i++) { |
699 plt[i] = FXCMYK_TODIB(src_plt[i]); | 699 plt[i] = FXCMYK_TODIB(src_plt[i]); |
700 } | 700 } |
701 } | 701 } |
702 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); | 702 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); |
703 pIccModule->TranslateScanline(pIccTransform, (FX_LPBYTE)plt, (FX_LPCBYTE
)plt, 256); | 703 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)plt, (const uint8
_t*)plt, 256); |
704 } else { | 704 } else { |
705 if (pSrcBitmap->IsCmykImage()) { | 705 if (pSrcBitmap->IsCmykImage()) { |
706 for (int i = 0; i < 256; i++) { | 706 for (int i = 0; i < 256; i++) { |
707 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(
src_plt[i]), FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]), | 707 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(
src_plt[i]), FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]), |
708 bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]); | 708 bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]); |
709 bgr_ptr += 3; | 709 bgr_ptr += 3; |
710 } | 710 } |
711 bgr_ptr = (FX_LPBYTE)plt; | 711 bgr_ptr = (uint8_t*)plt; |
712 } | 712 } |
713 } | 713 } |
714 for (int row = 0; row < height; row ++) { | 714 for (int row = 0; row < height; row ++) { |
715 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 715 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
716 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left; | 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 FX_LPBYTE 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(FX_LPBYTE dest_buf, int dest_pitch, int wi
dth, int height, | 727 FX_BOOL _ConvertBuffer_24bppRgb2Rgb24(uint8_t* dest_buf, int dest_pitch, int wid
th, 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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 733 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
734 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l
eft * 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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 739 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
740 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l
eft * 3; | 740 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + s
rc_left * 3; |
741 FXSYS_memcpy32(dest_scan, src_scan, width * 3); | 741 FXSYS_memcpy32(dest_scan, src_scan, width * 3); |
742 } | 742 } |
743 } | 743 } |
744 return TRUE; | 744 return TRUE; |
745 } | 745 } |
746 FX_BOOL _ConvertBuffer_32bppRgb2Rgb24(FX_LPBYTE dest_buf, int dest_pitch, int wi
dth, int height, | 746 FX_BOOL _ConvertBuffer_32bppRgb2Rgb24(uint8_t* dest_buf, int dest_pitch, int wid
th, 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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 750 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
751 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left
* 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 FX_LPBYTE 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(FX_LPBYTE dest_buf, int dest_pitch, int width,
int height, | 768 FX_BOOL _ConvertBuffer_Rgb2Rgb32(uint8_t* dest_buf, int dest_pitch, int width, i
nt 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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 775 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
776 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l
eft * 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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 785 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
786 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l
eft * 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(FX_LPBYTE dest_buf, int dest_pitch, int w
idth, int height, | 798 FX_BOOL _ConvertBuffer_32bppCmyk2Rgb32(uint8_t* dest_buf, int dest_pitch, int wi
dth, 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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 804 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
805 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l
eft * 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 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 814 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
815 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + src_l
eft * 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, FX_LPBYTE dest_buf, int dest_pit
ch, int width, int height, | 826 FX_BOOL ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitc
h, 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: |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 FX_LPBYTE 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 FX_LPBYTE 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_memset8(dest_buf, 0xff, dest_pitch * m_Height + 4); | 1005 FXSYS_memset8(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 FX_LPBYTE pDstScanline = dest_buf + row * dest_pitch + 3; | 1008 uint8_t* pDstScanline = dest_buf + row * dest_pitch + 3; |
1009 FX_LPCBYTE 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) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |