#include once "window9.bi"

function Image_Height(ByVal hBitmap As HBITMAP) as Long Export
	Dim size As BITMAP
	getobject(hBitmap,sizeof(BITMAP),@size)
	Return size.bmHeight
End Function

function Image_Width(ByVal hBitmap As HBITMAP) as Long Export
	Dim size As BITMAP
	getobject(hBitmap,sizeof(BITMAP),@size)
	Return size.bmWidth
End Function

function Resize_Image(ByVal hBitmap As HBITMAP, ByVal w As Integer, ByVal h As Integer) as HBITMAP Export
	Dim As HBITMAP hbitmap2
	Dim As HDC hdc,hdc2
	Dim size As BITMAP
	getobject(hBitmap,sizeof(BITMAP),@size)
	hbitmap2 = CreateBitmap(w ,h,1,32,0)
	hdc = CreateCompatibleDC(0)
	hdc2 = CreateCompatibleDC(0)
	SelectObject(hdc,hbitmap)
	SelectObject(hdc2,hbitmap2)
	SetStretchBltMode(hDC2, STRETCH_HALFTONE)
	StretchBlt(hdc2,0,0,w,h,hdc,0,0,size.bmWidth,size.bmHeight,SRCCOPY)
	DeleteObject(hbitmap)
	SelectObject(hdc,hbitmap2)
	BitBlt(hdc,0,0,w,h,hdc2,0,0,SRCCOPY)
	DeleteDC(hdc)
	DeleteDC(hdc2)
	Return hBitmap2
End Function

Function Copy_Image(ByVal hBitmap As hBitmap) as hBitmap Export
	Dim hBitmap1 As HBITMAP
	hBitmap1=CopyImage(hBitmap,IMAGE_BITMAP,0,0,LR_COPYRETURNORG)
	Return hBitmap1
End Function
