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 #include "dib_int.h" | 10 #include "dib_int.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 dest_format = FXDIB_8bppMask; | 424 dest_format = FXDIB_8bppMask; |
425 } | 425 } |
426 FX_LPBYTE dest_buf = m_pBuffer + dest_top * m_Pitch + dest_left * GetBPP
() / 8; | 426 FX_LPBYTE dest_buf = m_pBuffer + dest_top * m_Pitch + dest_left * GetBPP
() / 8; |
427 FX_DWORD* d_plt = NULL; | 427 FX_DWORD* d_plt = NULL; |
428 if(!ConvertBuffer(dest_format, dest_buf, m_Pitch, width, height, pSrcBit
map, src_left, src_top, d_plt, pIccTransform)) { | 428 if(!ConvertBuffer(dest_format, dest_buf, m_Pitch, width, height, pSrcBit
map, src_left, src_top, d_plt, pIccTransform)) { |
429 return FALSE; | 429 return FALSE; |
430 } | 430 } |
431 } | 431 } |
432 return TRUE; | 432 return TRUE; |
433 } | 433 } |
434 #ifndef _FPDFAPI_MINI_ | |
435 FX_BOOL CFX_DIBitmap::TransferMask(int dest_left, int dest_top, int width, int h
eight, | 434 FX_BOOL CFX_DIBitmap::TransferMask(int dest_left, int dest_top, int width, int h
eight, |
436 const CFX_DIBSource* pMask, FX_DWORD color, i
nt src_left, int src_top, int alpha_flag, void* pIccTransform) | 435 const CFX_DIBSource* pMask, FX_DWORD color, i
nt src_left, int src_top, int alpha_flag, void* pIccTransform) |
437 { | 436 { |
438 if (m_pBuffer == NULL) { | 437 if (m_pBuffer == NULL) { |
439 return FALSE; | 438 return FALSE; |
440 } | 439 } |
441 ASSERT(HasAlpha() && (m_bpp >= 24)); | 440 ASSERT(HasAlpha() && (m_bpp >= 24)); |
442 ASSERT(pMask->IsAlphaMask()); | 441 ASSERT(pMask->IsAlphaMask()); |
443 if (!HasAlpha() || !pMask->IsAlphaMask() || m_bpp < 24) { | 442 if (!HasAlpha() || !pMask->IsAlphaMask() || m_bpp < 24) { |
444 return FALSE; | 443 return FALSE; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 for (int col = 0; col < width; col ++) { | 518 for (int col = 0; col < width; col ++) { |
520 FXSYS_memcpy32(dest_color_pos, color_p, comps); | 519 FXSYS_memcpy32(dest_color_pos, color_p, comps); |
521 dest_color_pos += comps; | 520 dest_color_pos += comps; |
522 *dest_alpha_pos++ = (alpha * (*src_scan++) / 255); | 521 *dest_alpha_pos++ = (alpha * (*src_scan++) / 255); |
523 } | 522 } |
524 } | 523 } |
525 } | 524 } |
526 } | 525 } |
527 return TRUE; | 526 return TRUE; |
528 } | 527 } |
529 #endif | |
530 void CFX_DIBSource::CopyPalette(const FX_DWORD* pSrc, FX_DWORD size) | 528 void CFX_DIBSource::CopyPalette(const FX_DWORD* pSrc, FX_DWORD size) |
531 { | 529 { |
532 if (pSrc == NULL || GetBPP() > 8) { | 530 if (pSrc == NULL || GetBPP() > 8) { |
533 if (m_pPalette) { | 531 if (m_pPalette) { |
534 FX_Free(m_pPalette); | 532 FX_Free(m_pPalette); |
535 } | 533 } |
536 m_pPalette = NULL; | 534 m_pPalette = NULL; |
537 } else { | 535 } else { |
538 FX_DWORD pal_size = 1 << GetBPP(); | 536 FX_DWORD pal_size = 1 << GetBPP(); |
539 if (m_pPalette == NULL) { | 537 if (m_pPalette == NULL) { |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 } else { | 1044 } else { |
1047 if (!ConvertFormat(FXDIB_Argb)) { | 1045 if (!ConvertFormat(FXDIB_Argb)) { |
1048 return FALSE; | 1046 return FALSE; |
1049 } | 1047 } |
1050 MultiplyAlpha(alpha); | 1048 MultiplyAlpha(alpha); |
1051 } | 1049 } |
1052 break; | 1050 break; |
1053 } | 1051 } |
1054 return TRUE; | 1052 return TRUE; |
1055 } | 1053 } |
1056 #if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_) | |
1057 FX_DWORD CFX_DIBitmap::GetPixel(int x, int y) const | 1054 FX_DWORD CFX_DIBitmap::GetPixel(int x, int y) const |
1058 { | 1055 { |
1059 if (m_pBuffer == NULL) { | 1056 if (m_pBuffer == NULL) { |
1060 return 0; | 1057 return 0; |
1061 } | 1058 } |
1062 FX_LPBYTE pos = m_pBuffer + y * m_Pitch + x * GetBPP() / 8; | 1059 FX_LPBYTE pos = m_pBuffer + y * m_Pitch + x * GetBPP() / 8; |
1063 switch (GetFormat()) { | 1060 switch (GetFormat()) { |
1064 case FXDIB_1bppMask: { | 1061 case FXDIB_1bppMask: { |
1065 if ((*pos) & (1 << (7 - x % 8))) { | 1062 if ((*pos) & (1 << (7 - x % 8))) { |
1066 return 0xff000000; | 1063 return 0xff000000; |
(...skipping 16 matching lines...) Expand all Loading... |
1083 case FXDIB_Rgba: | 1080 case FXDIB_Rgba: |
1084 case FXDIB_Rgb32: | 1081 case FXDIB_Rgb32: |
1085 return FXARGB_GETDIB(pos) | 0xff000000; | 1082 return FXARGB_GETDIB(pos) | 0xff000000; |
1086 case FXDIB_Argb: | 1083 case FXDIB_Argb: |
1087 return FXARGB_GETDIB(pos); | 1084 return FXARGB_GETDIB(pos); |
1088 default: | 1085 default: |
1089 break; | 1086 break; |
1090 } | 1087 } |
1091 return 0; | 1088 return 0; |
1092 } | 1089 } |
1093 #endif | |
1094 void CFX_DIBitmap::SetPixel(int x, int y, FX_DWORD color) | 1090 void CFX_DIBitmap::SetPixel(int x, int y, FX_DWORD color) |
1095 { | 1091 { |
1096 if (m_pBuffer == NULL) { | 1092 if (m_pBuffer == NULL) { |
1097 return; | 1093 return; |
1098 } | 1094 } |
1099 if (x < 0 || x >= m_Width || y < 0 || y >= m_Height) { | 1095 if (x < 0 || x >= m_Width || y < 0 || y >= m_Height) { |
1100 return; | 1096 return; |
1101 } | 1097 } |
1102 FX_LPBYTE pos = m_pBuffer + y * m_Pitch + x * GetBPP() / 8; | 1098 FX_LPBYTE pos = m_pBuffer + y * m_Pitch + x * GetBPP() / 8; |
1103 switch (GetFormat()) { | 1099 switch (GetFormat()) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 } | 1165 } |
1170 int src_Bpp = m_bpp / 8; | 1166 int src_Bpp = m_bpp / 8; |
1171 FX_LPBYTE scanline = m_pBuffer + line * m_Pitch; | 1167 FX_LPBYTE scanline = m_pBuffer + line * m_Pitch; |
1172 if (src_Bpp == 0) { | 1168 if (src_Bpp == 0) { |
1173 for (int i = 0; i < clip_width; i ++) { | 1169 for (int i = 0; i < clip_width; i ++) { |
1174 FX_DWORD dest_x = clip_left + i; | 1170 FX_DWORD dest_x = clip_left + i; |
1175 FX_DWORD src_x = dest_x * m_Width / dest_width; | 1171 FX_DWORD src_x = dest_x * m_Width / dest_width; |
1176 if (bFlipX) { | 1172 if (bFlipX) { |
1177 src_x = m_Width - src_x - 1; | 1173 src_x = m_Width - src_x - 1; |
1178 } | 1174 } |
1179 #ifdef FOXIT_CHROME_BUILD | |
1180 src_x %= m_Width; | 1175 src_x %= m_Width; |
1181 #endif | |
1182 dest_scan[i] = (scanline[src_x / 8] & (1 << (7 - src_x % 8))) ? 255
: 0; | 1176 dest_scan[i] = (scanline[src_x / 8] & (1 << (7 - src_x % 8))) ? 255
: 0; |
1183 } | 1177 } |
1184 } else if (src_Bpp == 1) { | 1178 } else if (src_Bpp == 1) { |
1185 for (int i = 0; i < clip_width; i ++) { | 1179 for (int i = 0; i < clip_width; i ++) { |
1186 FX_DWORD dest_x = clip_left + i; | 1180 FX_DWORD dest_x = clip_left + i; |
1187 FX_DWORD src_x = dest_x * m_Width / dest_width; | 1181 FX_DWORD src_x = dest_x * m_Width / dest_width; |
1188 if (bFlipX) { | 1182 if (bFlipX) { |
1189 src_x = m_Width - src_x - 1; | 1183 src_x = m_Width - src_x - 1; |
1190 } | 1184 } |
1191 #ifdef FOXIT_CHROME_BUILD | |
1192 src_x %= m_Width; | 1185 src_x %= m_Width; |
1193 #endif | |
1194 int dest_pos = i; | 1186 int dest_pos = i; |
1195 if (m_pPalette) { | 1187 if (m_pPalette) { |
1196 if (!IsCmykImage()) { | 1188 if (!IsCmykImage()) { |
1197 dest_pos *= 3; | 1189 dest_pos *= 3; |
1198 FX_ARGB argb = m_pPalette[scanline[src_x]]; | 1190 FX_ARGB argb = m_pPalette[scanline[src_x]]; |
1199 dest_scan[dest_pos] = FXARGB_B(argb); | 1191 dest_scan[dest_pos] = FXARGB_B(argb); |
1200 dest_scan[dest_pos + 1] = FXARGB_G(argb); | 1192 dest_scan[dest_pos + 1] = FXARGB_G(argb); |
1201 dest_scan[dest_pos + 2] = FXARGB_R(argb); | 1193 dest_scan[dest_pos + 2] = FXARGB_R(argb); |
1202 } else { | 1194 } else { |
1203 dest_pos *= 4; | 1195 dest_pos *= 4; |
1204 FX_CMYK cmyk = m_pPalette[scanline[src_x]]; | 1196 FX_CMYK cmyk = m_pPalette[scanline[src_x]]; |
1205 dest_scan[dest_pos] = FXSYS_GetCValue(cmyk); | 1197 dest_scan[dest_pos] = FXSYS_GetCValue(cmyk); |
1206 dest_scan[dest_pos + 1] = FXSYS_GetMValue(cmyk); | 1198 dest_scan[dest_pos + 1] = FXSYS_GetMValue(cmyk); |
1207 dest_scan[dest_pos + 2] = FXSYS_GetYValue(cmyk); | 1199 dest_scan[dest_pos + 2] = FXSYS_GetYValue(cmyk); |
1208 dest_scan[dest_pos + 3] = FXSYS_GetKValue(cmyk); | 1200 dest_scan[dest_pos + 3] = FXSYS_GetKValue(cmyk); |
1209 } | 1201 } |
1210 } else { | 1202 } else { |
1211 dest_scan[dest_pos] = scanline[src_x]; | 1203 dest_scan[dest_pos] = scanline[src_x]; |
1212 } | 1204 } |
1213 } | 1205 } |
1214 } else { | 1206 } else { |
1215 for (int i = 0; i < clip_width; i ++) { | 1207 for (int i = 0; i < clip_width; i ++) { |
1216 FX_DWORD dest_x = clip_left + i; | 1208 FX_DWORD dest_x = clip_left + i; |
1217 FX_DWORD src_x = bFlipX ? (m_Width - dest_x * m_Width / dest_width -
1) * src_Bpp : (dest_x * m_Width / dest_width) * src_Bpp; | 1209 FX_DWORD src_x = bFlipX ? (m_Width - dest_x * m_Width / dest_width -
1) * src_Bpp : (dest_x * m_Width / dest_width) * src_Bpp; |
1218 #ifdef FOXIT_CHROME_BUILD | |
1219 src_x %= m_Width * src_Bpp; | 1210 src_x %= m_Width * src_Bpp; |
1220 #endif | |
1221 int dest_pos = i * src_Bpp; | 1211 int dest_pos = i * src_Bpp; |
1222 for (int b = 0; b < src_Bpp; b ++) { | 1212 for (int b = 0; b < src_Bpp; b ++) { |
1223 dest_scan[dest_pos + b] = scanline[src_x + b]; | 1213 dest_scan[dest_pos + b] = scanline[src_x + b]; |
1224 } | 1214 } |
1225 } | 1215 } |
1226 } | 1216 } |
1227 } | 1217 } |
1228 FX_BOOL CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor, FX_DWORD backcolor) | 1218 FX_BOOL CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor, FX_DWORD backcolor) |
1229 { | 1219 { |
1230 ASSERT(!IsAlphaMask()); | 1220 ASSERT(!IsAlphaMask()); |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1724 if (!m_pBitmap->Create(width, height, src_format)) { | 1714 if (!m_pBitmap->Create(width, height, src_format)) { |
1725 delete m_pBitmap; | 1715 delete m_pBitmap; |
1726 m_pBitmap = NULL; | 1716 m_pBitmap = NULL; |
1727 return FALSE; | 1717 return FALSE; |
1728 } | 1718 } |
1729 if (pSrcPalette) { | 1719 if (pSrcPalette) { |
1730 m_pBitmap->CopyPalette(pSrcPalette); | 1720 m_pBitmap->CopyPalette(pSrcPalette); |
1731 } | 1721 } |
1732 return TRUE; | 1722 return TRUE; |
1733 } | 1723 } |
OLD | NEW |