4 * Copyright 1993 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "gdi_private.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(bitmap);
35 static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc );
36 static INT BITMAP_GetObject( HGDIOBJ handle, INT count, LPVOID buffer );
37 static BOOL BITMAP_DeleteObject( HGDIOBJ handle );
39 static const struct gdi_obj_funcs bitmap_funcs =
41 BITMAP_SelectObject, /* pSelectObject */
42 BITMAP_GetObject, /* pGetObjectA */
43 BITMAP_GetObject, /* pGetObjectW */
44 NULL, /* pUnrealizeObject */
45 BITMAP_DeleteObject /* pDeleteObject */
49 /***********************************************************************
50 * null driver fallback implementations
53 LONG nulldrv_SetBitmapBits( HBITMAP bitmap, const void *bits, LONG size )
55 BITMAPOBJ *bmp = GDI_GetObjPtr( bitmap, OBJ_BITMAP );
57 if (!bmp->bitmap.bmBits)
59 LONG total = bmp->bitmap.bmHeight * bmp->bitmap.bmWidthBytes; /* alloc enough for entire bitmap */
60 if (!(bmp->bitmap.bmBits = HeapAlloc( GetProcessHeap(), 0, total )))
62 GDI_ReleaseObj( bitmap );
65 if (size < total) memset( (char *)bmp->bitmap.bmBits + size, 0, total - size );
67 memcpy( bmp->bitmap.bmBits, bits, size );
68 GDI_ReleaseObj( bitmap );
72 DWORD nulldrv_GetImage( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *info,
73 struct gdi_image_bits *bits, struct bitblt_coords *src )
76 int height, width_bytes;
78 if (!hbitmap) return ERROR_NOT_SUPPORTED;
79 if (!(bmp = GDI_GetObjPtr( hbitmap, OBJ_BITMAP ))) return ERROR_INVALID_HANDLE;
81 info->bmiHeader.biSize = sizeof(info->bmiHeader);
82 info->bmiHeader.biPlanes = 1;
83 info->bmiHeader.biBitCount = bmp->bitmap.bmBitsPixel;
84 info->bmiHeader.biCompression = BI_RGB;
85 info->bmiHeader.biXPelsPerMeter = 0;
86 info->bmiHeader.biYPelsPerMeter = 0;
87 info->bmiHeader.biClrUsed = 0;
88 info->bmiHeader.biClrImportant = 0;
91 height = src->visrect.bottom - src->visrect.top;
92 width_bytes = get_dib_stride( bmp->bitmap.bmWidth, bmp->bitmap.bmBitsPixel );
93 info->bmiHeader.biWidth = bmp->bitmap.bmWidth;
94 info->bmiHeader.biHeight = -height;
95 info->bmiHeader.biSizeImage = height * width_bytes;
97 /* make the source rectangle relative to the returned bits */
98 src->y -= src->visrect.top;
99 offset_rect( &src->visrect, 0, -src->visrect.top );
101 if (bmp->bitmap.bmBits && bmp->bitmap.bmWidthBytes == width_bytes)
103 bits->ptr = (char *)bmp->bitmap.bmBits + src->visrect.top * width_bytes;
104 bits->is_copy = FALSE;
109 bits->ptr = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage );
110 bits->is_copy = TRUE;
111 bits->free = free_heap_bits;
112 if (bmp->bitmap.bmBits)
114 /* fixup the line alignment */
115 char *src = bmp->bitmap.bmBits, *dst = bits->ptr;
116 for ( ; height > 0; height--, src += bmp->bitmap.bmWidthBytes, dst += width_bytes)
118 memcpy( dst, src, bmp->bitmap.bmWidthBytes );
119 memset( dst + bmp->bitmap.bmWidthBytes, 0, width_bytes - bmp->bitmap.bmWidthBytes );
122 else memset( bits->ptr, 0, info->bmiHeader.biSizeImage );
125 GDI_ReleaseObj( hbitmap );
126 return ERROR_SUCCESS;
130 /******************************************************************************
131 * CreateBitmap [GDI32.@]
133 * Creates a bitmap with the specified info.
136 * width [I] bitmap width
137 * height [I] bitmap height
138 * planes [I] Number of color planes
139 * bpp [I] Number of bits to identify a color
140 * bits [I] Pointer to array containing color data
143 * Success: Handle to bitmap
146 HBITMAP WINAPI CreateBitmap( INT width, INT height, UINT planes,
147 UINT bpp, LPCVOID bits )
153 bm.bmHeight = height;
154 bm.bmWidthBytes = get_bitmap_stride( width, bpp );
155 bm.bmPlanes = planes;
156 bm.bmBitsPixel = bpp;
157 bm.bmBits = (LPVOID)bits;
159 return CreateBitmapIndirect( &bm );
162 /******************************************************************************
163 * CreateCompatibleBitmap [GDI32.@]
165 * Creates a bitmap compatible with the DC.
168 * hdc [I] Handle to device context
169 * width [I] Width of bitmap
170 * height [I] Height of bitmap
173 * Success: Handle to bitmap
176 HBITMAP WINAPI CreateCompatibleBitmap( HDC hdc, INT width, INT height)
180 TRACE("(%p,%d,%d) =\n", hdc, width, height);
182 if (GetObjectType( hdc ) != OBJ_MEMDC)
184 hbmpRet = CreateBitmap(width, height,
185 GetDeviceCaps(hdc, PLANES),
186 GetDeviceCaps(hdc, BITSPIXEL),
192 HBITMAP bitmap = GetCurrentObject( hdc, OBJ_BITMAP );
193 INT size = GetObjectW( bitmap, sizeof(dib), &dib );
197 if (size == sizeof(BITMAP))
199 /* A device-dependent bitmap is selected in the DC */
200 hbmpRet = CreateBitmap(width, height,
202 dib.dsBm.bmBitsPixel,
207 /* A DIB section is selected in the DC */
211 /* Allocate memory for a BITMAPINFOHEADER structure and a
212 color table. The maximum number of colors in a color table
213 is 256 which corresponds to a bitmap with depth 8.
214 Bitmaps with higher depths don't have color tables. */
215 bi = HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
219 bi->bmiHeader.biSize = sizeof(bi->bmiHeader);
220 bi->bmiHeader.biWidth = width;
221 bi->bmiHeader.biHeight = height;
222 bi->bmiHeader.biPlanes = dib.dsBmih.biPlanes;
223 bi->bmiHeader.biBitCount = dib.dsBmih.biBitCount;
224 bi->bmiHeader.biCompression = dib.dsBmih.biCompression;
225 bi->bmiHeader.biSizeImage = 0;
226 bi->bmiHeader.biXPelsPerMeter = dib.dsBmih.biXPelsPerMeter;
227 bi->bmiHeader.biYPelsPerMeter = dib.dsBmih.biYPelsPerMeter;
228 bi->bmiHeader.biClrUsed = dib.dsBmih.biClrUsed;
229 bi->bmiHeader.biClrImportant = dib.dsBmih.biClrImportant;
231 if (bi->bmiHeader.biCompression == BI_BITFIELDS)
233 /* Copy the color masks */
234 CopyMemory(bi->bmiColors, dib.dsBitfields, 3 * sizeof(DWORD));
236 else if (bi->bmiHeader.biBitCount <= 8)
238 /* Copy the color table */
239 GetDIBColorTable(hdc, 0, 256, bi->bmiColors);
242 hbmpRet = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
243 HeapFree(GetProcessHeap(), 0, bi);
248 TRACE("\t\t%p\n", hbmpRet);
253 /******************************************************************************
254 * CreateBitmapIndirect [GDI32.@]
256 * Creates a bitmap with the specified info.
259 * bmp [I] Pointer to the bitmap info describing the bitmap
262 * Success: Handle to bitmap
263 * Failure: NULL. Use GetLastError() to determine the cause.
266 * If a width or height of 0 are given, a 1x1 monochrome bitmap is returned.
268 HBITMAP WINAPI CreateBitmapIndirect( const BITMAP *bmp )
274 if (!bmp || bmp->bmType)
276 SetLastError( ERROR_INVALID_PARAMETER );
280 if (bmp->bmWidth > 0x7ffffff || bmp->bmHeight > 0x7ffffff)
282 SetLastError( ERROR_INVALID_PARAMETER );
288 if (!bm.bmWidth || !bm.bmHeight)
290 return GetStockObject( DEFAULT_BITMAP );
295 bm.bmHeight = -bm.bmHeight;
297 bm.bmWidth = -bm.bmWidth;
300 if (bm.bmPlanes != 1)
302 FIXME("planes = %d\n", bm.bmPlanes);
303 SetLastError( ERROR_INVALID_PARAMETER );
307 /* Windows only uses 1, 4, 8, 16, 24 and 32 bpp */
308 if(bm.bmBitsPixel == 1) bm.bmBitsPixel = 1;
309 else if(bm.bmBitsPixel <= 4) bm.bmBitsPixel = 4;
310 else if(bm.bmBitsPixel <= 8) bm.bmBitsPixel = 8;
311 else if(bm.bmBitsPixel <= 16) bm.bmBitsPixel = 16;
312 else if(bm.bmBitsPixel <= 24) bm.bmBitsPixel = 24;
313 else if(bm.bmBitsPixel <= 32) bm.bmBitsPixel = 32;
315 WARN("Invalid bmBitsPixel %d, returning ERROR_INVALID_PARAMETER\n", bm.bmBitsPixel);
316 SetLastError(ERROR_INVALID_PARAMETER);
320 /* Windows ignores the provided bm.bmWidthBytes */
321 bm.bmWidthBytes = get_bitmap_stride( bm.bmWidth, bm.bmBitsPixel );
322 /* XP doesn't allow to create bitmaps larger than 128 Mb */
323 if (bm.bmHeight > 128 * 1024 * 1024 / bm.bmWidthBytes)
325 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
329 /* Create the BITMAPOBJ */
330 if (!(bmpobj = HeapAlloc( GetProcessHeap(), 0, sizeof(*bmpobj) )))
332 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
339 bmpobj->bitmap.bmBits = NULL;
340 bmpobj->funcs = &null_driver;
342 bmpobj->color_table = NULL;
343 bmpobj->nb_colors = 0;
345 if (!(hbitmap = alloc_gdi_handle( &bmpobj->header, OBJ_BITMAP, &bitmap_funcs )))
347 HeapFree( GetProcessHeap(), 0, bmpobj );
352 SetBitmapBits( hbitmap, bm.bmHeight * bm.bmWidthBytes, bm.bmBits );
354 TRACE("%dx%d, %d colors returning %p\n", bm.bmWidth, bm.bmHeight,
355 1 << (bm.bmPlanes * bm.bmBitsPixel), hbitmap);
361 /***********************************************************************
362 * GetBitmapBits [GDI32.@]
364 * Copies bitmap bits of bitmap to buffer.
367 * Success: Number of bytes copied
370 LONG WINAPI GetBitmapBits(
371 HBITMAP hbitmap, /* [in] Handle to bitmap */
372 LONG count, /* [in] Number of bytes to copy */
373 LPVOID bits) /* [out] Pointer to buffer to receive bits */
375 char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
376 BITMAPINFO *info = (BITMAPINFO *)buffer;
377 struct gdi_image_bits src_bits;
378 struct bitblt_coords src;
379 int dst_stride, max, ret;
380 BITMAPOBJ *bmp = GDI_GetObjPtr( hbitmap, OBJ_BITMAP );
384 if (bmp->dib) dst_stride = get_bitmap_stride( bmp->dib->dsBmih.biWidth, bmp->dib->dsBmih.biBitCount );
385 else dst_stride = get_bitmap_stride( bmp->bitmap.bmWidth, bmp->bitmap.bmBitsPixel );
387 ret = max = dst_stride * bmp->bitmap.bmHeight;
388 if (!bits) goto done;
389 if (count > max) count = max;
392 src.visrect.left = 0;
393 src.visrect.right = bmp->bitmap.bmWidth;
395 src.visrect.bottom = (count + dst_stride - 1) / dst_stride;
397 src.width = src.visrect.right - src.visrect.left;
398 src.height = src.visrect.bottom - src.visrect.top;
400 if (!bmp->funcs->pGetImage( NULL, hbitmap, info, &src_bits, &src ))
402 const char *src_ptr = src_bits.ptr;
403 int src_stride = get_dib_stride( info->bmiHeader.biWidth, info->bmiHeader.biBitCount );
405 /* GetBitmapBits returns 16-bit aligned data */
407 if (info->bmiHeader.biHeight > 0)
409 src_ptr += (info->bmiHeader.biHeight - 1) * src_stride;
410 src_stride = -src_stride;
412 src_ptr += src.visrect.top * src_stride;
414 if (src_stride == dst_stride) memcpy( bits, src_ptr, count );
415 else while (count > 0)
417 memcpy( bits, src_ptr, min( count, dst_stride ) );
418 src_ptr += src_stride;
419 bits = (char *)bits + dst_stride;
422 if (src_bits.free) src_bits.free( &src_bits );
427 GDI_ReleaseObj( hbitmap );
432 /******************************************************************************
433 * SetBitmapBits [GDI32.@]
435 * Sets bits of color data for a bitmap.
438 * Success: Number of bytes used in setting the bitmap bits
441 LONG WINAPI SetBitmapBits(
442 HBITMAP hbitmap, /* [in] Handle to bitmap */
443 LONG count, /* [in] Number of bytes in bitmap array */
444 LPCVOID bits) /* [in] Address of array with bitmap bits */
451 bmp = GDI_GetObjPtr( hbitmap, OBJ_BITMAP );
455 WARN("(%d): Negative number of bytes passed???\n", count );
459 if (bmp->dib) /* simply copy the bits into the DIB */
461 DIBSECTION *dib = bmp->dib;
462 char *dest = dib->dsBm.bmBits;
463 LONG max = dib->dsBm.bmWidthBytes * dib->dsBm.bmHeight;
464 if (count > max) count = max;
467 if (bmp->dib->dsBmih.biHeight >= 0) /* not top-down, need to flip contents vertically */
469 dest += dib->dsBm.bmWidthBytes * dib->dsBm.bmHeight;
472 dest -= dib->dsBm.bmWidthBytes;
473 memcpy( dest, bits, min( count, dib->dsBm.bmWidthBytes ) );
474 bits = (const char *)bits + dib->dsBm.bmWidthBytes;
475 count -= dib->dsBm.bmWidthBytes;
478 else memcpy( dest, bits, count );
480 GDI_ReleaseObj( hbitmap );
484 /* Only get entire lines */
485 height = count / bmp->bitmap.bmWidthBytes;
486 if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
487 count = height * bmp->bitmap.bmWidthBytes;
489 TRACE("(%p, %d, %p) %dx%d %d colors fetched height: %d\n",
490 hbitmap, count, bits, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
491 1 << bmp->bitmap.bmBitsPixel, height );
493 ret = bmp->funcs->pSetBitmapBits( hbitmap, bits, count );
494 GDI_ReleaseObj( hbitmap );
498 /**********************************************************************
502 HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap)
506 BITMAPOBJ *bmp = GDI_GetObjPtr( hbitmap, OBJ_BITMAP );
516 GDI_ReleaseObj( hbitmap );
517 dc = CreateCompatibleDC( NULL );
520 if (!(bi = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] ))))
525 bi->bmiHeader = dib.dsBmih;
527 /* Get the color table or the color masks */
528 GetDIBits( dc, hbitmap, 0, 0, NULL, bi, DIB_RGB_COLORS );
529 bi->bmiHeader.biHeight = dib.dsBmih.biHeight;
531 res = CreateDIBSection( dc, bi, DIB_RGB_COLORS, &bits, NULL, 0 );
532 if (res) SetDIBits( dc, res, 0, dib.dsBm.bmHeight, dib.dsBm.bmBits, bi, DIB_RGB_COLORS );
533 HeapFree( GetProcessHeap(), 0, bi );
537 dib.dsBm = bmp->bitmap;
538 dib.dsBm.bmBits = NULL;
539 GDI_ReleaseObj( hbitmap );
541 res = CreateBitmapIndirect( &dib.dsBm );
543 char *buf = HeapAlloc( GetProcessHeap(), 0, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight );
544 GetBitmapBits (hbitmap, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight, buf);
545 SetBitmapBits (res, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight, buf);
546 HeapFree( GetProcessHeap(), 0, buf );
552 /***********************************************************************
555 * Set the type of DC that owns the bitmap. This is used when the
556 * bitmap is selected into a device to initialize the bitmap function
559 BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, PHYSDEV physdev )
564 /* never set the owner of the stock bitmap since it can be selected in multiple DCs */
565 if (hbitmap == GetStockObject(DEFAULT_BITMAP)) return TRUE;
567 if (!(bitmap = GDI_GetObjPtr( hbitmap, OBJ_BITMAP ))) return FALSE;
569 if (!bitmap->dib && bitmap->funcs != physdev->funcs)
571 /* we can only change from the null driver to some other driver */
572 if (bitmap->funcs == &null_driver)
574 if (physdev->funcs->pCreateBitmap)
576 ret = physdev->funcs->pCreateBitmap( physdev, hbitmap, bitmap->bitmap.bmBits );
577 if (ret) bitmap->funcs = physdev->funcs;
581 WARN( "Trying to select bitmap %p in DC that doesn't support it\n", hbitmap );
587 FIXME( "Trying to select bitmap %p in different DC type\n", hbitmap );
591 GDI_ReleaseObj( hbitmap );
596 /***********************************************************************
597 * BITMAP_SelectObject
599 static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
604 PHYSDEV physdev = NULL, old_physdev = NULL;
606 if (!(dc = get_dc_ptr( hdc ))) return 0;
608 if (GetObjectType( hdc ) != OBJ_MEMDC)
614 if (handle == dc->hBitmap) goto done; /* nothing to do */
616 if (!(bitmap = GDI_GetObjPtr( handle, OBJ_BITMAP )))
622 if (bitmap->header.selcount && (handle != GetStockObject(DEFAULT_BITMAP)))
624 WARN( "Bitmap already selected in another DC\n" );
625 GDI_ReleaseObj( handle );
630 old_physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
631 if(old_physdev == &dc->dibdrv.dev)
632 pop_dc_driver( dc, old_physdev );
636 physdev = &dc->dibdrv.dev;
637 push_dc_driver( dc, physdev, physdev->funcs );
640 physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
642 if (!BITMAP_SetOwnerDC( handle, physdev ))
644 GDI_ReleaseObj( handle );
648 if (!physdev->funcs->pSelectBitmap( physdev, handle ))
650 GDI_ReleaseObj( handle );
655 dc->hBitmap = handle;
656 GDI_inc_ref_count( handle );
658 dc->vis_rect.left = 0;
659 dc->vis_rect.top = 0;
660 dc->vis_rect.right = bitmap->bitmap.bmWidth;
661 dc->vis_rect.bottom = bitmap->bitmap.bmHeight;
662 SetRectRgn( dc->hVisRgn, 0, 0, bitmap->bitmap.bmWidth, bitmap->bitmap.bmHeight);
663 GDI_ReleaseObj( handle );
665 GDI_dec_ref_count( ret );
671 if(physdev == &dc->dibdrv.dev) pop_dc_driver( dc, physdev );
672 if(old_physdev == &dc->dibdrv.dev) push_dc_driver( dc, old_physdev, old_physdev->funcs );
674 release_dc_ptr( dc );
679 /***********************************************************************
680 * BITMAP_DeleteObject
682 static BOOL BITMAP_DeleteObject( HGDIOBJ handle )
684 const DC_FUNCTIONS *funcs;
685 BITMAPOBJ *bmp = GDI_GetObjPtr( handle, OBJ_BITMAP );
687 if (!bmp) return FALSE;
689 GDI_ReleaseObj( handle );
691 funcs->pDeleteBitmap( handle );
693 if (!(bmp = free_gdi_handle( handle ))) return FALSE;
695 HeapFree( GetProcessHeap(), 0, bmp->bitmap.bmBits );
699 DIBSECTION *dib = bmp->dib;
701 if (dib->dsBm.bmBits)
705 SYSTEM_INFO SystemInfo;
706 GetSystemInfo( &SystemInfo );
707 UnmapViewOfFile( (char *)dib->dsBm.bmBits -
708 (dib->dsOffset % SystemInfo.dwAllocationGranularity) );
710 else if (!dib->dsOffset)
711 VirtualFree(dib->dsBm.bmBits, 0L, MEM_RELEASE );
713 HeapFree(GetProcessHeap(), 0, dib);
714 HeapFree(GetProcessHeap(), 0, bmp->color_table);
716 return HeapFree( GetProcessHeap(), 0, bmp );
720 /***********************************************************************
723 static INT BITMAP_GetObject( HGDIOBJ handle, INT count, LPVOID buffer )
726 BITMAPOBJ *bmp = GDI_GetObjPtr( handle, OBJ_BITMAP );
730 if (!buffer) ret = sizeof(BITMAP);
731 else if (count < sizeof(BITMAP)) ret = 0;
734 if (count >= sizeof(DIBSECTION))
736 DIBSECTION *dib = buffer;
738 dib->dsBmih.biHeight = abs( dib->dsBmih.biHeight );
739 ret = sizeof(DIBSECTION);
741 else /* if (count >= sizeof(BITMAP)) */
743 DIBSECTION *dib = bmp->dib;
744 memcpy( buffer, &dib->dsBm, sizeof(BITMAP) );
745 ret = sizeof(BITMAP);
750 memcpy( buffer, &bmp->bitmap, sizeof(BITMAP) );
751 ((BITMAP *) buffer)->bmBits = NULL;
752 ret = sizeof(BITMAP);
754 GDI_ReleaseObj( handle );
759 /******************************************************************************
760 * CreateDiscardableBitmap [GDI32.@]
762 * Creates a discardable bitmap.
765 * Success: Handle to bitmap
768 HBITMAP WINAPI CreateDiscardableBitmap(
769 HDC hdc, /* [in] Handle to device context */
770 INT width, /* [in] Bitmap width */
771 INT height) /* [in] Bitmap height */
773 return CreateCompatibleBitmap( hdc, width, height );
777 /******************************************************************************
778 * GetBitmapDimensionEx [GDI32.@]
780 * Retrieves dimensions of a bitmap.
786 BOOL WINAPI GetBitmapDimensionEx(
787 HBITMAP hbitmap, /* [in] Handle to bitmap */
788 LPSIZE size) /* [out] Address of struct receiving dimensions */
790 BITMAPOBJ * bmp = GDI_GetObjPtr( hbitmap, OBJ_BITMAP );
791 if (!bmp) return FALSE;
793 GDI_ReleaseObj( hbitmap );
798 /******************************************************************************
799 * SetBitmapDimensionEx [GDI32.@]
801 * Assigns dimensions to a bitmap.
802 * MSDN says that this function will fail if hbitmap is a handle created by
803 * CreateDIBSection, but that's not true on Windows 2000.
809 BOOL WINAPI SetBitmapDimensionEx(
810 HBITMAP hbitmap, /* [in] Handle to bitmap */
811 INT x, /* [in] Bitmap width */
812 INT y, /* [in] Bitmap height */
813 LPSIZE prevSize) /* [out] Address of structure for orig dims */
815 BITMAPOBJ * bmp = GDI_GetObjPtr( hbitmap, OBJ_BITMAP );
816 if (!bmp) return FALSE;
817 if (prevSize) *prevSize = bmp->size;
820 GDI_ReleaseObj( hbitmap );