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 "dib_int.h" | 9 #include "dib_int.h" |
10 #include <limits.h> | 10 #include <limits.h> |
(...skipping 10 matching lines...) Expand all Loading... |
21 base = (FX_FLOAT)(src_len); | 21 base = (FX_FLOAT)(src_len); |
22 } else { | 22 } else { |
23 base = 0; | 23 base = 0; |
24 } | 24 } |
25 int ext_size = flags & FXDIB_BICUBIC_INTERPOL ? 3 : 1; | 25 int ext_size = flags & FXDIB_BICUBIC_INTERPOL ? 3 : 1; |
26 m_ItemSize = sizeof(int) * 2 + (int)(sizeof(int) * (FXSYS_ceil(FXSYS_fabs((F
X_FLOAT)scale)) + ext_size)); | 26 m_ItemSize = sizeof(int) * 2 + (int)(sizeof(int) * (FXSYS_ceil(FXSYS_fabs((F
X_FLOAT)scale)) + ext_size)); |
27 m_DestMin = dest_min; | 27 m_DestMin = dest_min; |
28 if ((dest_max - dest_min) > (int)((1U << 30) - 4) / m_ItemSize) { | 28 if ((dest_max - dest_min) > (int)((1U << 30) - 4) / m_ItemSize) { |
29 return; | 29 return; |
30 } | 30 } |
31 m_pWeightTables = FX_TryAlloc(FX_BYTE, (dest_max - dest_min) * m_ItemSize +
4); | 31 m_pWeightTables = FX_TryAlloc(uint8_t, (dest_max - dest_min) * m_ItemSize +
4); |
32 if (m_pWeightTables == NULL) { | 32 if (m_pWeightTables == NULL) { |
33 return; | 33 return; |
34 } | 34 } |
35 if ((flags & FXDIB_NOSMOOTH) != 0 || FXSYS_fabs((FX_FLOAT)scale) < 1.0f) { | 35 if ((flags & FXDIB_NOSMOOTH) != 0 || FXSYS_fabs((FX_FLOAT)scale) < 1.0f) { |
36 for (int dest_pixel = dest_min; dest_pixel < dest_max; dest_pixel ++) { | 36 for (int dest_pixel = dest_min; dest_pixel < dest_max; dest_pixel ++) { |
37 PixelWeight& pixel_weights = *GetPixelWeight(dest_pixel); | 37 PixelWeight& pixel_weights = *GetPixelWeight(dest_pixel); |
38 double src_pos = dest_pixel * scale + scale / 2 + base; | 38 double src_pos = dest_pixel * scale + scale / 2 + base; |
39 if (flags & FXDIB_INTERPOL) { | 39 if (flags & FXDIB_INTERPOL) { |
40 pixel_weights.m_SrcStart = (int)FXSYS_floor((FX_FLOAT)src_pos -
1.0f / 2); | 40 pixel_weights.m_SrcStart = (int)FXSYS_floor((FX_FLOAT)src_pos -
1.0f / 2); |
41 pixel_weights.m_SrcEnd = (int)FXSYS_floor((FX_FLOAT)src_pos + 1.
0f / 2); | 41 pixel_weights.m_SrcEnd = (int)FXSYS_floor((FX_FLOAT)src_pos + 1.
0f / 2); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 FX_DWORD size = clip_rect.Width(); | 195 FX_DWORD size = clip_rect.Width(); |
196 if (size && m_DestBpp > (int)(INT_MAX / size)) { | 196 if (size && m_DestBpp > (int)(INT_MAX / size)) { |
197 return; | 197 return; |
198 } | 198 } |
199 size *= m_DestBpp; | 199 size *= m_DestBpp; |
200 if (size > INT_MAX - 31) { | 200 if (size > INT_MAX - 31) { |
201 return; | 201 return; |
202 } | 202 } |
203 size += 31; | 203 size += 31; |
204 size = size / 32 * 4; | 204 size = size / 32 * 4; |
205 m_pDestScanline = FX_TryAlloc(FX_BYTE, size); | 205 m_pDestScanline = FX_TryAlloc(uint8_t, size); |
206 if (m_pDestScanline == NULL) { | 206 if (m_pDestScanline == NULL) { |
207 return; | 207 return; |
208 } | 208 } |
209 if (dest_format == FXDIB_Rgb32) { | 209 if (dest_format == FXDIB_Rgb32) { |
210 FXSYS_memset8(m_pDestScanline, 255, size); | 210 FXSYS_memset8(m_pDestScanline, 255, size); |
211 } | 211 } |
212 m_InterPitch = (m_DestClip.Width() * m_DestBpp + 31) / 32 * 4; | 212 m_InterPitch = (m_DestClip.Width() * m_DestBpp + 31) / 32 * 4; |
213 m_ExtraMaskPitch = (m_DestClip.Width() * 8 + 31) / 32 * 4; | 213 m_ExtraMaskPitch = (m_DestClip.Width() * 8 + 31) / 32 * 4; |
214 m_pInterBuf = NULL; | 214 m_pInterBuf = NULL; |
215 m_pSource = pSrcBitmap; | 215 m_pSource = pSrcBitmap; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 int dest_a = 0; | 366 int dest_a = 0; |
367 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 367 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
368 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 368 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
369 if (src_scan[j / 8] & (1 << (7 - j % 8))) { | 369 if (src_scan[j / 8] & (1 << (7 - j % 8))) { |
370 dest_a += pixel_weight * 255; | 370 dest_a += pixel_weight * 255; |
371 } | 371 } |
372 } | 372 } |
373 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { | 373 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { |
374 dest_a = dest_a < 0 ? 0 : dest_a > 16711680 ? 167116
80 : dest_a; | 374 dest_a = dest_a < 0 ? 0 : dest_a > 16711680 ? 167116
80 : dest_a; |
375 } | 375 } |
376 *dest_scan++ = (FX_BYTE)(dest_a >> 16); | 376 *dest_scan++ = (uint8_t)(dest_a >> 16); |
377 } | 377 } |
378 break; | 378 break; |
379 } | 379 } |
380 case 3: { | 380 case 3: { |
381 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 381 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
382 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); | 382 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); |
383 int dest_a = 0; | 383 int dest_a = 0; |
384 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 384 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
385 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 385 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
386 dest_a += pixel_weight * src_scan[j]; | 386 dest_a += pixel_weight * src_scan[j]; |
387 } | 387 } |
388 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { | 388 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { |
389 dest_a = dest_a < 0 ? 0 : dest_a > 16711680 ? 167116
80 : dest_a; | 389 dest_a = dest_a < 0 ? 0 : dest_a > 16711680 ? 167116
80 : dest_a; |
390 } | 390 } |
391 *dest_scan++ = (FX_BYTE)(dest_a >> 16); | 391 *dest_scan++ = (uint8_t)(dest_a >> 16); |
392 } | 392 } |
393 break; | 393 break; |
394 } | 394 } |
395 case 4: { | 395 case 4: { |
396 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 396 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
397 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); | 397 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); |
398 int dest_a = 0, dest_r = 0; | 398 int dest_a = 0, dest_r = 0; |
399 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 399 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
400 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 400 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
401 pixel_weight = pixel_weight * src_scan_mask[j] / 255
; | 401 pixel_weight = pixel_weight * src_scan_mask[j] / 255
; |
402 dest_r += pixel_weight * src_scan[j]; | 402 dest_r += pixel_weight * src_scan[j]; |
403 dest_a += pixel_weight; | 403 dest_a += pixel_weight; |
404 } | 404 } |
405 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { | 405 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { |
406 dest_r = dest_r < 0 ? 0 : dest_r > 16711680 ? 167116
80 : dest_r; | 406 dest_r = dest_r < 0 ? 0 : dest_r > 16711680 ? 167116
80 : dest_r; |
407 dest_a = dest_a < 0 ? 0 : dest_a > 65536 ? 65536 : d
est_a; | 407 dest_a = dest_a < 0 ? 0 : dest_a > 65536 ? 65536 : d
est_a; |
408 } | 408 } |
409 *dest_scan++ = (FX_BYTE)(dest_r >> 16); | 409 *dest_scan++ = (uint8_t)(dest_r >> 16); |
410 *dest_scan_mask++ = (FX_BYTE)((dest_a * 255) >> 16); | 410 *dest_scan_mask++ = (uint8_t)((dest_a * 255) >> 16); |
411 } | 411 } |
412 break; | 412 break; |
413 } | 413 } |
414 case 5: { | 414 case 5: { |
415 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 415 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
416 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); | 416 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); |
417 int dest_r_y = 0, dest_g_m = 0, dest_b_c = 0; | 417 int dest_r_y = 0, dest_g_m = 0, dest_b_c = 0; |
418 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 418 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
419 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 419 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
420 unsigned long argb_cmyk = m_pSrcPalette[src_scan[j]]
; | 420 unsigned long argb_cmyk = m_pSrcPalette[src_scan[j]]
; |
421 if (m_DestFormat == FXDIB_Rgb) { | 421 if (m_DestFormat == FXDIB_Rgb) { |
422 dest_r_y += pixel_weight * (FX_BYTE)(argb_cmyk >
> 16); | 422 dest_r_y += pixel_weight * (uint8_t)(argb_cmyk >
> 16); |
423 dest_g_m += pixel_weight * (FX_BYTE)(argb_cmyk >
> 8); | 423 dest_g_m += pixel_weight * (uint8_t)(argb_cmyk >
> 8); |
424 dest_b_c += pixel_weight * (FX_BYTE)argb_cmyk; | 424 dest_b_c += pixel_weight * (uint8_t)argb_cmyk; |
425 } else { | 425 } else { |
426 dest_b_c += pixel_weight * (FX_BYTE)(argb_cmyk >
> 24); | 426 dest_b_c += pixel_weight * (uint8_t)(argb_cmyk >
> 24); |
427 dest_g_m += pixel_weight * (FX_BYTE)(argb_cmyk >
> 16); | 427 dest_g_m += pixel_weight * (uint8_t)(argb_cmyk >
> 16); |
428 dest_r_y += pixel_weight * (FX_BYTE)(argb_cmyk >
> 8); | 428 dest_r_y += pixel_weight * (uint8_t)(argb_cmyk >
> 8); |
429 } | 429 } |
430 } | 430 } |
431 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { | 431 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { |
432 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; | 432 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; |
433 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; | 433 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; |
434 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; | 434 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; |
435 } | 435 } |
436 *dest_scan++ = (FX_BYTE)(dest_b_c >> 16); | 436 *dest_scan++ = (uint8_t)(dest_b_c >> 16); |
437 *dest_scan++ = (FX_BYTE)(dest_g_m >> 16); | 437 *dest_scan++ = (uint8_t)(dest_g_m >> 16); |
438 *dest_scan++ = (FX_BYTE)(dest_r_y >> 16); | 438 *dest_scan++ = (uint8_t)(dest_r_y >> 16); |
439 } | 439 } |
440 break; | 440 break; |
441 } | 441 } |
442 case 6: { | 442 case 6: { |
443 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 443 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
444 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); | 444 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); |
445 int dest_a = 0, dest_r_y = 0, dest_g_m = 0, dest_b_c = 0
; | 445 int dest_a = 0, dest_r_y = 0, dest_g_m = 0, dest_b_c = 0
; |
446 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 446 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
447 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 447 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
448 pixel_weight = pixel_weight * src_scan_mask[j] / 255
; | 448 pixel_weight = pixel_weight * src_scan_mask[j] / 255
; |
449 unsigned long argb_cmyk = m_pSrcPalette[src_scan[j]]
; | 449 unsigned long argb_cmyk = m_pSrcPalette[src_scan[j]]
; |
450 if (m_DestFormat == FXDIB_Rgba) { | 450 if (m_DestFormat == FXDIB_Rgba) { |
451 dest_r_y += pixel_weight * (FX_BYTE)(argb_cmyk >
> 16); | 451 dest_r_y += pixel_weight * (uint8_t)(argb_cmyk >
> 16); |
452 dest_g_m += pixel_weight * (FX_BYTE)(argb_cmyk >
> 8); | 452 dest_g_m += pixel_weight * (uint8_t)(argb_cmyk >
> 8); |
453 dest_b_c += pixel_weight * (FX_BYTE)argb_cmyk; | 453 dest_b_c += pixel_weight * (uint8_t)argb_cmyk; |
454 } else { | 454 } else { |
455 dest_b_c += pixel_weight * (FX_BYTE)(argb_cmyk >
> 24); | 455 dest_b_c += pixel_weight * (uint8_t)(argb_cmyk >
> 24); |
456 dest_g_m += pixel_weight * (FX_BYTE)(argb_cmyk >
> 16); | 456 dest_g_m += pixel_weight * (uint8_t)(argb_cmyk >
> 16); |
457 dest_r_y += pixel_weight * (FX_BYTE)(argb_cmyk >
> 8); | 457 dest_r_y += pixel_weight * (uint8_t)(argb_cmyk >
> 8); |
458 } | 458 } |
459 dest_a += pixel_weight; | 459 dest_a += pixel_weight; |
460 } | 460 } |
461 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { | 461 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { |
462 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; | 462 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; |
463 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; | 463 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; |
464 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; | 464 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; |
465 dest_a = dest_a < 0 ? 0 : dest_a > 65536 ? 65536 : d
est_a; | 465 dest_a = dest_a < 0 ? 0 : dest_a > 65536 ? 65536 : d
est_a; |
466 } | 466 } |
467 *dest_scan++ = (FX_BYTE)(dest_b_c >> 16); | 467 *dest_scan++ = (uint8_t)(dest_b_c >> 16); |
468 *dest_scan++ = (FX_BYTE)(dest_g_m >> 16); | 468 *dest_scan++ = (uint8_t)(dest_g_m >> 16); |
469 *dest_scan++ = (FX_BYTE)(dest_r_y >> 16); | 469 *dest_scan++ = (uint8_t)(dest_r_y >> 16); |
470 *dest_scan_mask++ = (FX_BYTE)((dest_a * 255) >> 16); | 470 *dest_scan_mask++ = (uint8_t)((dest_a * 255) >> 16); |
471 } | 471 } |
472 break; | 472 break; |
473 } | 473 } |
474 case 7: { | 474 case 7: { |
475 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 475 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
476 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); | 476 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); |
477 int dest_r_y = 0, dest_g_m = 0, dest_b_c = 0; | 477 int dest_r_y = 0, dest_g_m = 0, dest_b_c = 0; |
478 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 478 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
479 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 479 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
480 FX_LPCBYTE src_pixel = src_scan + j * Bpp; | 480 FX_LPCBYTE src_pixel = src_scan + j * Bpp; |
481 dest_b_c += pixel_weight * (*src_pixel++); | 481 dest_b_c += pixel_weight * (*src_pixel++); |
482 dest_g_m += pixel_weight * (*src_pixel++); | 482 dest_g_m += pixel_weight * (*src_pixel++); |
483 dest_r_y += pixel_weight * (*src_pixel); | 483 dest_r_y += pixel_weight * (*src_pixel); |
484 } | 484 } |
485 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { | 485 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { |
486 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; | 486 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; |
487 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; | 487 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; |
488 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; | 488 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; |
489 } | 489 } |
490 *dest_scan++ = (FX_BYTE)((dest_b_c) >> 16); | 490 *dest_scan++ = (uint8_t)((dest_b_c) >> 16); |
491 *dest_scan++ = (FX_BYTE)((dest_g_m) >> 16); | 491 *dest_scan++ = (uint8_t)((dest_g_m) >> 16); |
492 *dest_scan++ = (FX_BYTE)((dest_r_y) >> 16); | 492 *dest_scan++ = (uint8_t)((dest_r_y) >> 16); |
493 dest_scan += Bpp - 3; | 493 dest_scan += Bpp - 3; |
494 } | 494 } |
495 break; | 495 break; |
496 } | 496 } |
497 case 8: { | 497 case 8: { |
498 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 498 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
499 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); | 499 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); |
500 int dest_a = 0, dest_r_y = 0, dest_g_m = 0, dest_b_c = 0
; | 500 int dest_a = 0, dest_r_y = 0, dest_g_m = 0, dest_b_c = 0
; |
501 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 501 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
502 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 502 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
503 FX_LPCBYTE src_pixel = src_scan + j * Bpp; | 503 FX_LPCBYTE src_pixel = src_scan + j * Bpp; |
504 if (m_DestFormat == FXDIB_Argb) { | 504 if (m_DestFormat == FXDIB_Argb) { |
505 pixel_weight = pixel_weight * src_pixel[3] / 255
; | 505 pixel_weight = pixel_weight * src_pixel[3] / 255
; |
506 } else { | 506 } else { |
507 pixel_weight = pixel_weight * src_scan_mask[j] /
255; | 507 pixel_weight = pixel_weight * src_scan_mask[j] /
255; |
508 } | 508 } |
509 dest_b_c += pixel_weight * (*src_pixel++); | 509 dest_b_c += pixel_weight * (*src_pixel++); |
510 dest_g_m += pixel_weight * (*src_pixel++); | 510 dest_g_m += pixel_weight * (*src_pixel++); |
511 dest_r_y += pixel_weight * (*src_pixel); | 511 dest_r_y += pixel_weight * (*src_pixel); |
512 dest_a += pixel_weight; | 512 dest_a += pixel_weight; |
513 } | 513 } |
514 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { | 514 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { |
515 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; | 515 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; |
516 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; | 516 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; |
517 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; | 517 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; |
518 dest_a = dest_a < 0 ? 0 : dest_a > 65536 ? 65536 : d
est_a; | 518 dest_a = dest_a < 0 ? 0 : dest_a > 65536 ? 65536 : d
est_a; |
519 } | 519 } |
520 *dest_scan++ = (FX_BYTE)((dest_b_c) >> 16); | 520 *dest_scan++ = (uint8_t)((dest_b_c) >> 16); |
521 *dest_scan++ = (FX_BYTE)((dest_g_m) >> 16); | 521 *dest_scan++ = (uint8_t)((dest_g_m) >> 16); |
522 *dest_scan++ = (FX_BYTE)((dest_r_y) >> 16); | 522 *dest_scan++ = (uint8_t)((dest_r_y) >> 16); |
523 if (m_DestFormat == FXDIB_Argb) { | 523 if (m_DestFormat == FXDIB_Argb) { |
524 *dest_scan = (FX_BYTE)((dest_a * 255) >> 16); | 524 *dest_scan = (uint8_t)((dest_a * 255) >> 16); |
525 } | 525 } |
526 if (dest_scan_mask) { | 526 if (dest_scan_mask) { |
527 *dest_scan_mask++ = (FX_BYTE)((dest_a * 255) >> 16); | 527 *dest_scan_mask++ = (uint8_t)((dest_a * 255) >> 16); |
528 } | 528 } |
529 dest_scan += Bpp - 3; | 529 dest_scan += Bpp - 3; |
530 } | 530 } |
531 break; | 531 break; |
532 } | 532 } |
533 } | 533 } |
534 rows_to_go --; | 534 rows_to_go --; |
535 } | 535 } |
536 return FALSE; | 536 return FALSE; |
537 } | 537 } |
(...skipping 19 matching lines...) Expand all Loading... |
557 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 557 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
558 unsigned char* src_scan = m_pInterBuf + (col - m_DestCli
p.left) * DestBpp; | 558 unsigned char* src_scan = m_pInterBuf + (col - m_DestCli
p.left) * DestBpp; |
559 int dest_a = 0; | 559 int dest_a = 0; |
560 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 560 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
561 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 561 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
562 dest_a += pixel_weight * src_scan[(j - m_SrcClip.top
) * m_InterPitch]; | 562 dest_a += pixel_weight * src_scan[(j - m_SrcClip.top
) * m_InterPitch]; |
563 } | 563 } |
564 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { | 564 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { |
565 dest_a = dest_a < 0 ? 0 : dest_a > 16711680 ? 167116
80 : dest_a; | 565 dest_a = dest_a < 0 ? 0 : dest_a > 16711680 ? 167116
80 : dest_a; |
566 } | 566 } |
567 *dest_scan = (FX_BYTE)(dest_a >> 16); | 567 *dest_scan = (uint8_t)(dest_a >> 16); |
568 dest_scan += DestBpp; | 568 dest_scan += DestBpp; |
569 } | 569 } |
570 break; | 570 break; |
571 } | 571 } |
572 case 4: { | 572 case 4: { |
573 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 573 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
574 unsigned char* src_scan = m_pInterBuf + (col - m_DestCli
p.left) * DestBpp; | 574 unsigned char* src_scan = m_pInterBuf + (col - m_DestCli
p.left) * DestBpp; |
575 unsigned char* src_scan_mask = m_pExtraAlphaBuf + (col -
m_DestClip.left); | 575 unsigned char* src_scan_mask = m_pExtraAlphaBuf + (col -
m_DestClip.left); |
576 int dest_a = 0, dest_k = 0; | 576 int dest_a = 0, dest_k = 0; |
577 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 577 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
578 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 578 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
579 dest_k += pixel_weight * src_scan[(j - m_SrcClip.top
) * m_InterPitch]; | 579 dest_k += pixel_weight * src_scan[(j - m_SrcClip.top
) * m_InterPitch]; |
580 dest_a += pixel_weight * src_scan_mask[(j - m_SrcCli
p.top) * m_ExtraMaskPitch]; | 580 dest_a += pixel_weight * src_scan_mask[(j - m_SrcCli
p.top) * m_ExtraMaskPitch]; |
581 } | 581 } |
582 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { | 582 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { |
583 dest_k = dest_k < 0 ? 0 : dest_k > 16711680 ? 167116
80 : dest_k; | 583 dest_k = dest_k < 0 ? 0 : dest_k > 16711680 ? 167116
80 : dest_k; |
584 dest_a = dest_a < 0 ? 0 : dest_a > 16711680 ? 167116
80 : dest_a; | 584 dest_a = dest_a < 0 ? 0 : dest_a > 16711680 ? 167116
80 : dest_a; |
585 } | 585 } |
586 *dest_scan = (FX_BYTE)(dest_k >> 16); | 586 *dest_scan = (uint8_t)(dest_k >> 16); |
587 dest_scan += DestBpp; | 587 dest_scan += DestBpp; |
588 *dest_sacn_mask++ = (FX_BYTE)(dest_a >> 16); | 588 *dest_sacn_mask++ = (uint8_t)(dest_a >> 16); |
589 } | 589 } |
590 break; | 590 break; |
591 } | 591 } |
592 case 5: | 592 case 5: |
593 case 7: { | 593 case 7: { |
594 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 594 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
595 unsigned char* src_scan = m_pInterBuf + (col - m_DestCli
p.left) * DestBpp; | 595 unsigned char* src_scan = m_pInterBuf + (col - m_DestCli
p.left) * DestBpp; |
596 int dest_r_y = 0, dest_g_m = 0, dest_b_c = 0; | 596 int dest_r_y = 0, dest_g_m = 0, dest_b_c = 0; |
597 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 597 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
598 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 598 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
599 FX_LPCBYTE src_pixel = src_scan + (j - m_SrcClip.top
) * m_InterPitch; | 599 FX_LPCBYTE src_pixel = src_scan + (j - m_SrcClip.top
) * m_InterPitch; |
600 dest_b_c += pixel_weight * (*src_pixel++); | 600 dest_b_c += pixel_weight * (*src_pixel++); |
601 dest_g_m += pixel_weight * (*src_pixel++); | 601 dest_g_m += pixel_weight * (*src_pixel++); |
602 dest_r_y += pixel_weight * (*src_pixel); | 602 dest_r_y += pixel_weight * (*src_pixel); |
603 } | 603 } |
604 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { | 604 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { |
605 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; | 605 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; |
606 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; | 606 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; |
607 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; | 607 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; |
608 } | 608 } |
609 dest_scan[0] = (FX_BYTE)((dest_b_c) >> 16); | 609 dest_scan[0] = (uint8_t)((dest_b_c) >> 16); |
610 dest_scan[1] = (FX_BYTE)((dest_g_m) >> 16); | 610 dest_scan[1] = (uint8_t)((dest_g_m) >> 16); |
611 dest_scan[2] = (FX_BYTE)((dest_r_y) >> 16); | 611 dest_scan[2] = (uint8_t)((dest_r_y) >> 16); |
612 dest_scan += DestBpp; | 612 dest_scan += DestBpp; |
613 } | 613 } |
614 break; | 614 break; |
615 } | 615 } |
616 case 6: | 616 case 6: |
617 case 8: { | 617 case 8: { |
618 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 618 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
619 unsigned char* src_scan = m_pInterBuf + (col - m_DestCli
p.left) * DestBpp; | 619 unsigned char* src_scan = m_pInterBuf + (col - m_DestCli
p.left) * DestBpp; |
620 unsigned char* src_scan_mask = NULL; | 620 unsigned char* src_scan_mask = NULL; |
621 if (m_DestFormat != FXDIB_Argb) { | 621 if (m_DestFormat != FXDIB_Argb) { |
(...skipping 24 matching lines...) Expand all Loading... |
646 } | 646 } |
647 if (dest_a) { | 647 if (dest_a) { |
648 int r = ((FX_DWORD)dest_r_y) * 255 / dest_a; | 648 int r = ((FX_DWORD)dest_r_y) * 255 / dest_a; |
649 int g = ((FX_DWORD)dest_g_m) * 255 / dest_a; | 649 int g = ((FX_DWORD)dest_g_m) * 255 / dest_a; |
650 int b = ((FX_DWORD)dest_b_c) * 255 / dest_a; | 650 int b = ((FX_DWORD)dest_b_c) * 255 / dest_a; |
651 dest_scan[0] = b > 255 ? 255 : b < 0 ? 0 : b; | 651 dest_scan[0] = b > 255 ? 255 : b < 0 ? 0 : b; |
652 dest_scan[1] = g > 255 ? 255 : g < 0 ? 0 : g; | 652 dest_scan[1] = g > 255 ? 255 : g < 0 ? 0 : g; |
653 dest_scan[2] = r > 255 ? 255 : r < 0 ? 0 : r; | 653 dest_scan[2] = r > 255 ? 255 : r < 0 ? 0 : r; |
654 } | 654 } |
655 if (m_DestFormat == FXDIB_Argb) { | 655 if (m_DestFormat == FXDIB_Argb) { |
656 dest_scan[3] = (FX_BYTE)((dest_a) >> 16); | 656 dest_scan[3] = (uint8_t)((dest_a) >> 16); |
657 } else { | 657 } else { |
658 *dest_sacn_mask = (FX_BYTE)((dest_a) >> 16); | 658 *dest_sacn_mask = (uint8_t)((dest_a) >> 16); |
659 } | 659 } |
660 dest_scan += DestBpp; | 660 dest_scan += DestBpp; |
661 if (dest_sacn_mask) { | 661 if (dest_sacn_mask) { |
662 dest_sacn_mask++; | 662 dest_sacn_mask++; |
663 } | 663 } |
664 } | 664 } |
665 break; | 665 break; |
666 } | 666 } |
667 } | 667 } |
668 m_pDestBitmap->ComposeScanline(row - m_DestClip.top, m_pDestScanline, m_
pDestMaskScanline); | 668 m_pDestBitmap->ComposeScanline(row - m_DestClip.top, m_pDestScanline, m_
pDestMaskScanline); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 if (m_DestHeight < 0) { | 791 if (m_DestHeight < 0) { |
792 m_bFlipY = TRUE; | 792 m_bFlipY = TRUE; |
793 m_DestHeight = -m_DestHeight; | 793 m_DestHeight = -m_DestHeight; |
794 } | 794 } |
795 m_LineIndex = 0; | 795 m_LineIndex = 0; |
796 FX_DWORD size = m_ClipRect.Width(); | 796 FX_DWORD size = m_ClipRect.Width(); |
797 if (size && m_DestBPP > (int)(INT_MAX / size)) { | 797 if (size && m_DestBPP > (int)(INT_MAX / size)) { |
798 return FALSE; | 798 return FALSE; |
799 } | 799 } |
800 size *= m_DestBPP; | 800 size *= m_DestBPP; |
801 m_pScanline = FX_Alloc(FX_BYTE, (size / 8 + 3) / 4 * 4); | 801 m_pScanline = FX_Alloc(uint8_t, (size / 8 + 3) / 4 * 4); |
802 if (m_pSource->m_pAlphaMask) { | 802 if (m_pSource->m_pAlphaMask) { |
803 m_pMaskScanline = FX_Alloc(FX_BYTE, (m_ClipRect.Width() + 3) / 4 * 4); | 803 m_pMaskScanline = FX_Alloc(uint8_t, (m_ClipRect.Width() + 3) / 4 * 4); |
804 } | 804 } |
805 if (m_pSource->GetWidth() * m_pSource->GetHeight() < MAX_PROGRESSIVE_STRETCH
_PIXELS) { | 805 if (m_pSource->GetWidth() * m_pSource->GetHeight() < MAX_PROGRESSIVE_STRETCH
_PIXELS) { |
806 ContinueQuickStretch(NULL); | 806 ContinueQuickStretch(NULL); |
807 return FALSE; | 807 return FALSE; |
808 } | 808 } |
809 return TRUE; | 809 return TRUE; |
810 } | 810 } |
811 FX_BOOL CFX_ImageStretcher::ContinueQuickStretch(IFX_Pause* pPause) | 811 FX_BOOL CFX_ImageStretcher::ContinueQuickStretch(IFX_Pause* pPause) |
812 { | 812 { |
813 if (m_pScanline == NULL) { | 813 if (m_pScanline == NULL) { |
(...skipping 20 matching lines...) Expand all Loading... |
834 return TRUE; | 834 return TRUE; |
835 } | 835 } |
836 m_pSource->DownSampleScanline(src_y, m_pScanline, m_DestBPP, m_DestWidth
, m_bFlipX, m_ClipRect.left, result_width); | 836 m_pSource->DownSampleScanline(src_y, m_pScanline, m_DestBPP, m_DestWidth
, m_bFlipX, m_ClipRect.left, result_width); |
837 if (m_pMaskScanline) { | 837 if (m_pMaskScanline) { |
838 m_pSource->m_pAlphaMask->DownSampleScanline(src_y, m_pMaskScanline,
1, m_DestWidth, m_bFlipX, m_ClipRect.left, result_width); | 838 m_pSource->m_pAlphaMask->DownSampleScanline(src_y, m_pMaskScanline,
1, m_DestWidth, m_bFlipX, m_ClipRect.left, result_width); |
839 } | 839 } |
840 m_pDest->ComposeScanline(dest_y, m_pScanline, m_pMaskScanline); | 840 m_pDest->ComposeScanline(dest_y, m_pScanline, m_pMaskScanline); |
841 } | 841 } |
842 return FALSE; | 842 return FALSE; |
843 } | 843 } |
OLD | NEW |