Portability fix.
[wine/wine64.git] / objects / bitmap.c
blobb57baed60876688eaf8f608f397572c0258faa43
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <stdlib.h>
23 #include <string.h>
25 #include "wine/winbase16.h"
26 #include "gdi.h"
27 #include "bitmap.h"
28 #include "selectors.h"
29 #include "wine/debug.h"
30 #include "wine/winuser16.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(bitmap);
35 static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, void *obj, HDC hdc );
36 static INT BITMAP_GetObject16( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
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_GetObject16, /* pGetObject16 */
44 BITMAP_GetObject, /* pGetObjectA */
45 BITMAP_GetObject, /* pGetObjectW */
46 NULL, /* pUnrealizeObject */
47 BITMAP_DeleteObject /* pDeleteObject */
50 /***********************************************************************
51 * BITMAP_GetWidthBytes
53 * Return number of bytes taken by a scanline of 16-bit aligned Windows DDB
54 * data.
56 INT BITMAP_GetWidthBytes( INT bmWidth, INT bpp )
58 switch(bpp)
60 case 1:
61 return 2 * ((bmWidth+15) >> 4);
63 case 24:
64 bmWidth *= 3; /* fall through */
65 case 8:
66 return bmWidth + (bmWidth & 1);
68 case 32:
69 return bmWidth * 4;
71 case 16:
72 case 15:
73 return bmWidth * 2;
75 case 4:
76 return 2 * ((bmWidth+3) >> 2);
78 default:
79 WARN("Unknown depth %d, please report.\n", bpp );
81 return -1;
84 /***********************************************************************
85 * CreateUserBitmap (GDI.407)
87 HBITMAP16 WINAPI CreateUserBitmap16( INT16 width, INT16 height, UINT16 planes,
88 UINT16 bpp, LPCVOID bits )
90 return CreateBitmap16( width, height, planes, bpp, bits );
93 /***********************************************************************
94 * CreateUserDiscardableBitmap (GDI.409)
96 HBITMAP16 WINAPI CreateUserDiscardableBitmap16( WORD dummy,
97 INT16 width, INT16 height )
99 HDC hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
100 HBITMAP16 ret = CreateCompatibleBitmap16( hdc, width, height );
101 DeleteDC( hdc );
102 return ret;
106 /***********************************************************************
107 * CreateBitmap (GDI.48)
109 HBITMAP16 WINAPI CreateBitmap16( INT16 width, INT16 height, UINT16 planes,
110 UINT16 bpp, LPCVOID bits )
112 return CreateBitmap( width, height, planes, bpp, bits );
116 /******************************************************************************
117 * CreateBitmap [GDI32.@] Creates a bitmap with the specified info
119 * PARAMS
120 * width [I] bitmap width
121 * height [I] bitmap height
122 * planes [I] Number of color planes
123 * bpp [I] Number of bits to identify a color
124 * bits [I] Pointer to array containing color data
126 * RETURNS
127 * Success: Handle to bitmap
128 * Failure: 0
130 HBITMAP WINAPI CreateBitmap( INT width, INT height, UINT planes,
131 UINT bpp, LPCVOID bits )
133 BITMAPOBJ *bmp;
134 HBITMAP hbitmap;
136 planes = (BYTE)planes;
137 bpp = (BYTE)bpp;
140 /* Check parameters */
141 if (!height || !width)
143 height = 1;
144 width = 1;
145 planes = 1;
146 bpp = 1;
148 if (planes != 1) {
149 FIXME("planes = %d\n", planes);
150 return 0;
152 if (height < 0) height = -height;
153 if (width < 0) width = -width;
155 /* Create the BITMAPOBJ */
156 if (!(bmp = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC, &hbitmap, &bitmap_funcs )))
157 return 0;
159 TRACE("%dx%d, %d colors returning %08x\n", width, height,
160 1 << (planes*bpp), hbitmap);
162 bmp->size.cx = 0;
163 bmp->size.cy = 0;
164 bmp->bitmap.bmType = 0;
165 bmp->bitmap.bmWidth = width;
166 bmp->bitmap.bmHeight = height;
167 bmp->bitmap.bmPlanes = planes;
168 bmp->bitmap.bmBitsPixel = bpp;
169 bmp->bitmap.bmWidthBytes = BITMAP_GetWidthBytes( width, bpp );
170 bmp->bitmap.bmBits = NULL;
172 bmp->funcs = NULL;
173 bmp->physBitmap = NULL;
174 bmp->dib = NULL;
175 bmp->segptr_bits = 0;
177 if (bits) /* Set bitmap bits */
178 SetBitmapBits( hbitmap, height * bmp->bitmap.bmWidthBytes,
179 bits );
180 GDI_ReleaseObj( hbitmap );
181 return hbitmap;
185 /***********************************************************************
186 * CreateCompatibleBitmap (GDI.51)
188 HBITMAP16 WINAPI CreateCompatibleBitmap16(HDC16 hdc, INT16 width, INT16 height)
190 return CreateCompatibleBitmap( hdc, width, height );
194 /******************************************************************************
195 * CreateCompatibleBitmap [GDI32.@] Creates a bitmap compatible with the DC
197 * PARAMS
198 * hdc [I] Handle to device context
199 * width [I] Width of bitmap
200 * height [I] Height of bitmap
202 * RETURNS
203 * Success: Handle to bitmap
204 * Failure: 0
206 HBITMAP WINAPI CreateCompatibleBitmap( HDC hdc, INT width, INT height)
208 HBITMAP hbmpRet = 0;
209 DC *dc;
211 TRACE("(%04x,%d,%d) = \n", hdc, width, height );
212 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
213 if ((width >= 0x10000) || (height >= 0x10000)) {
214 FIXME("got bad width %d or height %d, please look for reason\n",
215 width, height );
216 } else {
217 /* MS doc says if width or height is 0, return 1-by-1 pixel, monochrome bitmap */
218 if (!width || !height)
219 hbmpRet = CreateBitmap( 1, 1, 1, 1, NULL );
220 else
221 hbmpRet = CreateBitmap( width, height, 1, dc->bitsPerPixel, NULL );
223 if (!BITMAP_SetOwnerDC( hbmpRet, dc ))
225 DeleteObject( hbmpRet );
226 hbmpRet = 0;
229 TRACE("\t\t%04x\n", hbmpRet);
230 GDI_ReleaseObj(hdc);
231 return hbmpRet;
235 /***********************************************************************
236 * CreateBitmapIndirect (GDI.49)
238 HBITMAP16 WINAPI CreateBitmapIndirect16( const BITMAP16 * bmp )
240 return CreateBitmap16( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
241 bmp->bmBitsPixel, MapSL( bmp->bmBits ) );
245 /******************************************************************************
246 * CreateBitmapIndirect [GDI32.@] Creates a bitmap with the specifies info
248 * RETURNS
249 * Success: Handle to bitmap
250 * Failure: NULL
252 HBITMAP WINAPI CreateBitmapIndirect(
253 const BITMAP * bmp) /* [in] Pointer to the bitmap data */
255 return CreateBitmap( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
256 bmp->bmBitsPixel, bmp->bmBits );
260 /***********************************************************************
261 * GetBitmapBits (GDI.74)
263 LONG WINAPI GetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPVOID buffer )
265 return GetBitmapBits( hbitmap, count, buffer );
269 /***********************************************************************
270 * GetBitmapBits [GDI32.@] Copies bitmap bits of bitmap to buffer
272 * RETURNS
273 * Success: Number of bytes copied
274 * Failure: 0
276 LONG WINAPI GetBitmapBits(
277 HBITMAP hbitmap, /* [in] Handle to bitmap */
278 LONG count, /* [in] Number of bytes to copy */
279 LPVOID bits) /* [out] Pointer to buffer to receive bits */
281 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
282 LONG height, ret;
284 if (!bmp) return 0;
286 /* If the bits vector is null, the function should return the read size */
287 if(bits == NULL)
289 ret = bmp->bitmap.bmWidthBytes * bmp->bitmap.bmHeight;
290 goto done;
293 if (count < 0) {
294 WARN("(%ld): Negative number of bytes passed???\n", count );
295 count = -count;
298 /* Only get entire lines */
299 height = count / bmp->bitmap.bmWidthBytes;
300 if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
301 count = height * bmp->bitmap.bmWidthBytes;
302 if (count == 0)
304 WARN("Less than one entire line requested\n");
305 ret = 0;
306 goto done;
310 TRACE("(%08x, %ld, %p) %dx%d %d colors fetched height: %ld\n",
311 hbitmap, count, bits, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
312 1 << bmp->bitmap.bmBitsPixel, height );
314 if(bmp->funcs)
316 TRACE("Calling device specific BitmapBits\n");
317 if(bmp->funcs->pGetBitmapBits)
318 ret = bmp->funcs->pGetBitmapBits(hbitmap, bits, count);
319 else
321 memset( bits, 0, count );
322 ret = count;
324 } else {
326 if(!bmp->bitmap.bmBits) {
327 WARN("Bitmap is empty\n");
328 ret = 0;
329 } else {
330 memcpy(bits, bmp->bitmap.bmBits, count);
331 ret = count;
335 done:
336 GDI_ReleaseObj( hbitmap );
337 return ret;
341 /***********************************************************************
342 * SetBitmapBits (GDI.106)
344 LONG WINAPI SetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPCVOID buffer )
346 return SetBitmapBits( hbitmap, count, buffer );
350 /******************************************************************************
351 * SetBitmapBits [GDI32.@] Sets bits of color data for a bitmap
353 * RETURNS
354 * Success: Number of bytes used in setting the bitmap bits
355 * Failure: 0
357 LONG WINAPI SetBitmapBits(
358 HBITMAP hbitmap, /* [in] Handle to bitmap */
359 LONG count, /* [in] Number of bytes in bitmap array */
360 LPCVOID bits) /* [in] Address of array with bitmap bits */
362 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
363 LONG height, ret;
365 if ((!bmp) || (!bits))
366 return 0;
368 if (count < 0) {
369 WARN("(%ld): Negative number of bytes passed???\n", count );
370 count = -count;
373 /* Only get entire lines */
374 height = count / bmp->bitmap.bmWidthBytes;
375 if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
376 count = height * bmp->bitmap.bmWidthBytes;
378 TRACE("(%08x, %ld, %p) %dx%d %d colors fetched height: %ld\n",
379 hbitmap, count, bits, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
380 1 << bmp->bitmap.bmBitsPixel, height );
382 if(bmp->funcs) {
384 TRACE("Calling device specific BitmapBits\n");
385 if(bmp->funcs->pSetBitmapBits)
386 ret = bmp->funcs->pSetBitmapBits(hbitmap, bits, count);
387 else
388 ret = 0;
389 } else {
391 if(!bmp->bitmap.bmBits) /* Alloc enough for entire bitmap */
392 bmp->bitmap.bmBits = HeapAlloc( GetProcessHeap(), 0, count );
393 if(!bmp->bitmap.bmBits) {
394 WARN("Unable to allocate bit buffer\n");
395 ret = 0;
396 } else {
397 memcpy(bmp->bitmap.bmBits, bits, count);
398 ret = count;
402 GDI_ReleaseObj( hbitmap );
403 return ret;
406 /**********************************************************************
407 * BITMAP_CopyBitmap
410 HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap)
412 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
413 HBITMAP res = 0;
414 BITMAP bm;
416 if(!bmp) return 0;
418 bm = bmp->bitmap;
419 bm.bmBits = NULL;
420 res = CreateBitmapIndirect(&bm);
422 if(res) {
423 char *buf = HeapAlloc( GetProcessHeap(), 0, bm.bmWidthBytes *
424 bm.bmHeight );
425 GetBitmapBits (hbitmap, bm.bmWidthBytes * bm.bmHeight, buf);
426 SetBitmapBits (res, bm.bmWidthBytes * bm.bmHeight, buf);
427 HeapFree( GetProcessHeap(), 0, buf );
430 GDI_ReleaseObj( hbitmap );
431 return res;
435 /***********************************************************************
436 * BITMAP_SetOwnerDC
438 * Set the type of DC that owns the bitmap. This is used when the
439 * bitmap is selected into a device to initialize the bitmap function
440 * table.
442 BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, DC *dc )
444 BITMAPOBJ *bitmap;
445 BOOL ret;
447 /* never set the owner of the stock bitmap since it can be selected in multiple DCs */
448 if (hbitmap == GetStockObject(DEFAULT_BITMAP)) return TRUE;
450 if (!(bitmap = GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ))) return FALSE;
452 ret = TRUE;
453 if (!bitmap->funcs) /* not owned by a DC yet */
455 if (dc->funcs->pCreateBitmap) ret = dc->funcs->pCreateBitmap( dc->physDev, hbitmap );
456 if (ret) bitmap->funcs = dc->funcs;
458 else if (bitmap->funcs != dc->funcs)
460 FIXME( "Trying to select bitmap %x in different DC type\n", hbitmap );
461 ret = FALSE;
463 GDI_ReleaseObj( hbitmap );
464 return ret;
468 /***********************************************************************
469 * BITMAP_SelectObject
471 static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, void *obj, HDC hdc )
473 HGDIOBJ ret = handle;
474 BITMAPOBJ *bitmap = obj;
475 DC *dc = DC_GetDCPtr( hdc );
477 if (!dc) return 0;
478 if (!(dc->flags & DC_MEMORY))
480 GDI_ReleaseObj( hdc );
481 return 0;
483 if (handle == dc->hBitmap) goto done; /* nothing to do */
485 if (bitmap->header.dwCount && (handle != GetStockObject(DEFAULT_BITMAP)))
487 WARN( "Bitmap already selected in another DC\n" );
488 GDI_ReleaseObj( hdc );
489 return 0;
492 if (!bitmap->funcs && !BITMAP_SetOwnerDC( handle, dc ))
494 GDI_ReleaseObj( hdc );
495 return 0;
498 if (dc->funcs->pSelectBitmap) ret = dc->funcs->pSelectBitmap( dc->physDev, handle );
500 if (ret)
502 dc->hBitmap = ret;
503 dc->totalExtent.left = 0;
504 dc->totalExtent.top = 0;
505 dc->totalExtent.right = bitmap->bitmap.bmWidth;
506 dc->totalExtent.bottom = bitmap->bitmap.bmHeight;
507 dc->flags &= ~DC_DIRTY;
508 SetRectRgn( dc->hVisRgn, 0, 0, bitmap->bitmap.bmWidth, bitmap->bitmap.bmHeight);
509 CLIPPING_UpdateGCRegion( dc );
511 if (dc->bitsPerPixel != bitmap->bitmap.bmBitsPixel)
513 /* depth changed, reinitialize the DC */
514 dc->bitsPerPixel = bitmap->bitmap.bmBitsPixel;
515 DC_InitDC( dc );
518 done:
519 GDI_ReleaseObj( hdc );
520 return ret;
524 /***********************************************************************
525 * BITMAP_DeleteObject
527 static BOOL BITMAP_DeleteObject( HGDIOBJ handle, void *obj )
529 BITMAPOBJ * bmp = obj;
531 if (bmp->funcs && bmp->funcs->pDeleteBitmap)
532 bmp->funcs->pDeleteBitmap( handle );
534 if( bmp->bitmap.bmBits )
535 HeapFree( GetProcessHeap(), 0, bmp->bitmap.bmBits );
537 if (bmp->dib)
539 DIBSECTION *dib = bmp->dib;
541 if (dib->dsBm.bmBits)
543 if (dib->dshSection)
545 SYSTEM_INFO SystemInfo;
546 GetSystemInfo( &SystemInfo );
547 UnmapViewOfFile( (char *)dib->dsBm.bmBits -
548 (dib->dsOffset % SystemInfo.dwAllocationGranularity) );
550 else if (!dib->dsOffset)
551 VirtualFree(dib->dsBm.bmBits, 0L, MEM_RELEASE );
553 HeapFree(GetProcessHeap(), 0, dib);
554 bmp->dib = NULL;
555 if (bmp->segptr_bits)
556 { /* free its selector array */
557 WORD sel = SELECTOROF(bmp->segptr_bits);
558 WORD count = (GetSelectorLimit16(sel) / 0x10000) + 1;
559 int i;
561 for (i = 0; i < count; i++) FreeSelector16(sel + (i << __AHSHIFT));
564 return GDI_FreeObject( handle, obj );
568 /***********************************************************************
569 * BITMAP_GetObject16
571 static INT BITMAP_GetObject16( HGDIOBJ handle, void *obj, INT count, LPVOID buffer )
573 BITMAPOBJ *bmp = obj;
575 if (bmp->dib)
577 if ( count <= sizeof(BITMAP16) )
579 BITMAP *bmp32 = &bmp->dib->dsBm;
580 BITMAP16 bmp16;
581 bmp16.bmType = bmp32->bmType;
582 bmp16.bmWidth = bmp32->bmWidth;
583 bmp16.bmHeight = bmp32->bmHeight;
584 bmp16.bmWidthBytes = bmp32->bmWidthBytes;
585 bmp16.bmPlanes = bmp32->bmPlanes;
586 bmp16.bmBitsPixel = bmp32->bmBitsPixel;
587 bmp16.bmBits = (SEGPTR)0;
588 memcpy( buffer, &bmp16, count );
589 return count;
591 else
593 FIXME("not implemented for DIBs: count %d\n", count);
594 return 0;
597 else
599 BITMAP16 bmp16;
600 bmp16.bmType = bmp->bitmap.bmType;
601 bmp16.bmWidth = bmp->bitmap.bmWidth;
602 bmp16.bmHeight = bmp->bitmap.bmHeight;
603 bmp16.bmWidthBytes = bmp->bitmap.bmWidthBytes;
604 bmp16.bmPlanes = bmp->bitmap.bmPlanes;
605 bmp16.bmBitsPixel = bmp->bitmap.bmBitsPixel;
606 bmp16.bmBits = (SEGPTR)0;
607 if (count > sizeof(bmp16)) count = sizeof(bmp16);
608 memcpy( buffer, &bmp16, count );
609 return count;
614 /***********************************************************************
615 * BITMAP_GetObject
617 static INT BITMAP_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffer )
619 BITMAPOBJ *bmp = obj;
621 if (bmp->dib)
623 if (count < sizeof(DIBSECTION))
625 if (count > sizeof(BITMAP)) count = sizeof(BITMAP);
627 else
629 if (count > sizeof(DIBSECTION)) count = sizeof(DIBSECTION);
632 memcpy( buffer, bmp->dib, count );
633 return count;
635 else
637 if (count > sizeof(BITMAP)) count = sizeof(BITMAP);
638 memcpy( buffer, &bmp->bitmap, count );
639 return count;
644 /***********************************************************************
645 * CreateDiscardableBitmap (GDI.156)
647 HBITMAP16 WINAPI CreateDiscardableBitmap16( HDC16 hdc, INT16 width,
648 INT16 height )
650 return CreateCompatibleBitmap16( hdc, width, height );
654 /******************************************************************************
655 * CreateDiscardableBitmap [GDI32.@] Creates a discardable bitmap
657 * RETURNS
658 * Success: Handle to bitmap
659 * Failure: NULL
661 HBITMAP WINAPI CreateDiscardableBitmap(
662 HDC hdc, /* [in] Handle to device context */
663 INT width, /* [in] Bitmap width */
664 INT height) /* [in] Bitmap height */
666 return CreateCompatibleBitmap( hdc, width, height );
670 /***********************************************************************
671 * GetBitmapDimensionEx (GDI.468)
673 * NOTES
674 * Can this call GetBitmapDimensionEx?
676 BOOL16 WINAPI GetBitmapDimensionEx16( HBITMAP16 hbitmap, LPSIZE16 size )
678 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
679 if (!bmp) return FALSE;
680 size->cx = bmp->size.cx;
681 size->cy = bmp->size.cy;
682 GDI_ReleaseObj( hbitmap );
683 return TRUE;
687 /******************************************************************************
688 * GetBitmapDimensionEx [GDI32.@] Retrieves dimensions of a bitmap
690 * RETURNS
691 * Success: TRUE
692 * Failure: FALSE
694 BOOL WINAPI GetBitmapDimensionEx(
695 HBITMAP hbitmap, /* [in] Handle to bitmap */
696 LPSIZE size) /* [out] Address of struct receiving dimensions */
698 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
699 if (!bmp) return FALSE;
700 *size = bmp->size;
701 GDI_ReleaseObj( hbitmap );
702 return TRUE;
706 /***********************************************************************
707 * GetBitmapDimension (GDI.162)
709 DWORD WINAPI GetBitmapDimension16( HBITMAP16 hbitmap )
711 SIZE16 size;
712 if (!GetBitmapDimensionEx16( hbitmap, &size )) return 0;
713 return MAKELONG( size.cx, size.cy );
717 /***********************************************************************
718 * SetBitmapDimensionEx (GDI.478)
720 BOOL16 WINAPI SetBitmapDimensionEx16( HBITMAP16 hbitmap, INT16 x, INT16 y,
721 LPSIZE16 prevSize )
723 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
724 if (!bmp) return FALSE;
725 if (prevSize)
727 prevSize->cx = bmp->size.cx;
728 prevSize->cy = bmp->size.cy;
730 bmp->size.cx = x;
731 bmp->size.cy = y;
732 GDI_ReleaseObj( hbitmap );
733 return TRUE;
737 /******************************************************************************
738 * SetBitmapDimensionEx [GDI32.@] Assignes dimensions to a bitmap
740 * RETURNS
741 * Success: TRUE
742 * Failure: FALSE
744 BOOL WINAPI SetBitmapDimensionEx(
745 HBITMAP hbitmap, /* [in] Handle to bitmap */
746 INT x, /* [in] Bitmap width */
747 INT y, /* [in] Bitmap height */
748 LPSIZE prevSize) /* [out] Address of structure for orig dims */
750 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
751 if (!bmp) return FALSE;
752 if (prevSize) *prevSize = bmp->size;
753 bmp->size.cx = x;
754 bmp->size.cy = y;
755 GDI_ReleaseObj( hbitmap );
756 return TRUE;
760 /***********************************************************************
761 * SetBitmapDimension (GDI.163)
763 DWORD WINAPI SetBitmapDimension16( HBITMAP16 hbitmap, INT16 x, INT16 y )
765 SIZE16 size;
766 if (!SetBitmapDimensionEx16( hbitmap, x, y, &size )) return 0;
767 return MAKELONG( size.cx, size.cy );