Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Side by Side Diff: core/src/fxge/win32/fx_win32_device.cpp

Issue 474093003: Don't stretch bitmaps if destination size is empty. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Thu 08/21/2014 18:47:28.76 Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 if (pBitmap != pBitmap1) { 508 if (pBitmap != pBitmap1) {
509 delete pBitmap; 509 delete pBitmap;
510 } 510 }
511 } 511 }
512 return TRUE; 512 return TRUE;
513 } 513 }
514 FX_BOOL CGdiDeviceDriver::GDI_StretchDIBits(const CFX_DIBitmap* pBitmap1, int de st_left, int dest_top, 514 FX_BOOL CGdiDeviceDriver::GDI_StretchDIBits(const CFX_DIBitmap* pBitmap1, int de st_left, int dest_top,
515 int dest_width, int dest_height, FX_DWORD flags, void* pIccTransform) 515 int dest_width, int dest_height, FX_DWORD flags, void* pIccTransform)
516 { 516 {
517 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; 517 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
518 if (pBitmap == NULL) { 518 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
519 return FALSE; 519 return FALSE;
520 } 520 }
521 if ((pBitmap->IsCmykImage() || pIccTransform) && 521 if ((pBitmap->IsCmykImage() || pIccTransform) &&
522 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) { 522 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) {
523 return FALSE; 523 return FALSE;
524 } 524 }
525 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); 525 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
526 if ((FX_INT64)abs(dest_width) * abs(dest_height) < (FX_INT64)pBitmap1->GetWi dth() * pBitmap1->GetHeight() * 4 || 526 if ((FX_INT64)abs(dest_width) * abs(dest_height) < (FX_INT64)pBitmap1->GetWi dth() * pBitmap1->GetHeight() * 4 ||
527 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) { 527 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) {
528 SetStretchBltMode(m_hDC, HALFTONE); 528 SetStretchBltMode(m_hDC, HALFTONE);
(...skipping 13 matching lines...) Expand all
542 if (del) { 542 if (del) {
543 delete pToStrechBitmap; 543 delete pToStrechBitmap;
544 } 544 }
545 return TRUE; 545 return TRUE;
546 } 546 }
547 FX_BOOL CGdiDeviceDriver::GDI_StretchBitMask(const CFX_DIBitmap* pBitmap1, int d est_left, int dest_top, 547 FX_BOOL CGdiDeviceDriver::GDI_StretchBitMask(const CFX_DIBitmap* pBitmap1, int d est_left, int dest_top,
548 int dest_width, int dest_height, FX_DWORD bitmap_color, FX_DWORD flags, 548 int dest_width, int dest_height, FX_DWORD bitmap_color, FX_DWORD flags,
549 int alpha_flag, void* pIccTransform) 549 int alpha_flag, void* pIccTransform)
550 { 550 {
551 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; 551 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
552 if (pBitmap == NULL) { 552 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
553 return FALSE; 553 return FALSE;
554 } 554 }
555 _Color2Argb(bitmap_color, bitmap_color, alpha_flag | (1 << 24), pIccTransfor m); 555 _Color2Argb(bitmap_color, bitmap_color, alpha_flag | (1 << 24), pIccTransfor m);
556 int width = pBitmap->GetWidth(), height = pBitmap->GetHeight(); 556 int width = pBitmap->GetWidth(), height = pBitmap->GetHeight();
557 struct { 557 struct {
558 BITMAPINFOHEADER bmiHeader; 558 BITMAPINFOHEADER bmiHeader;
559 FX_DWORD bmiColors[2]; 559 FX_DWORD bmiColors[2];
560 } bmi; 560 } bmi;
561 FXSYS_memset32(&bmi.bmiHeader, 0, sizeof (BITMAPINFOHEADER)); 561 FXSYS_memset32(&bmi.bmiHeader, 0, sizeof (BITMAPINFOHEADER));
562 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 562 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 if (m_hDC) { 1191 if (m_hDC) {
1192 SelectObject(m_hDC, m_hOldBitmap); 1192 SelectObject(m_hDC, m_hOldBitmap);
1193 DeleteDC(m_hDC); 1193 DeleteDC(m_hDC);
1194 } 1194 }
1195 if (m_hBitmap) { 1195 if (m_hBitmap) {
1196 DeleteObject(m_hBitmap); 1196 DeleteObject(m_hBitmap);
1197 } 1197 }
1198 delete GetBitmap(); 1198 delete GetBitmap();
1199 } 1199 }
1200 #endif 1200 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698