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 <crtdbg.h> | 7 #include <crtdbg.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
806 FX_RECT dst_rect(0, 0, width, height); | 806 FX_RECT dst_rect(0, 0, width, height); |
807 dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); | 807 dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); |
808 int dst_width = dst_rect.Width(); | 808 int dst_width = dst_rect.Width(); |
809 int dst_height = dst_rect.Height(); | 809 int dst_height = dst_rect.Height(); |
810 ::StretchDIBits(m_hDC, left, top, dst_width, dst_height, 0, 0, dst_width, | 810 ::StretchDIBits(m_hDC, left, top, dst_width, dst_height, 0, 0, dst_width, |
811 dst_height, pBuffer, (BITMAPINFO*)info.c_str(), | 811 dst_height, pBuffer, (BITMAPINFO*)info.c_str(), |
812 DIB_RGB_COLORS, SRCCOPY); | 812 DIB_RGB_COLORS, SRCCOPY); |
813 } else { | 813 } else { |
814 CFX_DIBitmap* pBitmap = pBitmap1; | 814 CFX_DIBitmap* pBitmap = pBitmap1; |
815 if (pBitmap->IsCmykImage()) { | 815 if (pBitmap->IsCmykImage()) { |
816 pBitmap = pBitmap->CloneConvert(FXDIB_Rgb); | 816 pBitmap = pBitmap->CloneConvert(FXDIB_Rgb).release(); |
817 if (!pBitmap) | 817 if (!pBitmap) |
818 return false; | 818 return false; |
819 } | 819 } |
820 int width = pSrcRect->Width(), height = pSrcRect->Height(); | 820 int width = pSrcRect->Width(), height = pSrcRect->Height(); |
821 LPBYTE pBuffer = pBitmap->GetBuffer(); | 821 LPBYTE pBuffer = pBitmap->GetBuffer(); |
822 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); | 822 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); |
823 ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left, | 823 ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left, |
824 pBitmap->GetHeight() - pSrcRect->bottom, 0, | 824 pBitmap->GetHeight() - pSrcRect->bottom, 0, |
825 pBitmap->GetHeight(), pBuffer, | 825 pBitmap->GetHeight(), pBuffer, |
826 (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); | 826 (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); |
(...skipping 18 matching lines...) Expand all Loading... | |
845 return false; | 845 return false; |
846 | 846 |
847 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); | 847 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); |
848 if ((int64_t)abs(dest_width) * abs(dest_height) < | 848 if ((int64_t)abs(dest_width) * abs(dest_height) < |
849 (int64_t)pBitmap1->GetWidth() * pBitmap1->GetHeight() * 4 || | 849 (int64_t)pBitmap1->GetWidth() * pBitmap1->GetHeight() * 4 || |
850 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) { | 850 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) { |
851 SetStretchBltMode(m_hDC, HALFTONE); | 851 SetStretchBltMode(m_hDC, HALFTONE); |
852 } else { | 852 } else { |
853 SetStretchBltMode(m_hDC, COLORONCOLOR); | 853 SetStretchBltMode(m_hDC, COLORONCOLOR); |
854 } | 854 } |
855 CFX_DIBitmap* pToStrechBitmap = pBitmap; | 855 CFX_DIBitmap* pToStrechBitmap = pBitmap; |
npm
2016/12/05 20:37:23
I think you can use CFX_MaybeOwned here instead of
Tom Sepez
2016/12/05 21:38:13
Yes I can, but its windows-only code so I left it
| |
856 bool del = false; | 856 bool del = false; |
857 if (m_DeviceClass == FXDC_PRINTER && | 857 if (m_DeviceClass == FXDC_PRINTER && |
858 ((int64_t)pBitmap->GetWidth() * pBitmap->GetHeight() > | 858 ((int64_t)pBitmap->GetWidth() * pBitmap->GetHeight() > |
859 (int64_t)abs(dest_width) * abs(dest_height))) { | 859 (int64_t)abs(dest_width) * abs(dest_height))) { |
860 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); | 860 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height).release(); |
861 del = true; | 861 del = true; |
862 } | 862 } |
863 CFX_ByteString toStrechBitmapInfo = | 863 CFX_ByteString toStrechBitmapInfo = |
864 CFX_WindowsDIB::GetBitmapInfo(pToStrechBitmap); | 864 CFX_WindowsDIB::GetBitmapInfo(pToStrechBitmap); |
865 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 0, 0, | 865 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 0, 0, |
866 pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeight(), | 866 pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeight(), |
867 pToStrechBitmap->GetBuffer(), | 867 pToStrechBitmap->GetBuffer(), |
868 (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, | 868 (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, |
869 SRCCOPY); | 869 SRCCOPY); |
870 if (del) | 870 if (del) |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1383 // static | 1383 // static |
1384 IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC) { | 1384 IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC) { |
1385 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); | 1385 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); |
1386 int obj_type = ::GetObjectType(hDC); | 1386 int obj_type = ::GetObjectType(hDC); |
1387 bool use_printer = device_type == DT_RASPRINTER || | 1387 bool use_printer = device_type == DT_RASPRINTER || |
1388 device_type == DT_PLOTTER || obj_type == OBJ_ENHMETADC; | 1388 device_type == DT_PLOTTER || obj_type == OBJ_ENHMETADC; |
1389 if (use_printer) | 1389 if (use_printer) |
1390 return new CGdiPrinterDriver(hDC); | 1390 return new CGdiPrinterDriver(hDC); |
1391 return new CGdiDisplayDriver(hDC); | 1391 return new CGdiDisplayDriver(hDC); |
1392 } | 1392 } |
OLD | NEW |