| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 int pitch = (width * pbmi->bmiHeader.biBitCount + 31) / 32 * 4; | 61 int pitch = (width * pbmi->bmiHeader.biBitCount + 31) / 32 * 4; |
| 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(uint8_t, pitch); |
| 72 int top = 0, bottom = height - 1; | 72 int top = 0, bottom = height - 1; |
| 73 while (top < bottom) { | 73 while (top < bottom) { |
| 74 FXSYS_memcpy32(temp_buf, pBitmap->GetBuffer() + top * pitch, pitch); | 74 FXSYS_memcpy32(temp_buf, pBitmap->GetBuffer() + top * pitch, pitch); |
| 75 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); |
| 76 FXSYS_memcpy32(pBitmap->GetBuffer() + bottom * pitch, temp_buf, pitc
h); | 76 FXSYS_memcpy32(pBitmap->GetBuffer() + bottom * pitch, temp_buf, pitc
h); |
| 77 top ++; | 77 top ++; |
| 78 bottom --; | 78 bottom --; |
| 79 } | 79 } |
| 80 FX_Free(temp_buf); | 80 FX_Free(temp_buf); |
| 81 temp_buf = NULL; | 81 temp_buf = NULL; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 int height = abs(bmih.biHeight); | 189 int height = abs(bmih.biHeight); |
| 190 bmih.biHeight = -height; | 190 bmih.biHeight = -height; |
| 191 bmih.biCompression = BI_RGB; | 191 bmih.biCompression = BI_RGB; |
| 192 CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; | 192 CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; |
| 193 int ret = 0; | 193 int ret = 0; |
| 194 if (bmih.biBitCount == 1 || bmih.biBitCount == 8) { | 194 if (bmih.biBitCount == 1 || bmih.biBitCount == 8) { |
| 195 int size = sizeof (BITMAPINFOHEADER) + 8; | 195 int size = sizeof (BITMAPINFOHEADER) + 8; |
| 196 if (bmih.biBitCount == 8) { | 196 if (bmih.biBitCount == 8) { |
| 197 size += sizeof (FX_DWORD) * 254; | 197 size += sizeof (FX_DWORD) * 254; |
| 198 } | 198 } |
| 199 BITMAPINFO* pbmih = (BITMAPINFO*)FX_Alloc(FX_BYTE, size); | 199 BITMAPINFO* pbmih = (BITMAPINFO*)FX_Alloc(uint8_t, size); |
| 200 pbmih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | 200 pbmih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
| 201 pbmih->bmiHeader.biBitCount = bmih.biBitCount; | 201 pbmih->bmiHeader.biBitCount = bmih.biBitCount; |
| 202 pbmih->bmiHeader.biCompression = BI_RGB; | 202 pbmih->bmiHeader.biCompression = BI_RGB; |
| 203 pbmih->bmiHeader.biHeight = -height; | 203 pbmih->bmiHeader.biHeight = -height; |
| 204 pbmih->bmiHeader.biPlanes = 1; | 204 pbmih->bmiHeader.biPlanes = 1; |
| 205 pbmih->bmiHeader.biWidth = bmih.biWidth; | 205 pbmih->bmiHeader.biWidth = bmih.biWidth; |
| 206 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)) { |
| 207 delete pDIBitmap; | 207 delete pDIBitmap; |
| 208 FX_Free(pbmih); | 208 FX_Free(pbmih); |
| 209 if (bCreatedDC) { | 209 if (bCreatedDC) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 225 delete pDIBitmap; | 225 delete pDIBitmap; |
| 226 if (bCreatedDC) { | 226 if (bCreatedDC) { |
| 227 DeleteDC(hDC); | 227 DeleteDC(hDC); |
| 228 } | 228 } |
| 229 return NULL; | 229 return NULL; |
| 230 } | 230 } |
| 231 ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP
INFO*)&bmih, DIB_RGB_COLORS); | 231 ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP
INFO*)&bmih, DIB_RGB_COLORS); |
| 232 if (ret != 0 && bmih.biBitCount == 32) { | 232 if (ret != 0 && bmih.biBitCount == 32) { |
| 233 int pitch = pDIBitmap->GetPitch(); | 233 int pitch = pDIBitmap->GetPitch(); |
| 234 for (int row = 0; row < height; row ++) { | 234 for (int row = 0; row < height; row ++) { |
| 235 FX_BYTE* dest_scan = (FX_BYTE*)(pDIBitmap->GetBuffer() + row * p
itch); | 235 uint8_t* dest_scan = (uint8_t*)(pDIBitmap->GetBuffer() + row * p
itch); |
| 236 for (int col = 0; col < width; col++) { | 236 for (int col = 0; col < width; col++) { |
| 237 dest_scan[3] = 255; | 237 dest_scan[3] = 255; |
| 238 dest_scan += 4; | 238 dest_scan += 4; |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 if (ret == 0) { | 243 if (ret == 0) { |
| 244 if (pDIBitmap) { | 244 if (pDIBitmap) { |
| 245 delete pDIBitmap; | 245 delete pDIBitmap; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 273 } | 273 } |
| 274 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) | 274 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) |
| 275 { | 275 { |
| 276 ::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); |
| 277 } | 277 } |
| 278 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) | 278 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) |
| 279 { | 279 { |
| 280 ::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); |
| 281 } | 281 } |
| 282 #endif | 282 #endif |
| OLD | NEW |