| 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_DESKTOP_ | 8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #include "../../../include/fxge/fx_ge_win32.h" | 10 #include "../../../include/fxge/fx_ge_win32.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 GetBitmapSize(hBitmap, width, height); | 128 GetBitmapSize(hBitmap, width, height); |
| 129 CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; | 129 CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; |
| 130 if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { | 130 if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { |
| 131 delete pDIBitmap; | 131 delete pDIBitmap; |
| 132 DeleteDC(hDC); | 132 DeleteDC(hDC); |
| 133 return NULL; | 133 return NULL; |
| 134 } | 134 } |
| 135 CFX_ByteString info = GetBitmapInfo(pDIBitmap); | 135 CFX_ByteString info = GetBitmapInfo(pDIBitmap); |
| 136 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP
INFO*)info.c_str(), DIB_RGB_COLORS); | 136 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP
INFO*)info.c_str(), DIB_RGB_COLORS); |
| 137 if (!ret) { | 137 if (!ret) { |
| 138 if (pDIBitmap) { | 138 delete pDIBitmap; |
| 139 delete pDIBitmap; | |
| 140 } | |
| 141 pDIBitmap = NULL; | 139 pDIBitmap = NULL; |
| 142 } | 140 } |
| 143 DeleteDC(hDC); | 141 DeleteDC(hDC); |
| 144 return pDIBitmap; | 142 return pDIBitmap; |
| 145 } | 143 } |
| 146 CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) | 144 CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) |
| 147 { | 145 { |
| 148 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatfor
mData(); | 146 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatfor
mData(); |
| 149 if (pPlatform->m_GdiplusExt.IsAvailable()) { | 147 if (pPlatform->m_GdiplusExt.IsAvailable()) { |
| 150 return pPlatform->m_GdiplusExt.LoadDIBitmap(args); | 148 return pPlatform->m_GdiplusExt.LoadDIBitmap(args); |
| 151 } else if (args.flags == WINDIB_OPEN_MEMORY) { | 149 } else if (args.flags == WINDIB_OPEN_MEMORY) { |
| 152 return NULL; | 150 return NULL; |
| 153 } | 151 } |
| 154 HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name, IMAGE_
BITMAP, 0, 0, LR_LOADFROMFILE); | 152 HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name, IMAGE_
BITMAP, 0, 0, LR_LOADFROMFILE); |
| 155 if (hBitmap == NULL) { | 153 if (hBitmap == NULL) { |
| 156 return NULL; | 154 return NULL; |
| 157 } | 155 } |
| 158 HDC hDC = CreateCompatibleDC(NULL); | 156 HDC hDC = CreateCompatibleDC(NULL); |
| 159 int width, height; | 157 int width, height; |
| 160 GetBitmapSize(hBitmap, width, height); | 158 GetBitmapSize(hBitmap, width, height); |
| 161 CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; | 159 CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; |
| 162 if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { | 160 if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { |
| 163 delete pDIBitmap; | 161 delete pDIBitmap; |
| 164 DeleteDC(hDC); | 162 DeleteDC(hDC); |
| 165 return NULL; | 163 return NULL; |
| 166 } | 164 } |
| 167 CFX_ByteString info = GetBitmapInfo(pDIBitmap); | 165 CFX_ByteString info = GetBitmapInfo(pDIBitmap); |
| 168 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP
INFO*)info.c_str(), DIB_RGB_COLORS); | 166 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP
INFO*)info.c_str(), DIB_RGB_COLORS); |
| 169 if (!ret) { | 167 if (!ret) { |
| 170 if (pDIBitmap) { | 168 delete pDIBitmap; |
| 171 delete pDIBitmap; | |
| 172 } | |
| 173 pDIBitmap = NULL; | 169 pDIBitmap = NULL; |
| 174 } | 170 } |
| 175 DeleteDC(hDC); | 171 DeleteDC(hDC); |
| 176 return pDIBitmap; | 172 return pDIBitmap; |
| 177 } | 173 } |
| 178 CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, HBITMAP hBitmap, FX_DWORD* pP
alette, FX_DWORD palsize) | 174 CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, HBITMAP hBitmap, FX_DWORD* pP
alette, FX_DWORD palsize) |
| 179 { | 175 { |
| 180 FX_BOOL bCreatedDC = hDC == NULL; | 176 FX_BOOL bCreatedDC = hDC == NULL; |
| 181 if (hDC == NULL) { | 177 if (hDC == NULL) { |
| 182 hDC = CreateCompatibleDC(NULL); | 178 hDC = CreateCompatibleDC(NULL); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 for (int row = 0; row < height; row ++) { | 230 for (int row = 0; row < height; row ++) { |
| 235 uint8_t* dest_scan = (uint8_t*)(pDIBitmap->GetBuffer() + row * p
itch); | 231 uint8_t* dest_scan = (uint8_t*)(pDIBitmap->GetBuffer() + row * p
itch); |
| 236 for (int col = 0; col < width; col++) { | 232 for (int col = 0; col < width; col++) { |
| 237 dest_scan[3] = 255; | 233 dest_scan[3] = 255; |
| 238 dest_scan += 4; | 234 dest_scan += 4; |
| 239 } | 235 } |
| 240 } | 236 } |
| 241 } | 237 } |
| 242 } | 238 } |
| 243 if (ret == 0) { | 239 if (ret == 0) { |
| 244 if (pDIBitmap) { | 240 delete pDIBitmap; |
| 245 delete pDIBitmap; | |
| 246 } | |
| 247 pDIBitmap = NULL; | 241 pDIBitmap = NULL; |
| 248 } | 242 } |
| 249 if (bCreatedDC) { | 243 if (bCreatedDC) { |
| 250 DeleteDC(hDC); | 244 DeleteDC(hDC); |
| 251 } | 245 } |
| 252 return pDIBitmap; | 246 return pDIBitmap; |
| 253 } | 247 } |
| 254 CFX_WindowsDIB::CFX_WindowsDIB(HDC hDC, int width, int height) | 248 CFX_WindowsDIB::CFX_WindowsDIB(HDC hDC, int width, int height) |
| 255 { | 249 { |
| 256 Create(width, height, FXDIB_Rgb, (uint8_t*)1); | 250 Create(width, height, FXDIB_Rgb, (uint8_t*)1); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 273 } | 267 } |
| 274 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) | 268 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) |
| 275 { | 269 { |
| 276 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY); | 270 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY); |
| 277 } | 271 } |
| 278 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) | 272 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) |
| 279 { | 273 { |
| 280 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY); | 274 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY); |
| 281 } | 275 } |
| 282 #endif | 276 #endif |
| OLD | NEW |