On Wed, Apr 26, 2017 at 03:44:01PM +0800, Wei Xie wrote:
Fix cann't insert any HBITMAP in RichEdit control
From 91b46bc9da357b76b8028d058a191743e9a31a32 Mon Sep 17 00:00:00 2001 From: Wei xie <xiewei(a)linuxdeepin.com> Date: Wed, 26 Apr 2017 15:05:59 +0800 Subject: [PATCH 2/4] ole32: Support HBITMAP format in DataCache_GetExtent and DataCache_Draw
Fix cann't insert any HBITMAP in RichEdit control
Signed-off-by: Wei xie <xiewei(a)linuxdeepin.com> --- dlls/ole32/datacache.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
@@ -1908,6 +1926,40 @@ static HRESULT WINAPI DataCache_GetExtent(
return S_OK; } + case CF_BITMAP: + { + HDC hdc; + char dst_bmibuf[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; + BITMAPINFO *dst_info = (BITMAPINFO *)dst_bmibuf; + BITMAPINFOHEADER *info; + LONG x_pels_m, y_pels_m; + + if (cache_entry->stgmedium.tymed != TYMED_GDI) + continue; + + hdc = GetDC(NULL); + memset(dst_info, 0, sizeof(char)*FIELD_OFFSET( BITMAPINFO, bmiColors[256] )); + dst_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + + GetDIBits(hdc, cache_entry->stgmedium.u.hBitmap, 0, 1, NULL, dst_info, DIB_RGB_COLORS); + + info = &dst_info->bmiHeader;
I'm not convinced adding the info variable helps here. Just use dst_info->bmiHeader throughout. Better still drop the 'dst_' and use BITMAPINFO *info = (BITMAPINFO *)bmibuf;
+ x_pels_m = info->biXPelsPerMeter; + y_pels_m = info->biYPelsPerMeter; + + /* Size in units of 0.01mm (ie. MM_HIMETRIC) */ + if (x_pels_m != 0 && y_pels_m != 0) + { + lpsizel->cx = info->biWidth * 100000 / x_pels_m; + lpsizel->cy = info->biHeight * 100000 / y_pels_m; + } + else + { + lpsizel->cx = info->biWidth * 2540 / GetDeviceCaps( hdc, LOGPIXELSX ); + lpsizel->cy = info->biHeight * 2540 / GetDeviceCaps( hdc, LOGPIXELSY ); + }
You need a ReleaseDC(0, hdc);
+ return S_OK; + } } }
-- 2.10.2