| 1272 | } |
| 1273 | |
| 1274 | bool GetDataFromBitmap(HDC hdc, HBITMAP hbm, BYTE*& pBytes, int& width, int& height, int& bpp) |
| 1275 | { |
| 1276 | // Man what the hell |
| 1277 | BITMAP bm; |
| 1278 | BITMAPINFO bmi; |
| 1279 | |
| 1280 | ZeroMemory(&bm, sizeof bm); |
| 1281 | if (!GetObject(hbm, sizeof bm, &bm)) { |
| 1282 | DbgPrintW("Cannot obtain pointer to bitmap!"); |
| 1283 | return false; |
| 1284 | } |
| 1285 | |
| 1286 | width = bm.bmWidth; |
| 1287 | height = bm.bmHeight; |
| 1288 | bpp = bm.bmBitsPixel; |
| 1289 | |
| 1290 | ZeroMemory(&bmi, sizeof bmi); |
| 1291 | bmi.bmiHeader.biSize = sizeof bmi.bmiHeader; |
| 1292 | bmi.bmiHeader.biWidth = bm.bmWidth; |
| 1293 | bmi.bmiHeader.biHeight = bm.bmHeight; |
| 1294 | bmi.bmiHeader.biPlanes = 1; |
| 1295 | bmi.bmiHeader.biBitCount = bm.bmBitsPixel; |
| 1296 | bmi.bmiHeader.biCompression = BI_RGB; |
| 1297 | bmi.bmiHeader.biSizeImage = 0; |
| 1298 | |
| 1299 | int pitch = (((bm.bmWidth * bm.bmBitsPixel) + 31) & ~31) >> 3; |
| 1300 | |
| 1301 | pBytes = new BYTE[pitch * bm.bmHeight]; |
| 1302 | |
| 1303 | if (!GetDIBits(hdc, hbm, 0, bm.bmHeight, pBytes, &bmi, DIB_RGB_COLORS)) |
| 1304 | { |
| 1305 | DbgPrintW("Error, can't get DI bits for bitmap!"); |
| 1306 | delete[] pBytes; |
| 1307 | return false; |
| 1308 | } |
| 1309 | |
| 1310 | // swap in software, because in Windows NT 3.1, using negative height images is glitchy |
| 1311 | for (int y1 = 0, y2 = bm.bmHeight - 1; y1 < y2; y1++, y2--) |
| 1312 | { |
| 1313 | BYTE *scan1 = &pBytes[y1 * pitch], *scan2 = &pBytes[y2 * pitch]; |
| 1314 | DWORD *scan1D = (DWORD*) scan1, *scan2D = (DWORD*) scan2; |
| 1315 | |
| 1316 | for (int x = 0; x * 4 < pitch; x++) { |
| 1317 | std::swap(scan1D[x], scan2D[x]); |
| 1318 | } |
| 1319 | } |
| 1320 | |
| 1321 | return true; |
| 1322 | } |
| 1323 | |
| 1324 | std::string CutOutURLPath(const std::string& url) |
| 1325 | { |
no test coverage detected