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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; | 62 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; |
63 FXDIB_Format format = bAlpha ? (FXDIB_Format)(pbmi->bmiHeader.biBitCount + 0
x200) : (FXDIB_Format)pbmi->bmiHeader.biBitCount; | 63 FXDIB_Format format = bAlpha ? (FXDIB_Format)(pbmi->bmiHeader.biBitCount + 0
x200) : (FXDIB_Format)pbmi->bmiHeader.biBitCount; |
64 FX_BOOL ret = pBitmap->Create(width, height, format); | 64 FX_BOOL ret = pBitmap->Create(width, height, format); |
65 if (!ret) { | 65 if (!ret) { |
66 delete pBitmap; | 66 delete pBitmap; |
67 return NULL; | 67 return NULL; |
68 } | 68 } |
69 FXSYS_memcpy32(pBitmap->GetBuffer(), pData, pitch * height); | 69 FXSYS_memcpy32(pBitmap->GetBuffer(), pData, pitch * height); |
70 if (bBottomUp) { | 70 if (bBottomUp) { |
71 FX_LPBYTE temp_buf = FX_Alloc(FX_BYTE, pitch); | 71 FX_LPBYTE temp_buf = FX_Alloc(FX_BYTE, pitch); |
72 if (!temp_buf) { | |
73 if (pBitmap) { | |
74 delete pBitmap; | |
75 } | |
76 return NULL; | |
77 } | |
78 int top = 0, bottom = height - 1; | 72 int top = 0, bottom = height - 1; |
79 while (top < bottom) { | 73 while (top < bottom) { |
80 FXSYS_memcpy32(temp_buf, pBitmap->GetBuffer() + top * pitch, pitch); | 74 FXSYS_memcpy32(temp_buf, pBitmap->GetBuffer() + top * pitch, pitch); |
81 FXSYS_memcpy32(pBitmap->GetBuffer() + top * pitch, pBitmap->GetBuffe
r() + bottom * pitch, pitch); | 75 FXSYS_memcpy32(pBitmap->GetBuffer() + top * pitch, pBitmap->GetBuffe
r() + bottom * pitch, pitch); |
82 FXSYS_memcpy32(pBitmap->GetBuffer() + bottom * pitch, temp_buf, pitc
h); | 76 FXSYS_memcpy32(pBitmap->GetBuffer() + bottom * pitch, temp_buf, pitc
h); |
83 top ++; | 77 top ++; |
84 bottom --; | 78 bottom --; |
85 } | 79 } |
86 FX_Free(temp_buf); | 80 FX_Free(temp_buf); |
87 temp_buf = NULL; | 81 temp_buf = NULL; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 bmih.biHeight = -height; | 190 bmih.biHeight = -height; |
197 bmih.biCompression = BI_RGB; | 191 bmih.biCompression = BI_RGB; |
198 CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; | 192 CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; |
199 int ret = 0; | 193 int ret = 0; |
200 if (bmih.biBitCount == 1 || bmih.biBitCount == 8) { | 194 if (bmih.biBitCount == 1 || bmih.biBitCount == 8) { |
201 int size = sizeof (BITMAPINFOHEADER) + 8; | 195 int size = sizeof (BITMAPINFOHEADER) + 8; |
202 if (bmih.biBitCount == 8) { | 196 if (bmih.biBitCount == 8) { |
203 size += sizeof (FX_DWORD) * 254; | 197 size += sizeof (FX_DWORD) * 254; |
204 } | 198 } |
205 BITMAPINFO* pbmih = (BITMAPINFO*)FX_Alloc(FX_BYTE, size); | 199 BITMAPINFO* pbmih = (BITMAPINFO*)FX_Alloc(FX_BYTE, size); |
206 if (!pbmih) { | |
207 delete pDIBitmap; | |
208 if (bCreatedDC) { | |
209 DeleteDC(hDC); | |
210 } | |
211 return NULL; | |
212 } | |
213 pbmih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | 200 pbmih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
214 pbmih->bmiHeader.biBitCount = bmih.biBitCount; | 201 pbmih->bmiHeader.biBitCount = bmih.biBitCount; |
215 pbmih->bmiHeader.biCompression = BI_RGB; | 202 pbmih->bmiHeader.biCompression = BI_RGB; |
216 pbmih->bmiHeader.biHeight = -height; | 203 pbmih->bmiHeader.biHeight = -height; |
217 pbmih->bmiHeader.biPlanes = 1; | 204 pbmih->bmiHeader.biPlanes = 1; |
218 pbmih->bmiHeader.biWidth = bmih.biWidth; | 205 pbmih->bmiHeader.biWidth = bmih.biWidth; |
219 if (!pDIBitmap->Create(bmih.biWidth, height, bmih.biBitCount == 1 ? FXDI
B_1bppRgb : FXDIB_8bppRgb)) { | 206 if (!pDIBitmap->Create(bmih.biWidth, height, bmih.biBitCount == 1 ? FXDI
B_1bppRgb : FXDIB_8bppRgb)) { |
220 delete pDIBitmap; | 207 delete pDIBitmap; |
221 FX_Free(pbmih); | 208 FX_Free(pbmih); |
222 if (bCreatedDC) { | 209 if (bCreatedDC) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 273 } |
287 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) | 274 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) |
288 { | 275 { |
289 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY); | 276 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY); |
290 } | 277 } |
291 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) | 278 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) |
292 { | 279 { |
293 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY); | 280 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY); |
294 } | 281 } |
295 #endif | 282 #endif |
OLD | NEW |