Vincent Povirk : gdiplus: Support reading image data from device-dependent bitmaps.
Alexandre Julliard
julliard at winehq.org
Mon Dec 14 09:51:17 CST 2009
Module: wine
Branch: master
Commit: 25dcd43e52693c830967e31afcdef0d317ed6ae5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=25dcd43e52693c830967e31afcdef0d317ed6ae5
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Sat Dec 12 17:33:58 2009 -0600
gdiplus: Support reading image data from device-dependent bitmaps.
---
dlls/gdiplus/image.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 44 insertions(+), 1 deletions(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index aa03712..3dbe4da 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -2721,7 +2721,50 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
}
else
{
- FIXME("can only get image data from DIB sections\n");
+ HDC hdc;
+ HBITMAP oldhbm;
+ BITMAPINFO *pbmi;
+ INT src_height, dst_stride;
+ BYTE *dst_bits;
+
+ hdc = CreateCompatibleDC(NULL);
+ oldhbm = SelectObject(hdc, hbm);
+
+ pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
+
+ if (pbmi)
+ {
+ pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ pbmi->bmiHeader.biBitCount = 0;
+
+ GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
+
+ src_height = abs(pbmi->bmiHeader.biHeight);
+
+ if (pbmi->bmiHeader.biHeight > 0)
+ {
+ dst_bits = (BYTE*)lockeddata.Scan0+lockeddata.Stride*(src_height-1);
+ dst_stride = -lockeddata.Stride;
+ }
+ else
+ {
+ dst_bits = lockeddata.Scan0;
+ dst_stride = lockeddata.Stride;
+ }
+
+ for (y=0; y<src_height; y++)
+ {
+ GetDIBits(hdc, hbm, y, 1, dst_bits+dst_stride*y,
+ pbmi, DIB_RGB_COLORS);
+ }
+
+ GdipFree(pbmi);
+ }
+ else
+ retval = OutOfMemory;
+
+ SelectObject(hdc, oldhbm);
+ DeleteDC(hdc);
}
GdipBitmapUnlockBits(*bitmap, &lockeddata);
More information about the wine-cvs
mailing list