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_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ | 8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ |
9 #include "../../../include/fxge/fx_ge_win32.h" | 9 #include "../../../include/fxge/fx_ge_win32.h" |
10 #include <crtdbg.h> | 10 #include <crtdbg.h> |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 extern "C" { | 207 extern "C" { |
208 static int compareString(const void* key, const void* element) | 208 static int compareString(const void* key, const void* element) |
209 { | 209 { |
210 return FXSYS_stricmp((FX_LPCSTR)key, ((_FontNameMap*)element)->m_pSrcFon
tName); | 210 return FXSYS_stricmp((FX_LPCSTR)key, ((_FontNameMap*)element)->m_pSrcFon
tName); |
211 } | 211 } |
212 } | 212 } |
213 FX_BOOL _GetSubFontName(CFX_ByteString& name) | 213 FX_BOOL _GetSubFontName(CFX_ByteString& name) |
214 { | 214 { |
215 int size = sizeof g_JpFontNameMap; | 215 int size = sizeof g_JpFontNameMap; |
216 void* pFontnameMap = (void*)g_JpFontNameMap; | 216 void* pFontnameMap = (void*)g_JpFontNameMap; |
217 _FontNameMap* found = (_FontNameMap*)FXSYS_bsearch((FX_LPCSTR)name, pFontnam
eMap, | 217 _FontNameMap* found = (_FontNameMap*)FXSYS_bsearch(name.c_str(), pFontnameMa
p, |
218 size / sizeof (_FontNameMap), sizeof (_FontNameMap), c
ompareString); | 218 size / sizeof (_FontNameMap), sizeof (_FontNameMap), c
ompareString); |
219 if (found == NULL) { | 219 if (found == NULL) { |
220 return FALSE; | 220 return FALSE; |
221 } | 221 } |
222 name = found->m_pSubFontName; | 222 name = found->m_pSubFontName; |
223 return TRUE; | 223 return TRUE; |
224 } | 224 } |
225 void CWin32FontInfo::GetGBPreference(CFX_ByteString& face, int weight, int picth
_family) | 225 void CWin32FontInfo::GetGBPreference(CFX_ByteString& face, int weight, int picth
_family) |
226 { | 226 { |
227 if (face.Find("KaiTi") >= 0 || face.Find("\xbf\xac") >= 0) { | 227 if (face.Find("KaiTi") >= 0 || face.Find("\xbf\xac") >= 0) { |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 return FALSE; | 476 return FALSE; |
477 } | 477 } |
478 if ((pBitmap->IsCmykImage() || pIccTransform) && | 478 if ((pBitmap->IsCmykImage() || pIccTransform) && |
479 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) { | 479 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) { |
480 return FALSE; | 480 return FALSE; |
481 } | 481 } |
482 int width = pSrcRect->Width(), height = pSrcRect->Height(); | 482 int width = pSrcRect->Width(), height = pSrcRect->Height(); |
483 int pitch = pBitmap->GetPitch(); | 483 int pitch = pBitmap->GetPitch(); |
484 LPBYTE pBuffer = pBitmap->GetBuffer(); | 484 LPBYTE pBuffer = pBitmap->GetBuffer(); |
485 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); | 485 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); |
486 ((BITMAPINFOHEADER*)(FX_LPCSTR)info)->biHeight *= -1; | 486 ((BITMAPINFOHEADER*)info.c_str())->biHeight *= -1; |
487 FX_RECT dst_rect(0, 0, width, height); | 487 FX_RECT dst_rect(0, 0, width, height); |
488 dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); | 488 dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); |
489 int dst_width = dst_rect.Width(); | 489 int dst_width = dst_rect.Width(); |
490 int dst_height = dst_rect.Height(); | 490 int dst_height = dst_rect.Height(); |
491 ::StretchDIBits(m_hDC, left, top, dst_width, dst_height, | 491 ::StretchDIBits(m_hDC, left, top, dst_width, dst_height, |
492 0, 0, dst_width, dst_height, pBuffer, (BITMAPINFO*)(FX_L
PCSTR)info, DIB_RGB_COLORS, SRCCOPY); | 492 0, 0, dst_width, dst_height, pBuffer, (BITMAPINFO*)info.c_str(), DIB
_RGB_COLORS, SRCCOPY); |
493 delete pBitmap; | 493 delete pBitmap; |
494 } else { | 494 } else { |
495 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; | 495 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; |
496 if ((pBitmap->IsCmykImage() || pIccTransform) && | 496 if ((pBitmap->IsCmykImage() || pIccTransform) && |
497 (pBitmap = pBitmap->CloneConvert(FXDIB_Rgb, NULL, pIccTransform)
) == NULL) { | 497 (pBitmap = pBitmap->CloneConvert(FXDIB_Rgb, NULL, pIccTransform)
) == NULL) { |
498 return FALSE; | 498 return FALSE; |
499 } | 499 } |
500 int width = pSrcRect->Width(), height = pSrcRect->Height(); | 500 int width = pSrcRect->Width(), height = pSrcRect->Height(); |
501 int pitch = pBitmap->GetPitch(); | 501 int pitch = pBitmap->GetPitch(); |
502 LPBYTE pBuffer = pBitmap->GetBuffer(); | 502 LPBYTE pBuffer = pBitmap->GetBuffer(); |
503 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); | 503 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); |
504 ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left, pBi
tmap->GetHeight() - pSrcRect->bottom, | 504 ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left, pBi
tmap->GetHeight() - pSrcRect->bottom, |
505 0, pBitmap->GetHeight(), pBuffer, (BITMAPINFO*)(FX_L
PCSTR)info, DIB_RGB_COLORS); | 505 0, pBitmap->GetHeight(), pBuffer, (BITMAPINFO*)info.c_str(), DIB_RGB
_COLORS); |
506 if (pBitmap != pBitmap1) { | 506 if (pBitmap != pBitmap1) { |
507 delete pBitmap; | 507 delete pBitmap; |
508 } | 508 } |
509 } | 509 } |
510 return TRUE; | 510 return TRUE; |
511 } | 511 } |
512 FX_BOOL CGdiDeviceDriver::GDI_StretchDIBits(const CFX_DIBitmap* pBitmap1, int de
st_left, int dest_top, | 512 FX_BOOL CGdiDeviceDriver::GDI_StretchDIBits(const CFX_DIBitmap* pBitmap1, int de
st_left, int dest_top, |
513 int dest_width, int dest_height, FX_DWORD flags, void* pIccTransform) | 513 int dest_width, int dest_height, FX_DWORD flags, void* pIccTransform) |
514 { | 514 { |
515 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; | 515 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; |
(...skipping 13 matching lines...) Expand all Loading... |
529 } | 529 } |
530 CFX_DIBitmap* pToStrechBitmap = pBitmap; | 530 CFX_DIBitmap* pToStrechBitmap = pBitmap; |
531 bool del = false; | 531 bool del = false; |
532 if (m_DeviceClass == FXDC_PRINTER && ((FX_INT64)pBitmap->GetWidth() * pBitma
p->GetHeight() > (FX_INT64)abs(dest_width) * abs(dest_height))) { | 532 if (m_DeviceClass == FXDC_PRINTER && ((FX_INT64)pBitmap->GetWidth() * pBitma
p->GetHeight() > (FX_INT64)abs(dest_width) * abs(dest_height))) { |
533 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); | 533 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); |
534 del = true; | 534 del = true; |
535 } | 535 } |
536 CFX_ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechB
itmap); | 536 CFX_ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechB
itmap); |
537 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, | 537 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, |
538 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeigh
t(), pToStrechBitmap->GetBuffer(), | 538 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeigh
t(), pToStrechBitmap->GetBuffer(), |
539 (BITMAPINFO*)(FX_LPCSTR)toStrechBitmapInfo, DIB_RGB_COLORS,
SRCCOPY); | 539 (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, SRC
COPY); |
540 if (del) { | 540 if (del) { |
541 delete pToStrechBitmap; | 541 delete pToStrechBitmap; |
542 } | 542 } |
543 return TRUE; | 543 return TRUE; |
544 } | 544 } |
545 FX_BOOL CGdiDeviceDriver::GDI_StretchBitMask(const CFX_DIBitmap* pBitmap1, int d
est_left, int dest_top, | 545 FX_BOOL CGdiDeviceDriver::GDI_StretchBitMask(const CFX_DIBitmap* pBitmap1, int d
est_left, int dest_top, |
546 int dest_width, int dest_height, FX_DWORD bitmap_color, FX_DWORD flags, | 546 int dest_width, int dest_height, FX_DWORD bitmap_color, FX_DWORD flags, |
547 int alpha_flag, void* pIccTransform) | 547 int alpha_flag, void* pIccTransform) |
548 { | 548 { |
549 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; | 549 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 if (m_hDC) { | 1209 if (m_hDC) { |
1210 SelectObject(m_hDC, m_hOldBitmap); | 1210 SelectObject(m_hDC, m_hOldBitmap); |
1211 DeleteDC(m_hDC); | 1211 DeleteDC(m_hDC); |
1212 } | 1212 } |
1213 if (m_hBitmap) { | 1213 if (m_hBitmap) { |
1214 DeleteObject(m_hBitmap); | 1214 DeleteObject(m_hBitmap); |
1215 } | 1215 } |
1216 delete GetBitmap(); | 1216 delete GetBitmap(); |
1217 } | 1217 } |
1218 #endif | 1218 #endif |
OLD | NEW |