gdi32: Copy a DIB section as a DIB section in BITMAP_CopyBitmap.
This commit is contained in:
parent
91d91afb7d
commit
1914f3ecae
|
@ -510,17 +510,41 @@ LONG WINAPI SetBitmapBits(
|
||||||
*/
|
*/
|
||||||
HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap)
|
HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap)
|
||||||
{
|
{
|
||||||
HBITMAP res = 0;
|
HBITMAP res;
|
||||||
BITMAP bm;
|
DIBSECTION dib;
|
||||||
|
DWORD size;
|
||||||
|
|
||||||
if (!GetObjectW( hbitmap, sizeof(bm), &bm )) return 0;
|
if (!(size = GetObjectW( hbitmap, sizeof(dib), &dib ))) return 0;
|
||||||
res = CreateBitmapIndirect(&bm);
|
|
||||||
|
|
||||||
|
if (size == sizeof(DIBSECTION))
|
||||||
|
{
|
||||||
|
void *bits;
|
||||||
|
BITMAPINFO *bi;
|
||||||
|
HDC dc = CreateCompatibleDC( NULL );
|
||||||
|
|
||||||
|
if (!dc) return 0;
|
||||||
|
if (!(bi = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] ))))
|
||||||
|
{
|
||||||
|
DeleteDC( dc );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
bi->bmiHeader = dib.dsBmih;
|
||||||
|
|
||||||
|
/* Get the color table or the color masks */
|
||||||
|
GetDIBits( dc, hbitmap, 0, 0, NULL, bi, DIB_RGB_COLORS );
|
||||||
|
|
||||||
|
res = CreateDIBSection( dc, bi, DIB_RGB_COLORS, &bits, NULL, 0 );
|
||||||
|
if (res) SetDIBits( dc, res, 0, dib.dsBm.bmHeight, dib.dsBm.bmBits, bi, DIB_RGB_COLORS );
|
||||||
|
HeapFree( GetProcessHeap(), 0, bi );
|
||||||
|
DeleteDC( dc );
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = CreateBitmapIndirect( &dib.dsBm );
|
||||||
if(res) {
|
if(res) {
|
||||||
char *buf = HeapAlloc( GetProcessHeap(), 0, bm.bmWidthBytes *
|
char *buf = HeapAlloc( GetProcessHeap(), 0, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight );
|
||||||
bm.bmHeight );
|
GetBitmapBits (hbitmap, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight, buf);
|
||||||
GetBitmapBits (hbitmap, bm.bmWidthBytes * bm.bmHeight, buf);
|
SetBitmapBits (res, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight, buf);
|
||||||
SetBitmapBits (res, bm.bmWidthBytes * bm.bmHeight, buf);
|
|
||||||
HeapFree( GetProcessHeap(), 0, buf );
|
HeapFree( GetProcessHeap(), 0, buf );
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
Loading…
Reference in New Issue