4 * Copyright 1993 Alexandre Julliard
15 #include "sysmetrics.h"
16 #include "cursoricon.h"
21 /***********************************************************************
24 * Return number of bytes to pad a scanline of 16-bit aligned Windows DDB data.
26 INT32
BITMAP_GetPadding( int bmWidth
, int bpp
)
33 pad
= ((bmWidth
-1) & 8) ? 0 : 1;
37 pad
= (2 - (bmWidth
& 1)) & 1;
41 pad
= (bmWidth
*3) & 1;
47 pad
= 0; /* we have 16bit alignment already */
51 if (!(bmWidth
& 3)) pad
= 0;
52 else pad
= ((4 - (bmWidth
& 3)) + 1) / 2;
56 WARN(bitmap
,"Unknown depth %d, please report.\n", bpp
);
62 /***********************************************************************
63 * BITMAP_GetWidthBytes
65 * Return number of bytes taken by a scanline of 16-bit aligned Windows DDB
68 INT32
BITMAP_GetWidthBytes( INT32 bmWidth
, INT32 bpp
)
73 return 2 * ((bmWidth
+15) >> 4);
76 bmWidth
*= 3; /* fall through */
78 return bmWidth
+ (bmWidth
& 1);
88 return 2 * ((bmWidth
+3) >> 2);
91 WARN(bitmap
,"Unknown depth %d, please report.\n", bpp
);
96 /***********************************************************************
97 * CreateUserBitmap16 (GDI.407)
99 HBITMAP16 WINAPI
CreateUserBitmap16( INT16 width
, INT16 height
, UINT16 planes
,
100 UINT16 bpp
, LPCVOID bits
)
102 return CreateBitmap16( width
, height
, planes
, bpp
, bits
);
105 /***********************************************************************
106 * CreateUserDiscardableBitmap16 (GDI.409)
108 HBITMAP16 WINAPI
CreateUserDiscardableBitmap16( WORD dummy
,
109 INT16 width
, INT16 height
)
111 return CreateUserBitmap16( width
, height
, 1, screenDepth
, NULL
);
115 /***********************************************************************
116 * CreateBitmap16 (GDI.48)
118 HBITMAP16 WINAPI
CreateBitmap16( INT16 width
, INT16 height
, UINT16 planes
,
119 UINT16 bpp
, LPCVOID bits
)
121 return CreateBitmap32( width
, height
, planes
, bpp
, bits
);
125 /******************************************************************************
126 * CreateBitmap32 [GDI32.25] Creates a bitmap with the specified info
129 * width [I] bitmap width
130 * height [I] bitmap height
131 * planes [I] Number of color planes
132 * bpp [I] Number of bits to identify a color
133 * bits [I] Pointer to array containing color data
136 * Success: Handle to bitmap
139 HBITMAP32 WINAPI
CreateBitmap32( INT32 width
, INT32 height
, UINT32 planes
,
140 UINT32 bpp
, LPCVOID bits
)
145 planes
= (BYTE
)planes
;
149 /* Check parameters */
150 if (!height
|| !width
) return 0;
152 FIXME(bitmap
, "planes = %d\n", planes
);
155 if (height
< 0) height
= -height
;
156 if (width
< 0) width
= -width
;
158 /* Create the BITMAPOBJ */
159 hbitmap
= GDI_AllocObject( sizeof(BITMAPOBJ
), BITMAP_MAGIC
);
160 if (!hbitmap
) return 0;
162 TRACE(bitmap
, "%dx%d, %d colors returning %08x\n", width
, height
,
163 1 << (planes
*bpp
), hbitmap
);
165 bmp
= (BITMAPOBJ
*) GDI_HEAP_LOCK( hbitmap
);
169 bmp
->bitmap
.bmType
= 0;
170 bmp
->bitmap
.bmWidth
= width
;
171 bmp
->bitmap
.bmHeight
= height
;
172 bmp
->bitmap
.bmPlanes
= planes
;
173 bmp
->bitmap
.bmBitsPixel
= bpp
;
174 bmp
->bitmap
.bmWidthBytes
= BITMAP_GetWidthBytes( width
, bpp
);
175 bmp
->bitmap
.bmBits
= NULL
;
177 bmp
->DDBitmap
= NULL
;
180 if (bits
) /* Set bitmap bits */
181 SetBitmapBits32( hbitmap
, height
* bmp
->bitmap
.bmWidthBytes
,
183 GDI_HEAP_UNLOCK( hbitmap
);
188 /***********************************************************************
189 * CreateCompatibleBitmap16 (GDI.51)
191 HBITMAP16 WINAPI
CreateCompatibleBitmap16(HDC16 hdc
, INT16 width
, INT16 height
)
193 return CreateCompatibleBitmap32( hdc
, width
, height
);
197 /******************************************************************************
198 * CreateCompatibleBitmap32 [GDI32.30] Creates a bitmap compatible with the DC
201 * hdc [I] Handle to device context
202 * width [I] Width of bitmap
203 * height [I] Height of bitmap
206 * Success: Handle to bitmap
209 HBITMAP32 WINAPI
CreateCompatibleBitmap32( HDC32 hdc
, INT32 width
, INT32 height
)
211 HBITMAP32 hbmpRet
= 0;
214 TRACE(bitmap
, "(%04x,%d,%d) = \n", hdc
, width
, height
);
215 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
216 if ((width
>0x1000) || (height
> 0x1000)) {
217 FIXME(bitmap
,"got bad width %d or height %d, please look for reason\n",
221 hbmpRet
= CreateBitmap32( width
, height
, 1, dc
->w
.bitsPerPixel
, NULL
);
223 if(dc
->funcs
->pCreateBitmap
)
224 dc
->funcs
->pCreateBitmap( hbmpRet
);
226 TRACE(bitmap
,"\t\t%04x\n", hbmpRet
);
231 /***********************************************************************
232 * CreateBitmapIndirect16 (GDI.49)
234 HBITMAP16 WINAPI
CreateBitmapIndirect16( const BITMAP16
* bmp
)
236 return CreateBitmap16( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
237 bmp
->bmBitsPixel
, PTR_SEG_TO_LIN( bmp
->bmBits
) );
241 /******************************************************************************
242 * CreateBitmapIndirect32 [GDI32.26] Creates a bitmap with the specifies info
245 * Success: Handle to bitmap
248 HBITMAP32 WINAPI
CreateBitmapIndirect32(
249 const BITMAP32
* bmp
) /* [in] Pointer to the bitmap data */
251 return CreateBitmap32( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
252 bmp
->bmBitsPixel
, bmp
->bmBits
);
256 /***********************************************************************
257 * GetBitmapBits16 (GDI.74)
259 LONG WINAPI
GetBitmapBits16( HBITMAP16 hbitmap
, LONG count
, LPVOID buffer
)
261 return GetBitmapBits32( hbitmap
, count
, buffer
);
265 /***********************************************************************
266 * GetBitmapBits32 [GDI32.143] Copies bitmap bits of bitmap to buffer
269 * Success: Number of bytes copied
272 LONG WINAPI
GetBitmapBits32(
273 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
274 LONG count
, /* [in] Number of bytes to copy */
275 LPVOID bits
) /* [out] Pointer to buffer to receive bits */
277 BITMAPOBJ
*bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
283 WARN(bitmap
, "(%ld): Negative number of bytes passed???\n", count
);
287 /* Only get entire lines */
288 height
= count
/ bmp
->bitmap
.bmWidthBytes
;
289 if (height
> bmp
->bitmap
.bmHeight
) height
= bmp
->bitmap
.bmHeight
;
290 count
= height
* bmp
->bitmap
.bmWidthBytes
;
292 TRACE(bitmap
, "(%08x, %ld, %p) %dx%d %d colors fetched height: %ld\n",
293 hbitmap
, count
, bits
, bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
294 1 << bmp
->bitmap
.bmBitsPixel
, height
);
298 TRACE(bitmap
, "Calling device specific BitmapBits\n");
299 if(bmp
->DDBitmap
->funcs
->pBitmapBits
)
300 ret
= bmp
->DDBitmap
->funcs
->pBitmapBits(hbitmap
, bits
, count
,
303 ERR(bitmap
, "BitmapBits == NULL??\n");
309 if(!bmp
->bitmap
.bmBits
) {
310 WARN(bitmap
, "Bitmap is empty\n");
313 memcpy(bits
, bmp
->bitmap
.bmBits
, count
);
319 GDI_HEAP_UNLOCK( hbitmap
);
324 /***********************************************************************
325 * SetBitmapBits16 (GDI.106)
327 LONG WINAPI
SetBitmapBits16( HBITMAP16 hbitmap
, LONG count
, LPCVOID buffer
)
329 return SetBitmapBits32( hbitmap
, count
, buffer
);
333 /******************************************************************************
334 * SetBitmapBits32 [GDI32.303] Sets bits of color data for a bitmap
337 * Success: Number of bytes used in setting the bitmap bits
340 LONG WINAPI
SetBitmapBits32(
341 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
342 LONG count
, /* [in] Number of bytes in bitmap array */
343 LPCVOID bits
) /* [in] Address of array with bitmap bits */
345 BITMAPOBJ
*bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
351 WARN(bitmap
, "(%ld): Negative number of bytes passed???\n", count
);
355 /* Only get entire lines */
356 height
= count
/ bmp
->bitmap
.bmWidthBytes
;
357 if (height
> bmp
->bitmap
.bmHeight
) height
= bmp
->bitmap
.bmHeight
;
358 count
= height
* bmp
->bitmap
.bmWidthBytes
;
360 TRACE(bitmap
, "(%08x, %ld, %p) %dx%d %d colors fetched height: %ld\n",
361 hbitmap
, count
, bits
, bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
362 1 << bmp
->bitmap
.bmBitsPixel
, height
);
366 TRACE(bitmap
, "Calling device specific BitmapBits\n");
367 if(bmp
->DDBitmap
->funcs
->pBitmapBits
)
368 ret
= bmp
->DDBitmap
->funcs
->pBitmapBits(hbitmap
, (void *) bits
,
371 ERR(bitmap
, "BitmapBits == NULL??\n");
377 if(!bmp
->bitmap
.bmBits
) /* Alloc enough for entire bitmap */
378 bmp
->bitmap
.bmBits
= HeapAlloc( GetProcessHeap(), 0, count
);
379 if(!bmp
->bitmap
.bmBits
) {
380 WARN(bitmap
, "Unable to allocate bit buffer\n");
383 memcpy(bmp
->bitmap
.bmBits
, bits
, count
);
388 GDI_HEAP_UNLOCK( hbitmap
);
392 /***********************************************************************
393 * LoadImage16 [USER.389]
396 HANDLE16 WINAPI
LoadImage16( HINSTANCE16 hinst
, LPCSTR name
, UINT16 type
,
397 INT16 desiredx
, INT16 desiredy
, UINT16 loadflags
)
400 TRACE(resource
,"(0x%04x,%s,%d,%d,%d,0x%08x)\n",
401 hinst
,(char *)PTR_SEG_TO_LIN(name
),type
,desiredx
,desiredy
,loadflags
);
403 TRACE(resource
,"LoadImage16(0x%04x,%p,%d,%d,%d,0x%08x)\n",
404 hinst
,name
,type
,desiredx
,desiredy
,loadflags
);
408 return LoadBitmap16(hinst
,(SEGPTR
)name
);
410 return LoadIcon16(hinst
,(SEGPTR
)name
);
412 return LoadCursor16(hinst
,(SEGPTR
)name
);
418 /**********************************************************************
419 * LoadImage32A (USER32.365)
421 * FIXME: implementation lacks some features, see LR_ defines in windows.h
424 HANDLE32 WINAPI
LoadImage32A( HINSTANCE32 hinst
, LPCSTR name
, UINT32 type
,
425 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
430 if (HIWORD(name
)) u_name
= HEAP_strdupAtoW(GetProcessHeap(), 0, name
);
431 else u_name
=(LPWSTR
)name
;
432 res
= LoadImage32W(hinst
, u_name
, type
, desiredx
, desiredy
, loadflags
);
433 if (HIWORD(name
)) HeapFree(GetProcessHeap(), 0, u_name
);
438 /******************************************************************************
439 * LoadImage32W [USER32.366] Loads an icon, cursor, or bitmap
442 * hinst [I] Handle of instance that contains image
443 * name [I] Name of image
444 * type [I] Type of image
445 * desiredx [I] Desired width
446 * desiredy [I] Desired height
447 * loadflags [I] Load flags
450 * Success: Handle to newly loaded image
453 * FIXME: Implementation lacks some features, see LR_ defines in windows.h
455 HANDLE32 WINAPI
LoadImage32W( HINSTANCE32 hinst
, LPCWSTR name
, UINT32 type
,
456 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
459 TRACE(resource
,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
460 hinst
,name
,type
,desiredx
,desiredy
,loadflags
463 TRACE(resource
,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
464 hinst
,name
,type
,desiredx
,desiredy
,loadflags
467 if (loadflags
& LR_DEFAULTSIZE
)
469 if (type
== IMAGE_ICON
) {
470 if (!desiredx
) desiredx
= SYSMETRICS_CXICON
;
471 if (!desiredy
) desiredy
= SYSMETRICS_CYICON
;
472 } else if (type
== IMAGE_CURSOR
) {
473 if (!desiredx
) desiredx
= SYSMETRICS_CXCURSOR
;
474 if (!desiredy
) desiredy
= SYSMETRICS_CYCURSOR
;
477 if (loadflags
& LR_LOADFROMFILE
) loadflags
&= ~LR_SHARED
;
480 return BITMAP_LoadBitmap32W(hinst
, name
, loadflags
);
482 return CURSORICON_Load32(hinst
, name
, desiredx
, desiredy
,
483 MIN(16, COLOR_GetSystemPaletteSize()), FALSE
, loadflags
);
485 return CURSORICON_Load32(hinst
, name
, desiredx
, desiredy
, 1, TRUE
,
492 /**********************************************************************
496 HBITMAP32
BITMAP_CopyBitmap(HBITMAP32 hbitmap
)
498 BITMAPOBJ
*bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
506 res
= CreateBitmapIndirect32(&bm
);
509 char *buf
= HeapAlloc( GetProcessHeap(), 0, bm
.bmWidthBytes
*
511 GetBitmapBits32 (hbitmap
, bm
.bmWidthBytes
* bm
.bmHeight
, buf
);
512 SetBitmapBits32 (res
, bm
.bmWidthBytes
* bm
.bmHeight
, buf
);
513 HeapFree( GetProcessHeap(), 0, buf
);
516 GDI_HEAP_UNLOCK( hbitmap
);
521 /******************************************************************************
522 * CopyImage32 [USER32.61] Creates new image and copies attributes to it
525 * hnd [I] Handle to image to copy
526 * type [I] Type of image to copy
527 * desiredx [I] Desired width of new image
528 * desiredy [I] Desired height of new image
529 * flags [I] Copy flags
532 * Success: Handle to newly created image
535 * FIXME: implementation still lacks nearly all features, see LR_*
536 * defines in windows.h
538 HICON32 WINAPI
CopyImage32( HANDLE32 hnd
, UINT32 type
, INT32 desiredx
,
539 INT32 desiredy
, UINT32 flags
)
544 return BITMAP_CopyBitmap(hnd
);
546 return CopyIcon32(hnd
);
548 return CopyCursor32(hnd
);
553 /**********************************************************************
554 * LoadBitmap16 (USER.175)
557 * Can this call LoadBitmap32?
559 HBITMAP16 WINAPI
LoadBitmap16( HINSTANCE16 instance
, SEGPTR name
)
561 HBITMAP32 hbitmap
= 0;
569 char *str
= (char *)PTR_SEG_TO_LIN( name
);
570 TRACE(bitmap
, "(%04x,'%s')\n", instance
, str
);
571 if (str
[0] == '#') name
= (SEGPTR
)(DWORD
)(WORD
)atoi( str
+ 1 );
574 TRACE(bitmap
, "(%04x,%04x)\n",
575 instance
, LOWORD(name
) );
577 if (!instance
) /* OEM bitmap */
579 if (HIWORD((int)name
)) return 0;
580 return OBM_LoadBitmap( LOWORD((int)name
) );
583 if (!(hRsrc
= FindResource16( instance
, name
, RT_BITMAP16
))) return 0;
584 if (!(handle
= LoadResource16( instance
, hRsrc
))) return 0;
586 info
= (BITMAPINFO
*)LockResource16( handle
);
587 if ((hdc
= GetDC32(0)) != 0)
589 char *bits
= (char *)info
+ DIB_BitmapInfoSize( info
, DIB_RGB_COLORS
);
590 hbitmap
= CreateDIBitmap32( hdc
, &info
->bmiHeader
, CBM_INIT
,
591 bits
, info
, DIB_RGB_COLORS
);
592 ReleaseDC32( 0, hdc
);
594 FreeResource16( handle
);
599 /**********************************************************************
600 * BITMAP_LoadBitmap32W
602 HBITMAP32
BITMAP_LoadBitmap32W(HINSTANCE32 instance
,LPCWSTR name
,
605 HBITMAP32 hbitmap
= 0;
610 BITMAPINFO
*info
, *fix_info
=NULL
;
614 if (!(loadflags
& LR_LOADFROMFILE
)) {
615 if (!instance
) /* OEM bitmap */
617 if (HIWORD((int)name
)) return 0;
618 return OBM_LoadBitmap( LOWORD((int)name
) );
621 if (!(hRsrc
= FindResource32W( instance
, name
, RT_BITMAP32W
))) return 0;
622 if (!(handle
= LoadResource32( instance
, hRsrc
))) return 0;
624 if ((info
= (BITMAPINFO
*)LockResource32( handle
)) == NULL
) return 0;
628 if (!(ptr
= (char *)VIRTUAL_MapFileW( name
))) return 0;
629 info
= (BITMAPINFO
*)(ptr
+ sizeof(BITMAPFILEHEADER
));
631 size
= DIB_BitmapInfoSize(info
, DIB_RGB_COLORS
);
632 if ((hFix
= GlobalAlloc32(0, size
))) fix_info
=GlobalLock32(hFix
);
636 memcpy(fix_info
, info
, size
);
637 pix
= *((LPBYTE
)info
+DIB_BitmapInfoSize(info
, DIB_RGB_COLORS
));
638 DIB_FixColorsToLoadflags(fix_info
, loadflags
, pix
);
639 if ((hdc
= GetDC32(0)) != 0) {
640 if (loadflags
& LR_CREATEDIBSECTION
)
641 hbitmap
= CreateDIBSection32(hdc
, fix_info
, DIB_RGB_COLORS
, NULL
, 0, 0);
643 char *bits
= (char *)info
+ size
;;
644 hbitmap
= CreateDIBitmap32( hdc
, &fix_info
->bmiHeader
, CBM_INIT
,
645 bits
, fix_info
, DIB_RGB_COLORS
);
647 ReleaseDC32( 0, hdc
);
649 GlobalUnlock32(hFix
);
652 if (loadflags
& LR_LOADFROMFILE
) UnmapViewOfFile( ptr
);
657 /******************************************************************************
658 * LoadBitmap32W [USER32.358] Loads bitmap from the executable file
661 * Success: Handle to specified bitmap
664 HBITMAP32 WINAPI
LoadBitmap32W(
665 HINSTANCE32 instance
, /* [in] Handle to application instance */
666 LPCWSTR name
) /* [in] Address of bitmap resource name */
668 return BITMAP_LoadBitmap32W(instance
, name
, 0);
672 /**********************************************************************
673 * LoadBitmap32A (USER32.357)
675 HBITMAP32 WINAPI
LoadBitmap32A( HINSTANCE32 instance
, LPCSTR name
)
678 if (!HIWORD(name
)) res
= LoadBitmap32W( instance
, (LPWSTR
)name
);
681 LPWSTR uni
= HEAP_strdupAtoW( GetProcessHeap(), 0, name
);
682 res
= LoadBitmap32W( instance
, uni
);
683 HeapFree( GetProcessHeap(), 0, uni
);
689 /***********************************************************************
690 * BITMAP_DeleteObject
692 BOOL32
BITMAP_DeleteObject( HBITMAP16 hbitmap
, BITMAPOBJ
* bmp
)
694 if( bmp
->DDBitmap
) {
695 if( bmp
->DDBitmap
->funcs
->pDeleteObject
)
696 bmp
->DDBitmap
->funcs
->pDeleteObject( hbitmap
);
699 if( bmp
->bitmap
.bmBits
)
700 HeapFree( GetProcessHeap(), 0, bmp
->bitmap
.bmBits
);
702 DIB_DeleteDIBSection( bmp
);
704 return GDI_FreeObject( hbitmap
);
708 /***********************************************************************
711 INT16
BITMAP_GetObject16( BITMAPOBJ
* bmp
, INT16 count
, LPVOID buffer
)
715 if ( count
<= sizeof(BITMAP16
) )
717 BITMAP32
*bmp32
= &bmp
->dib
->dibSection
.dsBm
;
719 bmp16
.bmType
= bmp32
->bmType
;
720 bmp16
.bmWidth
= bmp32
->bmWidth
;
721 bmp16
.bmHeight
= bmp32
->bmHeight
;
722 bmp16
.bmWidthBytes
= bmp32
->bmWidthBytes
;
723 bmp16
.bmPlanes
= bmp32
->bmPlanes
;
724 bmp16
.bmBitsPixel
= bmp32
->bmBitsPixel
;
725 bmp16
.bmBits
= (SEGPTR
)0;
726 memcpy( buffer
, &bmp16
, count
);
731 FIXME(bitmap
, "not implemented for DIBs: count %d\n", count
);
738 bmp16
.bmType
= bmp
->bitmap
.bmType
;
739 bmp16
.bmWidth
= bmp
->bitmap
.bmWidth
;
740 bmp16
.bmHeight
= bmp
->bitmap
.bmHeight
;
741 bmp16
.bmWidthBytes
= bmp
->bitmap
.bmWidthBytes
;
742 bmp16
.bmPlanes
= bmp
->bitmap
.bmPlanes
;
743 bmp16
.bmBitsPixel
= bmp
->bitmap
.bmBitsPixel
;
744 bmp16
.bmBits
= (SEGPTR
)0;
745 if (count
> sizeof(bmp16
)) count
= sizeof(bmp16
);
746 memcpy( buffer
, &bmp16
, count
);
752 /***********************************************************************
755 INT32
BITMAP_GetObject32( BITMAPOBJ
* bmp
, INT32 count
, LPVOID buffer
)
759 if (count
< sizeof(DIBSECTION
))
761 if (count
> sizeof(BITMAP32
)) count
= sizeof(BITMAP32
);
765 if (count
> sizeof(DIBSECTION
)) count
= sizeof(DIBSECTION
);
768 memcpy( buffer
, &bmp
->dib
->dibSection
, count
);
773 if (count
> sizeof(BITMAP32
)) count
= sizeof(BITMAP32
);
774 memcpy( buffer
, &bmp
->bitmap
, count
);
780 /***********************************************************************
781 * CreateDiscardableBitmap16 (GDI.156)
783 HBITMAP16 WINAPI
CreateDiscardableBitmap16( HDC16 hdc
, INT16 width
,
786 return CreateCompatibleBitmap16( hdc
, width
, height
);
790 /******************************************************************************
791 * CreateDiscardableBitmap32 [GDI32.38] Creates a discardable bitmap
794 * Success: Handle to bitmap
797 HBITMAP32 WINAPI
CreateDiscardableBitmap32(
798 HDC32 hdc
, /* [in] Handle to device context */
799 INT32 width
, /* [in] Bitmap width */
800 INT32 height
) /* [in] Bitmap height */
802 return CreateCompatibleBitmap32( hdc
, width
, height
);
806 /***********************************************************************
807 * GetBitmapDimensionEx16 (GDI.468)
810 * Can this call GetBitmapDimensionEx32?
812 BOOL16 WINAPI
GetBitmapDimensionEx16( HBITMAP16 hbitmap
, LPSIZE16 size
)
814 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
815 if (!bmp
) return FALSE
;
816 CONV_SIZE32TO16( &bmp
->size
, size
);
817 GDI_HEAP_UNLOCK( hbitmap
);
822 /******************************************************************************
823 * GetBitmapDimensionEx32 [GDI32.144] Retrieves dimensions of a bitmap
829 BOOL32 WINAPI
GetBitmapDimensionEx32(
830 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
831 LPSIZE32 size
) /* [out] Address of struct receiving dimensions */
833 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
834 if (!bmp
) return FALSE
;
836 GDI_HEAP_UNLOCK( hbitmap
);
841 /***********************************************************************
842 * GetBitmapDimension (GDI.162)
844 DWORD WINAPI
GetBitmapDimension( HBITMAP16 hbitmap
)
847 if (!GetBitmapDimensionEx16( hbitmap
, &size
)) return 0;
848 return MAKELONG( size
.cx
, size
.cy
);
852 /***********************************************************************
853 * SetBitmapDimensionEx16 (GDI.478)
855 BOOL16 WINAPI
SetBitmapDimensionEx16( HBITMAP16 hbitmap
, INT16 x
, INT16 y
,
858 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
859 if (!bmp
) return FALSE
;
860 if (prevSize
) CONV_SIZE32TO16( &bmp
->size
, prevSize
);
863 GDI_HEAP_UNLOCK( hbitmap
);
868 /******************************************************************************
869 * SetBitmapDimensionEx32 [GDI32.304] Assignes dimensions to a bitmap
875 BOOL32 WINAPI
SetBitmapDimensionEx32(
876 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
877 INT32 x
, /* [in] Bitmap width */
878 INT32 y
, /* [in] Bitmap height */
879 LPSIZE32 prevSize
) /* [out] Address of structure for orig dims */
881 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
882 if (!bmp
) return FALSE
;
883 if (prevSize
) *prevSize
= bmp
->size
;
886 GDI_HEAP_UNLOCK( hbitmap
);
891 /***********************************************************************
892 * SetBitmapDimension (GDI.163)
894 DWORD WINAPI
SetBitmapDimension( HBITMAP16 hbitmap
, INT16 x
, INT16 y
)
897 if (!SetBitmapDimensionEx16( hbitmap
, x
, y
, &size
)) return 0;
898 return MAKELONG( size
.cx
, size
.cy
);