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 <windows.h> | 9 #include <windows.h> |
10 #include "../../../include/fxge/fx_ge_win32.h" | 10 #include "../../../include/fxge/fx_ge_win32.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 return pBitmap; | 101 return pBitmap; |
102 } | 102 } |
103 CFX_DIBitmap* CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData) | 103 CFX_DIBitmap* CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData) |
104 { | 104 { |
105 return _FX_WindowsDIB_LoadFromBuf(pbmi, pData, FALSE); | 105 return _FX_WindowsDIB_LoadFromBuf(pbmi, pData, FALSE); |
106 } | 106 } |
107 HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC) | 107 HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC) |
108 { | 108 { |
109 CFX_ByteString info = GetBitmapInfo(pBitmap); | 109 CFX_ByteString info = GetBitmapInfo(pBitmap); |
110 HBITMAP hBitmap = NULL; | 110 HBITMAP hBitmap = NULL; |
111 hBitmap = CreateDIBitmap(hDC, (BITMAPINFOHEADER*)(FX_LPCSTR)info, CBM_INIT, | 111 hBitmap = CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT, |
112 pBitmap->GetBuffer(), (BITMAPINFO*)(FX_LPCSTR)info,
DIB_RGB_COLORS); | 112 pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); |
113 return hBitmap; | 113 return hBitmap; |
114 } | 114 } |
115 void GetBitmapSize(HBITMAP hBitmap, int& w, int& h) | 115 void GetBitmapSize(HBITMAP hBitmap, int& w, int& h) |
116 { | 116 { |
117 BITMAP bmp; | 117 BITMAP bmp; |
118 GetObject(hBitmap, sizeof bmp, &bmp); | 118 GetObject(hBitmap, sizeof bmp, &bmp); |
119 w = bmp.bmWidth; | 119 w = bmp.bmWidth; |
120 h = bmp.bmHeight; | 120 h = bmp.bmHeight; |
121 } | 121 } |
122 CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(FX_LPCWSTR filename) | 122 CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(FX_LPCWSTR filename) |
(...skipping 16 matching lines...) Expand all Loading... |
139 if (!pDIBitmap) { | 139 if (!pDIBitmap) { |
140 DeleteDC(hDC); | 140 DeleteDC(hDC); |
141 return NULL; | 141 return NULL; |
142 } | 142 } |
143 if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { | 143 if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { |
144 delete pDIBitmap; | 144 delete pDIBitmap; |
145 DeleteDC(hDC); | 145 DeleteDC(hDC); |
146 return NULL; | 146 return NULL; |
147 } | 147 } |
148 CFX_ByteString info = GetBitmapInfo(pDIBitmap); | 148 CFX_ByteString info = GetBitmapInfo(pDIBitmap); |
149 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP
INFO*)(FX_LPCSTR)info, DIB_RGB_COLORS); | 149 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP
INFO*)info.c_str(), DIB_RGB_COLORS); |
150 if (!ret) { | 150 if (!ret) { |
151 if (pDIBitmap) { | 151 if (pDIBitmap) { |
152 delete pDIBitmap; | 152 delete pDIBitmap; |
153 } | 153 } |
154 pDIBitmap = NULL; | 154 pDIBitmap = NULL; |
155 } | 155 } |
156 DeleteDC(hDC); | 156 DeleteDC(hDC); |
157 return pDIBitmap; | 157 return pDIBitmap; |
158 } | 158 } |
159 CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) | 159 CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) |
(...skipping 15 matching lines...) Expand all Loading... |
175 if (!pDIBitmap) { | 175 if (!pDIBitmap) { |
176 DeleteDC(hDC); | 176 DeleteDC(hDC); |
177 return NULL; | 177 return NULL; |
178 } | 178 } |
179 if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { | 179 if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { |
180 delete pDIBitmap; | 180 delete pDIBitmap; |
181 DeleteDC(hDC); | 181 DeleteDC(hDC); |
182 return NULL; | 182 return NULL; |
183 } | 183 } |
184 CFX_ByteString info = GetBitmapInfo(pDIBitmap); | 184 CFX_ByteString info = GetBitmapInfo(pDIBitmap); |
185 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP
INFO*)(FX_LPCSTR)info, DIB_RGB_COLORS); | 185 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP
INFO*)info.c_str(), DIB_RGB_COLORS); |
186 if (!ret) { | 186 if (!ret) { |
187 if (pDIBitmap) { | 187 if (pDIBitmap) { |
188 delete pDIBitmap; | 188 delete pDIBitmap; |
189 } | 189 } |
190 pDIBitmap = NULL; | 190 pDIBitmap = NULL; |
191 } | 191 } |
192 DeleteDC(hDC); | 192 DeleteDC(hDC); |
193 return pDIBitmap; | 193 return pDIBitmap; |
194 } | 194 } |
195 CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, HBITMAP hBitmap, FX_DWORD* pP
alette, FX_DWORD palsize) | 195 CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, HBITMAP hBitmap, FX_DWORD* pP
alette, FX_DWORD palsize) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } | 300 } |
301 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) | 301 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) |
302 { | 302 { |
303 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY); | 303 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY); |
304 } | 304 } |
305 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) | 305 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) |
306 { | 306 { |
307 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY); | 307 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY); |
308 } | 308 } |
309 #endif | 309 #endif |
OLD | NEW |