Date: 02-16-2022
Return to Index
created by gbSnippets
hBmp = LoadImage(GetModuleHandle(""), "cowgirl", %IMAGE_BITMAP, 0, 0, %LR_DEFAULTCOLOR)
#1
hStatus = GdipCreateBitmapFromResource(hInstance, StrPTR(strResourceName), pImage)
w = GdipGetImageWidth(pImage, dwImageWidth)
h = GdipGetImageHeight(pImage, dwImageHeight)
#2
Local hResInfo as DWord, hResData as DWord, w as Long, h as Long, iPointer as DWord
hResInfo = FindResource GetModuleHandle(""), "cowgirl", %RT_BITMAP
hResData = LoadResource GetModuleHandle(""), hResInfo
iPointer = LockResource hResData
Get #1, iPointer+19, w
Get #1, iPointer+23, h
#3
Local hBMP as DWord, w as Long, h as Long
Graphic Bitmap Load "update", 0, 0 to hBMP
Graphic Attach hBMP, 0
Graphic Get Client To w,h
MsgBox Str$(w) + Str$(h)
#4
Local hbmp As DWord, w As Long, h As Long, tSize As SizeL
hBmp = LoadImage(GetModuleHandle(""), "cowgirl", %IMAGE_BITMAP, 0, 0, %LR_DEFAULTCOLOR)
GetBitMapDimensionEx(hBMP, tSizeL)
MsgBox Str$(tSize.cx) + Str$(tSize.cy)
#5
Local hbmp As DWord, w As Long, h As Long, Bmp As Bitmap
hBmp = LoadImage(GetModuleHandle(""), "cowgirl", %IMAGE_BITMAP, 0, 0, %LR_DEFAULTCOLOR)
GetObject hBmp, SizeOf(Bmp), Bmp
MsgBox "BitMap width: "+Str$(Bmp.bmWidth)+$CRLF+ _
"BitMap height: "+Str$(Bmp.bmHeight)
End If
End Function
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
#Resource "gbSnippets.pbr"
Global hDlg as DWord
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 50,10,100,20
Control Add Graphic, hDlg, 200, "", 50,40,150,150
Graphic Attach hDlg, 200
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
Local hbmp As DWord, w As Long, h As Long, Bmp As Bitmap
hBmp = LoadImage(GetModuleHandle(""), "cowgirl", %IMAGE_BITMAP, 0, 0, %LR_DEFAULTCOLOR)
GetObject hBmp, SizeOf(Bmp), Bmp
MsgBox "BitMap width: "+Str$(Bmp.bmWidth)+$CRLF+ _
"BitMap height: "+Str$(Bmp.bmHeight)
End If
End Function
'gbs_00422
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm