#Include ONCE "window9.bi"

function IMAGE_HEIGHT alias "image_height" (ByVal hBitmap As HBITMAP) as Integer Export
  Dim size As BITMAP
  getobject(hBitmap,sizeof(BITMAP),@size)
  Return size.bmHeight
End Function

function IMAGE_width alias "image_width" (ByVal hBitmap As HBITMAP) as Integer Export
  Dim size As BITMAP
  getobject(hBitmap,sizeof(BITMAP),@size)
  Return size.bmWidth
End Function

function Resize_image alias "Resize_image" (ByVal hBitmap As HBITMAP,ByVal w As Integer, ByVal h As Integer,ByVal TIP As Integer=IMAGE_BITMAP) 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 alias "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
