Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: core/src/fxge/win32/fx_win32_dib.cpp

Issue 1062863006: Remove checks in fxge/{apple,win32,skia,dib} now that FX_NEW cant return 0 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix missing |new| typo. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxge/win32/fx_win32_device.cpp ('k') | core/src/fxge/win32/fx_win32_dwrite.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData, FX_BOOL bAlpha) 52 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData, FX_BOOL bAlpha)
53 { 53 {
54 int width = pbmi->bmiHeader.biWidth; 54 int width = pbmi->bmiHeader.biWidth;
55 int height = pbmi->bmiHeader.biHeight; 55 int height = pbmi->bmiHeader.biHeight;
56 BOOL bBottomUp = TRUE; 56 BOOL bBottomUp = TRUE;
57 if (height < 0) { 57 if (height < 0) {
58 height = -height; 58 height = -height;
59 bBottomUp = FALSE; 59 bBottomUp = FALSE;
60 } 60 }
61 int pitch = (width * pbmi->bmiHeader.biBitCount + 31) / 32 * 4; 61 int pitch = (width * pbmi->bmiHeader.biBitCount + 31) / 32 * 4;
62 CFX_DIBitmap* pBitmap = FX_NEW CFX_DIBitmap; 62 CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
63 if (!pBitmap) {
64 return NULL;
65 }
66 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;
67 FX_BOOL ret = pBitmap->Create(width, height, format); 64 FX_BOOL ret = pBitmap->Create(width, height, format);
68 if (!ret) { 65 if (!ret) {
69 delete pBitmap; 66 delete pBitmap;
70 return NULL; 67 return NULL;
71 } 68 }
72 FXSYS_memcpy32(pBitmap->GetBuffer(), pData, pitch * height); 69 FXSYS_memcpy32(pBitmap->GetBuffer(), pData, pitch * height);
73 if (bBottomUp) { 70 if (bBottomUp) {
74 FX_LPBYTE temp_buf = FX_Alloc(FX_BYTE, pitch); 71 FX_LPBYTE temp_buf = FX_Alloc(FX_BYTE, pitch);
75 if (!temp_buf) { 72 if (!temp_buf) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 args.path_name = filename; 125 args.path_name = filename;
129 return pPlatform->m_GdiplusExt.LoadDIBitmap(args); 126 return pPlatform->m_GdiplusExt.LoadDIBitmap(args);
130 } 127 }
131 HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)filename, IMAGE_BITMAP , 0, 0, LR_LOADFROMFILE); 128 HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)filename, IMAGE_BITMAP , 0, 0, LR_LOADFROMFILE);
132 if (hBitmap == NULL) { 129 if (hBitmap == NULL) {
133 return NULL; 130 return NULL;
134 } 131 }
135 HDC hDC = CreateCompatibleDC(NULL); 132 HDC hDC = CreateCompatibleDC(NULL);
136 int width, height; 133 int width, height;
137 GetBitmapSize(hBitmap, width, height); 134 GetBitmapSize(hBitmap, width, height);
138 CFX_DIBitmap* pDIBitmap = FX_NEW CFX_DIBitmap; 135 CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap;
139 if (!pDIBitmap) {
140 DeleteDC(hDC);
141 return NULL;
142 }
143 if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { 136 if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) {
144 delete pDIBitmap; 137 delete pDIBitmap;
145 DeleteDC(hDC); 138 DeleteDC(hDC);
146 return NULL; 139 return NULL;
147 } 140 }
148 CFX_ByteString info = GetBitmapInfo(pDIBitmap); 141 CFX_ByteString info = GetBitmapInfo(pDIBitmap);
149 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP INFO*)info.c_str(), DIB_RGB_COLORS); 142 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP INFO*)info.c_str(), DIB_RGB_COLORS);
150 if (!ret) { 143 if (!ret) {
151 if (pDIBitmap) { 144 if (pDIBitmap) {
152 delete pDIBitmap; 145 delete pDIBitmap;
(...skipping 11 matching lines...) Expand all
164 } else if (args.flags == WINDIB_OPEN_MEMORY) { 157 } else if (args.flags == WINDIB_OPEN_MEMORY) {
165 return NULL; 158 return NULL;
166 } 159 }
167 HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name, IMAGE_ BITMAP, 0, 0, LR_LOADFROMFILE); 160 HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name, IMAGE_ BITMAP, 0, 0, LR_LOADFROMFILE);
168 if (hBitmap == NULL) { 161 if (hBitmap == NULL) {
169 return NULL; 162 return NULL;
170 } 163 }
171 HDC hDC = CreateCompatibleDC(NULL); 164 HDC hDC = CreateCompatibleDC(NULL);
172 int width, height; 165 int width, height;
173 GetBitmapSize(hBitmap, width, height); 166 GetBitmapSize(hBitmap, width, height);
174 CFX_DIBitmap* pDIBitmap = FX_NEW CFX_DIBitmap; 167 CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap;
175 if (!pDIBitmap) {
176 DeleteDC(hDC);
177 return NULL;
178 }
179 if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { 168 if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) {
180 delete pDIBitmap; 169 delete pDIBitmap;
181 DeleteDC(hDC); 170 DeleteDC(hDC);
182 return NULL; 171 return NULL;
183 } 172 }
184 CFX_ByteString info = GetBitmapInfo(pDIBitmap); 173 CFX_ByteString info = GetBitmapInfo(pDIBitmap);
185 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP INFO*)info.c_str(), DIB_RGB_COLORS); 174 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAP INFO*)info.c_str(), DIB_RGB_COLORS);
186 if (!ret) { 175 if (!ret) {
187 if (pDIBitmap) { 176 if (pDIBitmap) {
188 delete pDIBitmap; 177 delete pDIBitmap;
(...skipping 10 matching lines...) Expand all
199 hDC = CreateCompatibleDC(NULL); 188 hDC = CreateCompatibleDC(NULL);
200 } 189 }
201 BITMAPINFOHEADER bmih; 190 BITMAPINFOHEADER bmih;
202 FXSYS_memset32(&bmih, 0, sizeof bmih); 191 FXSYS_memset32(&bmih, 0, sizeof bmih);
203 bmih.biSize = sizeof bmih; 192 bmih.biSize = sizeof bmih;
204 GetDIBits(hDC, hBitmap, 0, 0, NULL, (BITMAPINFO*)&bmih, DIB_RGB_COLORS); 193 GetDIBits(hDC, hBitmap, 0, 0, NULL, (BITMAPINFO*)&bmih, DIB_RGB_COLORS);
205 int width = bmih.biWidth; 194 int width = bmih.biWidth;
206 int height = abs(bmih.biHeight); 195 int height = abs(bmih.biHeight);
207 bmih.biHeight = -height; 196 bmih.biHeight = -height;
208 bmih.biCompression = BI_RGB; 197 bmih.biCompression = BI_RGB;
209 CFX_DIBitmap* pDIBitmap = FX_NEW CFX_DIBitmap; 198 CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap;
210 if (!pDIBitmap) {
211 return NULL;
212 }
213 int ret = 0; 199 int ret = 0;
214 if (bmih.biBitCount == 1 || bmih.biBitCount == 8) { 200 if (bmih.biBitCount == 1 || bmih.biBitCount == 8) {
215 int size = sizeof (BITMAPINFOHEADER) + 8; 201 int size = sizeof (BITMAPINFOHEADER) + 8;
216 if (bmih.biBitCount == 8) { 202 if (bmih.biBitCount == 8) {
217 size += sizeof (FX_DWORD) * 254; 203 size += sizeof (FX_DWORD) * 254;
218 } 204 }
219 BITMAPINFO* pbmih = (BITMAPINFO*)FX_Alloc(FX_BYTE, size); 205 BITMAPINFO* pbmih = (BITMAPINFO*)FX_Alloc(FX_BYTE, size);
220 if (!pbmih) { 206 if (!pbmih) {
221 delete pDIBitmap; 207 delete pDIBitmap;
222 if (bCreatedDC) { 208 if (bCreatedDC) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 286 }
301 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) 287 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top)
302 { 288 {
303 ::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);
304 } 290 }
305 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) 291 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top)
306 { 292 {
307 ::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);
308 } 294 }
309 #endif 295 #endif
OLDNEW
« no previous file with comments | « core/src/fxge/win32/fx_win32_device.cpp ('k') | core/src/fxge/win32/fx_win32_dwrite.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698