4 * Copyright 1993 Alexandre Julliard
11 #include "wine/winbase16.h"
17 #include "sysmetrics.h"
18 #include "cursoricon.h"
21 #include "wine/winuser16.h"
23 /***********************************************************************
26 * Return number of bytes to pad a scanline of 16-bit aligned Windows DDB data.
28 INT BITMAP_GetPadding( int bmWidth, int bpp )
35 pad = ((bmWidth-1) & 8) ? 0 : 1;
39 pad = (2 - (bmWidth & 1)) & 1;
43 pad = (bmWidth*3) & 1;
49 pad = 0; /* we have 16bit alignment already */
53 if (!(bmWidth & 3)) pad = 0;
54 else pad = ((4 - (bmWidth & 3)) + 1) / 2;
58 WARN(bitmap,"Unknown depth %d, please report.\n", bpp );
64 /***********************************************************************
65 * BITMAP_GetWidthBytes
67 * Return number of bytes taken by a scanline of 16-bit aligned Windows DDB
70 INT BITMAP_GetWidthBytes( INT bmWidth, INT bpp )
75 return 2 * ((bmWidth+15) >> 4);
78 bmWidth *= 3; /* fall through */
80 return bmWidth + (bmWidth & 1);
90 return 2 * ((bmWidth+3) >> 2);
93 WARN(bitmap,"Unknown depth %d, please report.\n", bpp );
98 /***********************************************************************
99 * CreateUserBitmap16 (GDI.407)
101 HBITMAP16 WINAPI CreateUserBitmap16( INT16 width, INT16 height, UINT16 planes,
102 UINT16 bpp, LPCVOID bits )
104 return CreateBitmap16( width, height, planes, bpp, bits );
107 /***********************************************************************
108 * CreateUserDiscardableBitmap16 (GDI.409)
110 HBITMAP16 WINAPI CreateUserDiscardableBitmap16( WORD dummy,
111 INT16 width, INT16 height )
113 return CreateUserBitmap16( width, height, 1, MONITOR_GetDepth(&MONITOR_PrimaryMonitor), NULL );
117 /***********************************************************************
118 * CreateBitmap16 (GDI.48)
120 HBITMAP16 WINAPI CreateBitmap16( INT16 width, INT16 height, UINT16 planes,
121 UINT16 bpp, LPCVOID bits )
123 return CreateBitmap( width, height, planes, bpp, bits );
127 /******************************************************************************
128 * CreateBitmap32 [GDI32.25] Creates a bitmap with the specified info
131 * width [I] bitmap width
132 * height [I] bitmap height
133 * planes [I] Number of color planes
134 * bpp [I] Number of bits to identify a color
135 * bits [I] Pointer to array containing color data
138 * Success: Handle to bitmap
141 HBITMAP WINAPI CreateBitmap( INT width, INT height, UINT planes,
142 UINT bpp, LPCVOID bits )
147 planes = (BYTE)planes;
151 /* Check parameters */
152 if (!height || !width) return 0;
154 FIXME(bitmap, "planes = %d\n", planes);
157 if (height < 0) height = -height;
158 if (width < 0) width = -width;
160 /* Create the BITMAPOBJ */
161 hbitmap = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC );
162 if (!hbitmap) return 0;
164 TRACE(bitmap, "%dx%d, %d colors returning %08x\n", width, height,
165 1 << (planes*bpp), hbitmap);
167 bmp = (BITMAPOBJ *) GDI_HEAP_LOCK( hbitmap );
171 bmp->bitmap.bmType = 0;
172 bmp->bitmap.bmWidth = width;
173 bmp->bitmap.bmHeight = height;
174 bmp->bitmap.bmPlanes = planes;
175 bmp->bitmap.bmBitsPixel = bpp;
176 bmp->bitmap.bmWidthBytes = BITMAP_GetWidthBytes( width, bpp );
177 bmp->bitmap.bmBits = NULL;
179 bmp->DDBitmap = NULL;
182 if (bits) /* Set bitmap bits */
183 SetBitmapBits( hbitmap, height * bmp->bitmap.bmWidthBytes,
185 GDI_HEAP_UNLOCK( hbitmap );
190 /***********************************************************************
191 * CreateCompatibleBitmap16 (GDI.51)
193 HBITMAP16 WINAPI CreateCompatibleBitmap16(HDC16 hdc, INT16 width, INT16 height)
195 return CreateCompatibleBitmap( hdc, width, height );
199 /******************************************************************************
200 * CreateCompatibleBitmap32 [GDI32.30] Creates a bitmap compatible with the DC
203 * hdc [I] Handle to device context
204 * width [I] Width of bitmap
205 * height [I] Height of bitmap
208 * Success: Handle to bitmap
211 HBITMAP WINAPI CreateCompatibleBitmap( HDC hdc, INT width, INT height)
216 TRACE(bitmap, "(%04x,%d,%d) = \n", hdc, width, height );
217 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
218 if ((width >= 0x10000) || (height >= 0x10000)) {
219 FIXME(bitmap,"got bad width %d or height %d, please look for reason\n",
222 hbmpRet = CreateBitmap( 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);
227 GDI_HEAP_UNLOCK(hdc);
232 /***********************************************************************
233 * CreateBitmapIndirect16 (GDI.49)
235 HBITMAP16 WINAPI CreateBitmapIndirect16( const BITMAP16 * bmp )
237 return CreateBitmap16( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
238 bmp->bmBitsPixel, PTR_SEG_TO_LIN( bmp->bmBits ) );
242 /******************************************************************************
243 * CreateBitmapIndirect32 [GDI32.26] Creates a bitmap with the specifies info
246 * Success: Handle to bitmap
249 HBITMAP WINAPI CreateBitmapIndirect(
250 const BITMAP * bmp) /* [in] Pointer to the bitmap data */
252 return CreateBitmap( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
253 bmp->bmBitsPixel, bmp->bmBits );
257 /***********************************************************************
258 * GetBitmapBits16 (GDI.74)
260 LONG WINAPI GetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPVOID buffer )
262 return GetBitmapBits( hbitmap, count, buffer );
266 /***********************************************************************
267 * GetBitmapBits32 [GDI32.143] Copies bitmap bits of bitmap to buffer
270 * Success: Number of bytes copied
273 LONG WINAPI GetBitmapBits(
274 HBITMAP hbitmap, /* [in] Handle to bitmap */
275 LONG count, /* [in] Number of bytes to copy */
276 LPVOID bits) /* [out] Pointer to buffer to receive bits */
278 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
284 WARN(bitmap, "(%ld): Negative number of bytes passed???\n", count );
288 /* Only get entire lines */
289 height = count / bmp->bitmap.bmWidthBytes;
290 if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
291 count = height * bmp->bitmap.bmWidthBytes;
294 WARN(bitmap, "Less then one entire line requested\n");
295 GDI_HEAP_UNLOCK( hbitmap );
300 TRACE(bitmap, "(%08x, %ld, %p) %dx%d %d colors fetched height: %ld\n",
301 hbitmap, count, bits, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
302 1 << bmp->bitmap.bmBitsPixel, height );
306 TRACE(bitmap, "Calling device specific BitmapBits\n");
307 if(bmp->DDBitmap->funcs->pBitmapBits)
308 ret = bmp->DDBitmap->funcs->pBitmapBits(hbitmap, bits, count,
311 ERR(bitmap, "BitmapBits == NULL??\n");
317 if(!bmp->bitmap.bmBits) {
318 WARN(bitmap, "Bitmap is empty\n");
321 memcpy(bits, bmp->bitmap.bmBits, count);
327 GDI_HEAP_UNLOCK( hbitmap );
332 /***********************************************************************
333 * SetBitmapBits16 (GDI.106)
335 LONG WINAPI SetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPCVOID buffer )
337 return SetBitmapBits( hbitmap, count, buffer );
341 /******************************************************************************
342 * SetBitmapBits32 [GDI32.303] Sets bits of color data for a bitmap
345 * Success: Number of bytes used in setting the bitmap bits
348 LONG WINAPI SetBitmapBits(
349 HBITMAP hbitmap, /* [in] Handle to bitmap */
350 LONG count, /* [in] Number of bytes in bitmap array */
351 LPCVOID bits) /* [in] Address of array with bitmap bits */
353 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
359 WARN(bitmap, "(%ld): Negative number of bytes passed???\n", count );
363 /* Only get entire lines */
364 height = count / bmp->bitmap.bmWidthBytes;
365 if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
366 count = height * bmp->bitmap.bmWidthBytes;
368 TRACE(bitmap, "(%08x, %ld, %p) %dx%d %d colors fetched height: %ld\n",
369 hbitmap, count, bits, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
370 1 << bmp->bitmap.bmBitsPixel, height );
374 TRACE(bitmap, "Calling device specific BitmapBits\n");
375 if(bmp->DDBitmap->funcs->pBitmapBits)
376 ret = bmp->DDBitmap->funcs->pBitmapBits(hbitmap, (void *) bits,
379 ERR(bitmap, "BitmapBits == NULL??\n");
385 if(!bmp->bitmap.bmBits) /* Alloc enough for entire bitmap */
386 bmp->bitmap.bmBits = HeapAlloc( GetProcessHeap(), 0, count );
387 if(!bmp->bitmap.bmBits) {
388 WARN(bitmap, "Unable to allocate bit buffer\n");
391 memcpy(bmp->bitmap.bmBits, bits, count);
396 GDI_HEAP_UNLOCK( hbitmap );
400 /***********************************************************************
401 * LoadImage16 [USER.389]
404 HANDLE16 WINAPI LoadImage16( HINSTANCE16 hinst, LPCSTR name, UINT16 type,
405 INT16 desiredx, INT16 desiredy, UINT16 loadflags)
408 TRACE(resource,"(0x%04x,%s,%d,%d,%d,0x%08x)\n",
409 hinst,(char *)PTR_SEG_TO_LIN(name),type,desiredx,desiredy,loadflags);
411 TRACE(resource,"LoadImage16(0x%04x,%p,%d,%d,%d,0x%08x)\n",
412 hinst,name,type,desiredx,desiredy,loadflags);
416 return LoadBitmap16(hinst,(SEGPTR)name);
418 return LoadIcon16(hinst,(SEGPTR)name);
420 return LoadCursor16(hinst,(SEGPTR)name);
426 /**********************************************************************
427 * LoadImage32A (USER32.365)
429 * FIXME: implementation lacks some features, see LR_ defines in windows.h
432 HANDLE WINAPI LoadImageA( HINSTANCE hinst, LPCSTR name, UINT type,
433 INT desiredx, INT desiredy, UINT loadflags)
438 if (HIWORD(name)) u_name = HEAP_strdupAtoW(GetProcessHeap(), 0, name);
439 else u_name=(LPWSTR)name;
440 res = LoadImageW(hinst, u_name, type, desiredx, desiredy, loadflags);
441 if (HIWORD(name)) HeapFree(GetProcessHeap(), 0, u_name);
446 /******************************************************************************
447 * LoadImage32W [USER32.366] Loads an icon, cursor, or bitmap
450 * hinst [I] Handle of instance that contains image
451 * name [I] Name of image
452 * type [I] Type of image
453 * desiredx [I] Desired width
454 * desiredy [I] Desired height
455 * loadflags [I] Load flags
458 * Success: Handle to newly loaded image
461 * FIXME: Implementation lacks some features, see LR_ defines in windows.h
463 HANDLE WINAPI LoadImageW( HINSTANCE hinst, LPCWSTR name, UINT type,
464 INT desiredx, INT desiredy, UINT loadflags )
467 TRACE(resource,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
468 hinst,name,type,desiredx,desiredy,loadflags);
470 TRACE(resource,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
471 hinst,name,type,desiredx,desiredy,loadflags);
473 if (loadflags & LR_DEFAULTSIZE) {
474 if (type == IMAGE_ICON) {
475 if (!desiredx) desiredx = SYSMETRICS_CXICON;
476 if (!desiredy) desiredy = SYSMETRICS_CYICON;
477 } else if (type == IMAGE_CURSOR) {
478 if (!desiredx) desiredx = SYSMETRICS_CXCURSOR;
479 if (!desiredy) desiredy = SYSMETRICS_CYCURSOR;
482 if (loadflags & LR_LOADFROMFILE) loadflags &= ~LR_SHARED;
485 return BITMAP_LoadBitmapW(hinst, name, loadflags);
490 UINT palEnts = GetSystemPaletteEntries(hdc, 0, 0, NULL);
493 return CURSORICON_Load(hinst, name, desiredx, desiredy,
494 MIN(16, palEnts), FALSE, loadflags);
498 return CURSORICON_Load(hinst, name, desiredx, desiredy,
505 /**********************************************************************
509 HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap)
511 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
519 res = CreateBitmapIndirect(&bm);
522 char *buf = HeapAlloc( GetProcessHeap(), 0, bm.bmWidthBytes *
524 GetBitmapBits (hbitmap, bm.bmWidthBytes * bm.bmHeight, buf);
525 SetBitmapBits (res, bm.bmWidthBytes * bm.bmHeight, buf);
526 HeapFree( GetProcessHeap(), 0, buf );
529 GDI_HEAP_UNLOCK( hbitmap );
533 /******************************************************************************
534 * CopyImage16 [USER.390] Creates new image and copies attributes to it
537 HICON16 WINAPI CopyImage16( HANDLE16 hnd, UINT16 type, INT16 desiredx,
538 INT16 desiredy, UINT16 flags )
540 return (HICON16)CopyImage((HANDLE)hnd, (UINT)type, (INT)desiredx,
541 (INT)desiredy, (UINT)flags);
544 /******************************************************************************
545 * CopyImage32 [USER32.61] Creates new image and copies attributes to it
548 * hnd [I] Handle to image to copy
549 * type [I] Type of image to copy
550 * desiredx [I] Desired width of new image
551 * desiredy [I] Desired height of new image
552 * flags [I] Copy flags
555 * Success: Handle to newly created image
558 * FIXME: implementation still lacks nearly all features, see LR_*
559 * defines in windows.h
561 HICON WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx,
562 INT desiredy, UINT flags )
567 return BITMAP_CopyBitmap(hnd);
569 return CopyIcon(hnd);
571 return CopyCursor(hnd);
576 /**********************************************************************
577 * LoadBitmap16 (USER.175)
580 * Can this call LoadBitmap32?
582 HBITMAP16 WINAPI LoadBitmap16( HINSTANCE16 instance, SEGPTR name )
592 char *str = (char *)PTR_SEG_TO_LIN( name );
593 TRACE(bitmap, "(%04x,'%s')\n", instance, str );
594 if (str[0] == '#') name = (SEGPTR)(DWORD)(WORD)atoi( str + 1 );
597 TRACE(bitmap, "(%04x,%04x)\n",
598 instance, LOWORD(name) );
600 if (!instance) /* OEM bitmap */
605 if (HIWORD((int)name)) return 0;
606 hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
607 dc = DC_GetDCPtr( hdc );
608 if(dc->funcs->pLoadOEMResource)
609 hbitmap = dc->funcs->pLoadOEMResource( LOWORD((int)name),
611 GDI_HEAP_UNLOCK( hdc );
616 if (!(hRsrc = FindResource16( instance, name, RT_BITMAP16 ))) return 0;
617 if (!(handle = LoadResource16( instance, hRsrc ))) return 0;
619 info = (BITMAPINFO *)LockResource16( handle );
620 if ((hdc = GetDC(0)) != 0)
622 char *bits = (char *)info + DIB_BitmapInfoSize( info, DIB_RGB_COLORS );
623 hbitmap = CreateDIBitmap( hdc, &info->bmiHeader, CBM_INIT,
624 bits, info, DIB_RGB_COLORS );
627 FreeResource16( handle );
632 /**********************************************************************
633 * BITMAP_LoadBitmap32W
635 HBITMAP BITMAP_LoadBitmapW(HINSTANCE instance,LPCWSTR name,
643 BITMAPINFO *info, *fix_info=NULL;
647 if (!(loadflags & LR_LOADFROMFILE)) {
648 if (!instance) /* OEM bitmap */
653 if (HIWORD((int)name)) return 0;
654 hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
655 dc = DC_GetDCPtr( hdc );
656 if(dc->funcs->pLoadOEMResource)
657 hbitmap = dc->funcs->pLoadOEMResource( LOWORD((int)name),
659 GDI_HEAP_UNLOCK( hdc );
664 if (!(hRsrc = FindResourceW( instance, name, RT_BITMAPW ))) return 0;
665 if (!(handle = LoadResource( instance, hRsrc ))) return 0;
667 if ((info = (BITMAPINFO *)LockResource( handle )) == NULL) return 0;
671 if (!(ptr = (char *)VIRTUAL_MapFileW( name ))) return 0;
672 info = (BITMAPINFO *)(ptr + sizeof(BITMAPFILEHEADER));
674 size = DIB_BitmapInfoSize(info, DIB_RGB_COLORS);
675 if ((hFix = GlobalAlloc(0, size))) fix_info=GlobalLock(hFix);
679 memcpy(fix_info, info, size);
680 pix = *((LPBYTE)info+DIB_BitmapInfoSize(info, DIB_RGB_COLORS));
681 DIB_FixColorsToLoadflags(fix_info, loadflags, pix);
682 if ((hdc = GetDC(0)) != 0) {
683 if (loadflags & LR_CREATEDIBSECTION)
684 hbitmap = CreateDIBSection(hdc, fix_info, DIB_RGB_COLORS, NULL, 0, 0);
686 char *bits = (char *)info + size;;
687 hbitmap = CreateDIBitmap( hdc, &fix_info->bmiHeader, CBM_INIT,
688 bits, fix_info, DIB_RGB_COLORS );
695 if (loadflags & LR_LOADFROMFILE) UnmapViewOfFile( ptr );
700 /******************************************************************************
701 * LoadBitmap32W [USER32.358] Loads bitmap from the executable file
704 * Success: Handle to specified bitmap
707 HBITMAP WINAPI LoadBitmapW(
708 HINSTANCE instance, /* [in] Handle to application instance */
709 LPCWSTR name) /* [in] Address of bitmap resource name */
711 return BITMAP_LoadBitmapW(instance, name, 0);
715 /**********************************************************************
716 * LoadBitmap32A (USER32.357)
718 HBITMAP WINAPI LoadBitmapA( HINSTANCE instance, LPCSTR name )
721 if (!HIWORD(name)) res = LoadBitmapW( instance, (LPWSTR)name );
724 LPWSTR uni = HEAP_strdupAtoW( GetProcessHeap(), 0, name );
725 res = LoadBitmapW( instance, uni );
726 HeapFree( GetProcessHeap(), 0, uni );
732 /***********************************************************************
733 * BITMAP_DeleteObject
735 BOOL BITMAP_DeleteObject( HBITMAP16 hbitmap, BITMAPOBJ * bmp )
737 if( bmp->DDBitmap ) {
738 if( bmp->DDBitmap->funcs->pDeleteObject )
739 bmp->DDBitmap->funcs->pDeleteObject( hbitmap );
742 if( bmp->bitmap.bmBits )
743 HeapFree( GetProcessHeap(), 0, bmp->bitmap.bmBits );
745 DIB_DeleteDIBSection( bmp );
747 return GDI_FreeObject( hbitmap );
751 /***********************************************************************
754 INT16 BITMAP_GetObject16( BITMAPOBJ * bmp, INT16 count, LPVOID buffer )
758 if ( count <= sizeof(BITMAP16) )
760 BITMAP *bmp32 = &bmp->dib->dibSection.dsBm;
762 bmp16.bmType = bmp32->bmType;
763 bmp16.bmWidth = bmp32->bmWidth;
764 bmp16.bmHeight = bmp32->bmHeight;
765 bmp16.bmWidthBytes = bmp32->bmWidthBytes;
766 bmp16.bmPlanes = bmp32->bmPlanes;
767 bmp16.bmBitsPixel = bmp32->bmBitsPixel;
768 bmp16.bmBits = (SEGPTR)0;
769 memcpy( buffer, &bmp16, count );
774 FIXME(bitmap, "not implemented for DIBs: count %d\n", count);
781 bmp16.bmType = bmp->bitmap.bmType;
782 bmp16.bmWidth = bmp->bitmap.bmWidth;
783 bmp16.bmHeight = bmp->bitmap.bmHeight;
784 bmp16.bmWidthBytes = bmp->bitmap.bmWidthBytes;
785 bmp16.bmPlanes = bmp->bitmap.bmPlanes;
786 bmp16.bmBitsPixel = bmp->bitmap.bmBitsPixel;
787 bmp16.bmBits = (SEGPTR)0;
788 if (count > sizeof(bmp16)) count = sizeof(bmp16);
789 memcpy( buffer, &bmp16, count );
795 /***********************************************************************
798 INT BITMAP_GetObject( BITMAPOBJ * bmp, INT count, LPVOID buffer )
802 if (count < sizeof(DIBSECTION))
804 if (count > sizeof(BITMAP)) count = sizeof(BITMAP);
808 if (count > sizeof(DIBSECTION)) count = sizeof(DIBSECTION);
811 memcpy( buffer, &bmp->dib->dibSection, count );
816 if (count > sizeof(BITMAP)) count = sizeof(BITMAP);
817 memcpy( buffer, &bmp->bitmap, count );
823 /***********************************************************************
824 * CreateDiscardableBitmap16 (GDI.156)
826 HBITMAP16 WINAPI CreateDiscardableBitmap16( HDC16 hdc, INT16 width,
829 return CreateCompatibleBitmap16( hdc, width, height );
833 /******************************************************************************
834 * CreateDiscardableBitmap32 [GDI32.38] Creates a discardable bitmap
837 * Success: Handle to bitmap
840 HBITMAP WINAPI CreateDiscardableBitmap(
841 HDC hdc, /* [in] Handle to device context */
842 INT width, /* [in] Bitmap width */
843 INT height) /* [in] Bitmap height */
845 return CreateCompatibleBitmap( hdc, width, height );
849 /***********************************************************************
850 * GetBitmapDimensionEx16 (GDI.468)
853 * Can this call GetBitmapDimensionEx32?
855 BOOL16 WINAPI GetBitmapDimensionEx16( HBITMAP16 hbitmap, LPSIZE16 size )
857 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
858 if (!bmp) return FALSE;
859 CONV_SIZE32TO16( &bmp->size, size );
860 GDI_HEAP_UNLOCK( hbitmap );
865 /******************************************************************************
866 * GetBitmapDimensionEx32 [GDI32.144] Retrieves dimensions of a bitmap
872 BOOL WINAPI GetBitmapDimensionEx(
873 HBITMAP hbitmap, /* [in] Handle to bitmap */
874 LPSIZE size) /* [out] Address of struct receiving dimensions */
876 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
877 if (!bmp) return FALSE;
879 GDI_HEAP_UNLOCK( hbitmap );
884 /***********************************************************************
885 * GetBitmapDimension (GDI.162)
887 DWORD WINAPI GetBitmapDimension16( HBITMAP16 hbitmap )
890 if (!GetBitmapDimensionEx16( hbitmap, &size )) return 0;
891 return MAKELONG( size.cx, size.cy );
895 /***********************************************************************
896 * SetBitmapDimensionEx16 (GDI.478)
898 BOOL16 WINAPI SetBitmapDimensionEx16( HBITMAP16 hbitmap, INT16 x, INT16 y,
901 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
902 if (!bmp) return FALSE;
903 if (prevSize) CONV_SIZE32TO16( &bmp->size, prevSize );
906 GDI_HEAP_UNLOCK( hbitmap );
911 /******************************************************************************
912 * SetBitmapDimensionEx32 [GDI32.304] Assignes dimensions to a bitmap
918 BOOL WINAPI SetBitmapDimensionEx(
919 HBITMAP hbitmap, /* [in] Handle to bitmap */
920 INT x, /* [in] Bitmap width */
921 INT y, /* [in] Bitmap height */
922 LPSIZE prevSize) /* [out] Address of structure for orig dims */
924 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
925 if (!bmp) return FALSE;
926 if (prevSize) *prevSize = bmp->size;
929 GDI_HEAP_UNLOCK( hbitmap );
934 /***********************************************************************
935 * SetBitmapDimension (GDI.163)
937 DWORD WINAPI SetBitmapDimension16( HBITMAP16 hbitmap, INT16 x, INT16 y )
940 if (!SetBitmapDimensionEx16( hbitmap, x, y, &size )) return 0;
941 return MAKELONG( size.cx, size.cy );