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