dplayx: Tests for GroupOwner.
[wine.git] / dlls / gdi32 / bitmap.c
blob94061f8c684d89ee40e5156268a7fb58a7d458bb
1 /*
2 * GDI bitmap objects
4 * Copyright 1993 Alexandre Julliard
5 * 1998 Huw D M Davies
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
22 #include <stdarg.h>
23 #include <stdlib.h>
24 #include <string.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "wine/winbase16.h"
30 #include "gdi_private.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(bitmap);
36 static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc );
37 static INT BITMAP_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
38 static BOOL BITMAP_DeleteObject( HGDIOBJ handle, void *obj );
40 static const struct gdi_obj_funcs bitmap_funcs =
42 BITMAP_SelectObject, /* pSelectObject */
43 BITMAP_GetObject, /* pGetObjectA */
44 BITMAP_GetObject, /* pGetObjectW */
45 NULL, /* pUnrealizeObject */
46 BITMAP_DeleteObject /* pDeleteObject */
49 /***********************************************************************
50 * BITMAP_GetWidthBytes
52 * Return number of bytes taken by a scanline of 16-bit aligned Windows DDB
53 * data.
55 INT BITMAP_GetWidthBytes( INT bmWidth, INT bpp )
57 switch(bpp)
59 case 1:
60 return 2 * ((bmWidth+15) >> 4);
62 case 24:
63 bmWidth *= 3; /* fall through */
64 case 8:
65 return bmWidth + (bmWidth & 1);
67 case 32:
68 return bmWidth * 4;
70 case 16:
71 case 15:
72 return bmWidth * 2;
74 case 4:
75 return 2 * ((bmWidth+3) >> 2);
77 default:
78 WARN("Unknown depth %d, please report.\n", bpp );
80 return -1;
84 /******************************************************************************
85 * CreateBitmap [GDI32.@]
87 * Creates a bitmap with the specified info.
89 * PARAMS
90 * width [I] bitmap width
91 * height [I] bitmap height
92 * planes [I] Number of color planes
93 * bpp [I] Number of bits to identify a color
94 * bits [I] Pointer to array containing color data
96 * RETURNS
97 * Success: Handle to bitmap
98 * Failure: 0
100 HBITMAP WINAPI CreateBitmap( INT width, INT height, UINT planes,
101 UINT bpp, LPCVOID bits )
103 BITMAP bm;
105 bm.bmType = 0;
106 bm.bmWidth = width;
107 bm.bmHeight = height;
108 bm.bmWidthBytes = BITMAP_GetWidthBytes( width, bpp );
109 bm.bmPlanes = planes;
110 bm.bmBitsPixel = bpp;
111 bm.bmBits = (LPVOID)bits;
113 return CreateBitmapIndirect( &bm );
116 /******************************************************************************
117 * CreateCompatibleBitmap [GDI32.@]
119 * Creates a bitmap compatible with the DC.
121 * PARAMS
122 * hdc [I] Handle to device context
123 * width [I] Width of bitmap
124 * height [I] Height of bitmap
126 * RETURNS
127 * Success: Handle to bitmap
128 * Failure: 0
130 HBITMAP WINAPI CreateCompatibleBitmap( HDC hdc, INT width, INT height)
132 HBITMAP hbmpRet = 0;
134 TRACE("(%p,%d,%d) =\n", hdc, width, height);
136 if (GetObjectType( hdc ) != OBJ_MEMDC)
138 hbmpRet = CreateBitmap(width, height,
139 GetDeviceCaps(hdc, PLANES),
140 GetDeviceCaps(hdc, BITSPIXEL),
141 NULL);
143 else /* Memory DC */
145 DIBSECTION dib;
146 HBITMAP bitmap = GetCurrentObject( hdc, OBJ_BITMAP );
147 INT size = GetObjectW( bitmap, sizeof(dib), &dib );
149 if (!size) return 0;
151 if (size == sizeof(BITMAP))
153 /* A device-dependent bitmap is selected in the DC */
154 hbmpRet = CreateBitmap(width, height,
155 dib.dsBm.bmPlanes,
156 dib.dsBm.bmBitsPixel,
157 NULL);
159 else
161 /* A DIB section is selected in the DC */
162 BITMAPINFO *bi;
163 void *bits;
165 /* Allocate memory for a BITMAPINFOHEADER structure and a
166 color table. The maximum number of colors in a color table
167 is 256 which corresponds to a bitmap with depth 8.
168 Bitmaps with higher depths don't have color tables. */
169 bi = HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
171 if (bi)
173 bi->bmiHeader.biSize = sizeof(bi->bmiHeader);
174 bi->bmiHeader.biWidth = width;
175 bi->bmiHeader.biHeight = height;
176 bi->bmiHeader.biPlanes = dib.dsBmih.biPlanes;
177 bi->bmiHeader.biBitCount = dib.dsBmih.biBitCount;
178 bi->bmiHeader.biCompression = dib.dsBmih.biCompression;
179 bi->bmiHeader.biSizeImage = 0;
180 bi->bmiHeader.biXPelsPerMeter = dib.dsBmih.biXPelsPerMeter;
181 bi->bmiHeader.biYPelsPerMeter = dib.dsBmih.biYPelsPerMeter;
182 bi->bmiHeader.biClrUsed = dib.dsBmih.biClrUsed;
183 bi->bmiHeader.biClrImportant = dib.dsBmih.biClrImportant;
185 if (bi->bmiHeader.biCompression == BI_BITFIELDS)
187 /* Copy the color masks */
188 CopyMemory(bi->bmiColors, dib.dsBitfields, 3 * sizeof(DWORD));
190 else if (bi->bmiHeader.biBitCount <= 8)
192 /* Copy the color table */
193 GetDIBColorTable(hdc, 0, 256, bi->bmiColors);
196 hbmpRet = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
197 HeapFree(GetProcessHeap(), 0, bi);
202 TRACE("\t\t%p\n", hbmpRet);
203 return hbmpRet;
207 /******************************************************************************
208 * CreateBitmapIndirect [GDI32.@]
210 * Creates a bitmap with the specified info.
212 * PARAMS
213 * bmp [I] Pointer to the bitmap info describing the bitmap
215 * RETURNS
216 * Success: Handle to bitmap
217 * Failure: NULL. Use GetLastError() to determine the cause.
219 * NOTES
220 * If a width or height of 0 are given, a 1x1 monochrome bitmap is returned.
222 HBITMAP WINAPI CreateBitmapIndirect( const BITMAP *bmp )
224 BITMAP bm;
225 BITMAPOBJ *bmpobj;
226 HBITMAP hbitmap;
228 if (!bmp || bmp->bmType)
230 SetLastError( ERROR_INVALID_PARAMETER );
231 return NULL;
234 if (bmp->bmWidth > 0x7ffffff || bmp->bmHeight > 0x7ffffff)
236 SetLastError( ERROR_INVALID_PARAMETER );
237 return 0;
240 bm = *bmp;
242 if (!bm.bmWidth || !bm.bmHeight)
244 return GetStockObject( DEFAULT_BITMAP );
246 else
248 if (bm.bmHeight < 0)
249 bm.bmHeight = -bm.bmHeight;
250 if (bm.bmWidth < 0)
251 bm.bmWidth = -bm.bmWidth;
254 if (bm.bmPlanes != 1)
256 FIXME("planes = %d\n", bm.bmPlanes);
257 SetLastError( ERROR_INVALID_PARAMETER );
258 return NULL;
261 /* Windows only uses 1, 4, 8, 16, 24 and 32 bpp */
262 if(bm.bmBitsPixel == 1) bm.bmBitsPixel = 1;
263 else if(bm.bmBitsPixel <= 4) bm.bmBitsPixel = 4;
264 else if(bm.bmBitsPixel <= 8) bm.bmBitsPixel = 8;
265 else if(bm.bmBitsPixel <= 16) bm.bmBitsPixel = 16;
266 else if(bm.bmBitsPixel <= 24) bm.bmBitsPixel = 24;
267 else if(bm.bmBitsPixel <= 32) bm.bmBitsPixel = 32;
268 else {
269 WARN("Invalid bmBitsPixel %d, returning ERROR_INVALID_PARAMETER\n", bm.bmBitsPixel);
270 SetLastError(ERROR_INVALID_PARAMETER);
271 return NULL;
274 /* Windows ignores the provided bm.bmWidthBytes */
275 bm.bmWidthBytes = BITMAP_GetWidthBytes( bm.bmWidth, bm.bmBitsPixel );
276 /* XP doesn't allow to create bitmaps larger than 128 Mb */
277 if (bm.bmHeight * bm.bmWidthBytes > 128 * 1024 * 1024)
279 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
280 return 0;
283 /* Create the BITMAPOBJ */
284 bmpobj = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC,
285 (HGDIOBJ *)&hbitmap, &bitmap_funcs );
287 if (!bmpobj)
289 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
290 return NULL;
293 TRACE("%dx%d, %d colors returning %p\n", bm.bmWidth, bm.bmHeight,
294 1 << (bm.bmPlanes * bm.bmBitsPixel), hbitmap);
296 bmpobj->size.cx = 0;
297 bmpobj->size.cy = 0;
298 bmpobj->bitmap = bm;
299 bmpobj->bitmap.bmBits = NULL;
300 bmpobj->funcs = NULL;
301 bmpobj->dib = NULL;
302 bmpobj->segptr_bits = 0;
303 bmpobj->color_table = NULL;
304 bmpobj->nb_colors = 0;
306 if (bm.bmBits)
307 SetBitmapBits( hbitmap, bm.bmHeight * bm.bmWidthBytes, bm.bmBits );
309 GDI_ReleaseObj( hbitmap );
310 return hbitmap;
314 /***********************************************************************
315 * GetBitmapBits [GDI32.@]
317 * Copies bitmap bits of bitmap to buffer.
319 * RETURNS
320 * Success: Number of bytes copied
321 * Failure: 0
323 LONG WINAPI GetBitmapBits(
324 HBITMAP hbitmap, /* [in] Handle to bitmap */
325 LONG count, /* [in] Number of bytes to copy */
326 LPVOID bits) /* [out] Pointer to buffer to receive bits */
328 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
329 LONG height, ret;
331 if (!bmp) return 0;
333 if (bmp->dib) /* simply copy the bits from the DIB */
335 DIBSECTION *dib = bmp->dib;
336 const char *src = dib->dsBm.bmBits;
337 INT width_bytes = BITMAP_GetWidthBytes(dib->dsBm.bmWidth, dib->dsBm.bmBitsPixel);
338 DWORD max = width_bytes * bmp->bitmap.bmHeight;
340 if (!bits)
342 ret = max;
343 goto done;
346 if (count > max) count = max;
347 ret = count;
349 /* GetBitmapBits returns not 32-bit aligned data */
351 if (bmp->dib->dsBmih.biHeight >= 0) /* not top-down, need to flip contents vertically */
353 src += dib->dsBm.bmWidthBytes * dib->dsBm.bmHeight;
354 while (count > 0)
356 src -= dib->dsBm.bmWidthBytes;
357 memcpy( bits, src, min( count, width_bytes ) );
358 bits = (char *)bits + width_bytes;
359 count -= width_bytes;
362 else
364 while (count > 0)
366 memcpy( bits, src, min( count, width_bytes ) );
367 src += dib->dsBm.bmWidthBytes;
368 bits = (char *)bits + width_bytes;
369 count -= width_bytes;
372 goto done;
375 /* If the bits vector is null, the function should return the read size */
376 if(bits == NULL)
378 ret = bmp->bitmap.bmWidthBytes * bmp->bitmap.bmHeight;
379 goto done;
382 if (count < 0) {
383 WARN("(%d): Negative number of bytes passed???\n", count );
384 count = -count;
387 /* Only get entire lines */
388 height = count / bmp->bitmap.bmWidthBytes;
389 if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
390 count = height * bmp->bitmap.bmWidthBytes;
391 if (count == 0)
393 WARN("Less than one entire line requested\n");
394 ret = 0;
395 goto done;
399 TRACE("(%p, %d, %p) %dx%d %d colors fetched height: %d\n",
400 hbitmap, count, bits, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
401 1 << bmp->bitmap.bmBitsPixel, height );
403 if(bmp->funcs && bmp->funcs->pGetBitmapBits)
405 TRACE("Calling device specific BitmapBits\n");
406 ret = bmp->funcs->pGetBitmapBits(hbitmap, bits, count);
407 } else {
409 if(!bmp->bitmap.bmBits) {
410 TRACE("Bitmap is empty\n");
411 memset(bits, 0, count);
412 ret = count;
413 } else {
414 memcpy(bits, bmp->bitmap.bmBits, count);
415 ret = count;
419 done:
420 GDI_ReleaseObj( hbitmap );
421 return ret;
425 /******************************************************************************
426 * SetBitmapBits [GDI32.@]
428 * Sets bits of color data for a bitmap.
430 * RETURNS
431 * Success: Number of bytes used in setting the bitmap bits
432 * Failure: 0
434 LONG WINAPI SetBitmapBits(
435 HBITMAP hbitmap, /* [in] Handle to bitmap */
436 LONG count, /* [in] Number of bytes in bitmap array */
437 LPCVOID bits) /* [in] Address of array with bitmap bits */
439 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
440 LONG height, ret;
442 if ((!bmp) || (!bits))
443 return 0;
445 if (count < 0) {
446 WARN("(%d): Negative number of bytes passed???\n", count );
447 count = -count;
450 if (bmp->dib) /* simply copy the bits into the DIB */
452 DIBSECTION *dib = bmp->dib;
453 char *dest = dib->dsBm.bmBits;
454 DWORD max = dib->dsBm.bmWidthBytes * dib->dsBm.bmHeight;
455 if (count > max) count = max;
456 ret = count;
458 if (bmp->dib->dsBmih.biHeight >= 0) /* not top-down, need to flip contents vertically */
460 dest += dib->dsBm.bmWidthBytes * dib->dsBm.bmHeight;
461 while (count > 0)
463 dest -= dib->dsBm.bmWidthBytes;
464 memcpy( dest, bits, min( count, dib->dsBm.bmWidthBytes ) );
465 bits = (const char *)bits + dib->dsBm.bmWidthBytes;
466 count -= dib->dsBm.bmWidthBytes;
469 else memcpy( dest, bits, count );
471 GDI_ReleaseObj( hbitmap );
472 return ret;
475 /* Only get entire lines */
476 height = count / bmp->bitmap.bmWidthBytes;
477 if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
478 count = height * bmp->bitmap.bmWidthBytes;
480 TRACE("(%p, %d, %p) %dx%d %d colors fetched height: %d\n",
481 hbitmap, count, bits, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
482 1 << bmp->bitmap.bmBitsPixel, height );
484 if(bmp->funcs && bmp->funcs->pSetBitmapBits) {
486 TRACE("Calling device specific BitmapBits\n");
487 ret = bmp->funcs->pSetBitmapBits(hbitmap, bits, count);
488 } else {
490 if(!bmp->bitmap.bmBits) /* Alloc enough for entire bitmap */
491 bmp->bitmap.bmBits = HeapAlloc( GetProcessHeap(), 0, count );
492 if(!bmp->bitmap.bmBits) {
493 WARN("Unable to allocate bit buffer\n");
494 ret = 0;
495 } else {
496 memcpy(bmp->bitmap.bmBits, bits, count);
497 ret = count;
501 GDI_ReleaseObj( hbitmap );
502 return ret;
505 /**********************************************************************
506 * BITMAP_CopyBitmap
509 HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap)
511 HBITMAP res = 0;
512 BITMAP bm;
514 if (!GetObjectW( hbitmap, sizeof(bm), &bm )) return 0;
515 res = CreateBitmapIndirect(&bm);
517 if(res) {
518 char *buf = HeapAlloc( GetProcessHeap(), 0, bm.bmWidthBytes *
519 bm.bmHeight );
520 GetBitmapBits (hbitmap, bm.bmWidthBytes * bm.bmHeight, buf);
521 SetBitmapBits (res, bm.bmWidthBytes * bm.bmHeight, buf);
522 HeapFree( GetProcessHeap(), 0, buf );
524 return res;
528 /***********************************************************************
529 * BITMAP_SetOwnerDC
531 * Set the type of DC that owns the bitmap. This is used when the
532 * bitmap is selected into a device to initialize the bitmap function
533 * table.
535 BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, DC *dc )
537 BITMAPOBJ *bitmap;
538 BOOL ret;
540 /* never set the owner of the stock bitmap since it can be selected in multiple DCs */
541 if (hbitmap == GetStockObject(DEFAULT_BITMAP)) return TRUE;
543 if (!(bitmap = GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ))) return FALSE;
545 ret = TRUE;
546 if (!bitmap->funcs) /* not owned by a DC yet */
548 if (dc->funcs->pCreateBitmap) ret = dc->funcs->pCreateBitmap( dc->physDev, hbitmap,
549 bitmap->bitmap.bmBits );
550 if (ret) bitmap->funcs = dc->funcs;
552 else if (bitmap->funcs != dc->funcs)
554 FIXME( "Trying to select bitmap %p in different DC type\n", hbitmap );
555 ret = FALSE;
557 GDI_ReleaseObj( hbitmap );
558 return ret;
562 /***********************************************************************
563 * BITMAP_SelectObject
565 static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
567 HGDIOBJ ret;
568 BITMAPOBJ *bitmap;
569 DC *dc;
571 if (!(dc = get_dc_ptr( hdc ))) return 0;
573 if (GetObjectType( hdc ) != OBJ_MEMDC)
575 ret = 0;
576 goto done;
578 ret = dc->hBitmap;
579 if (handle == dc->hBitmap) goto done; /* nothing to do */
581 if (!(bitmap = GDI_GetObjPtr( handle, BITMAP_MAGIC )))
583 ret = 0;
584 goto done;
587 if (bitmap->header.dwCount && (handle != GetStockObject(DEFAULT_BITMAP)))
589 WARN( "Bitmap already selected in another DC\n" );
590 GDI_ReleaseObj( handle );
591 ret = 0;
592 goto done;
595 if (!bitmap->funcs && !BITMAP_SetOwnerDC( handle, dc ))
597 GDI_ReleaseObj( handle );
598 ret = 0;
599 goto done;
602 if (dc->funcs->pSelectBitmap && !dc->funcs->pSelectBitmap( dc->physDev, handle ))
604 GDI_ReleaseObj( handle );
605 ret = 0;
607 else
609 dc->hBitmap = handle;
610 GDI_inc_ref_count( handle );
611 dc->dirty = 0;
612 SetRectRgn( dc->hVisRgn, 0, 0, bitmap->bitmap.bmWidth, bitmap->bitmap.bmHeight);
613 GDI_ReleaseObj( handle );
614 DC_InitDC( dc );
615 GDI_dec_ref_count( ret );
618 done:
619 release_dc_ptr( dc );
620 return ret;
624 /***********************************************************************
625 * BITMAP_DeleteObject
627 static BOOL BITMAP_DeleteObject( HGDIOBJ handle, void *obj )
629 BITMAPOBJ * bmp = obj;
631 if (bmp->funcs && bmp->funcs->pDeleteBitmap)
632 bmp->funcs->pDeleteBitmap( handle );
634 HeapFree( GetProcessHeap(), 0, bmp->bitmap.bmBits );
636 if (bmp->dib)
638 DIBSECTION *dib = bmp->dib;
640 if (dib->dsBm.bmBits)
642 if (dib->dshSection)
644 SYSTEM_INFO SystemInfo;
645 GetSystemInfo( &SystemInfo );
646 UnmapViewOfFile( (char *)dib->dsBm.bmBits -
647 (dib->dsOffset % SystemInfo.dwAllocationGranularity) );
649 else if (!dib->dsOffset)
650 VirtualFree(dib->dsBm.bmBits, 0L, MEM_RELEASE );
652 HeapFree(GetProcessHeap(), 0, dib);
653 bmp->dib = NULL;
654 if (bmp->segptr_bits)
655 { /* free its selector array */
656 WORD sel = SELECTOROF(bmp->segptr_bits);
657 WORD count = (GetSelectorLimit16(sel) / 0x10000) + 1;
658 int i;
660 for (i = 0; i < count; i++) FreeSelector16(sel + (i << __AHSHIFT));
662 HeapFree(GetProcessHeap(), 0, bmp->color_table);
664 return GDI_FreeObject( handle, obj );
668 /***********************************************************************
669 * BITMAP_GetObject
671 static INT BITMAP_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffer )
673 BITMAPOBJ *bmp = obj;
675 if( !buffer ) return sizeof(BITMAP);
676 if (count < sizeof(BITMAP)) return 0;
678 if (bmp->dib)
680 if (count >= sizeof(DIBSECTION))
682 memcpy( buffer, bmp->dib, sizeof(DIBSECTION) );
683 return sizeof(DIBSECTION);
685 else /* if (count >= sizeof(BITMAP)) */
687 DIBSECTION *dib = bmp->dib;
688 memcpy( buffer, &dib->dsBm, sizeof(BITMAP) );
689 return sizeof(BITMAP);
692 else
694 memcpy( buffer, &bmp->bitmap, sizeof(BITMAP) );
695 ((BITMAP *) buffer)->bmBits = NULL;
696 return sizeof(BITMAP);
701 /******************************************************************************
702 * CreateDiscardableBitmap [GDI32.@]
704 * Creates a discardable bitmap.
706 * RETURNS
707 * Success: Handle to bitmap
708 * Failure: NULL
710 HBITMAP WINAPI CreateDiscardableBitmap(
711 HDC hdc, /* [in] Handle to device context */
712 INT width, /* [in] Bitmap width */
713 INT height) /* [in] Bitmap height */
715 return CreateCompatibleBitmap( hdc, width, height );
719 /******************************************************************************
720 * GetBitmapDimensionEx [GDI32.@]
722 * Retrieves dimensions of a bitmap.
724 * RETURNS
725 * Success: TRUE
726 * Failure: FALSE
728 BOOL WINAPI GetBitmapDimensionEx(
729 HBITMAP hbitmap, /* [in] Handle to bitmap */
730 LPSIZE size) /* [out] Address of struct receiving dimensions */
732 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
733 if (!bmp) return FALSE;
734 *size = bmp->size;
735 GDI_ReleaseObj( hbitmap );
736 return TRUE;
740 /******************************************************************************
741 * SetBitmapDimensionEx [GDI32.@]
743 * Assigns dimensions to a bitmap.
744 * MSDN says that this function will fail if hbitmap is a handle created by
745 * CreateDIBSection, but that's not true on Windows 2000.
747 * RETURNS
748 * Success: TRUE
749 * Failure: FALSE
751 BOOL WINAPI SetBitmapDimensionEx(
752 HBITMAP hbitmap, /* [in] Handle to bitmap */
753 INT x, /* [in] Bitmap width */
754 INT y, /* [in] Bitmap height */
755 LPSIZE prevSize) /* [out] Address of structure for orig dims */
757 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
758 if (!bmp) return FALSE;
759 if (prevSize) *prevSize = bmp->size;
760 bmp->size.cx = x;
761 bmp->size.cy = y;
762 GDI_ReleaseObj( hbitmap );
763 return TRUE;