Need a test with this...

BlitzMax Forums/BlitzMax Beginners Area/Need a test with this...

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi !
with Dreamora function... the image auto scale to the drawrect size ? How to not deform the image ?
Thanks
(note i invert some params into the dreamora function declaration)



Strict 

Graphics 800,600

Global hImage:Timage = LoadImage ("griffe.png")
SetImageHandle hImage, 0,0

Rem
	image: handle of the image you want to draw
	x , y: Position at which you want to draw the imagerect
	w,h: width and height of the imagerect you want to draw
	l,t: top left position on the image you want to start drawing (in pixels)
	dw,dh: Drawing height and width of the image part you want do draw.
End Rem

Function drawimagearea (image:TImage, x#, y#, w#, h#, l#, t#,dw#,dh#,  frame:Int=0)
	Local origin_x#,origin_y#
	GetOrigin (origin_x,origin_y)
	Local l1#	= l + w
	Local h1#	= t + h
	Local x0#=-image.handle_x,x1#=x0+w
	Local y0#=-image.handle_y,y1#=y0+h

	If l1 > image.width
		x1 = x0 + w + image.width - l1
		l1 = image.width
	EndIf 
	If h1 > image.height
		y1 = y0 + h + image.height - h1
		h1 = image.height
	EndIf

	If TGLImageFrame (image.frame(frame))
		Local frame:TGLImageFrame 	= TGLImageFrame (image.frame(frame))
								
		frame.u0 = l / image.width
		frame.v0 = t / image.height
		frame.u1 = (l1) / image.width
		frame.v1 = (h1) / image.height
		frame.Draw x0,y0,x0+dw,y0+dh,x+origin_x,y+origin_y
		
		frame.u0	= 0
		frame.v0	= 0
		frame.u1	= 1
		frame.v1	= 1
	Else
		Local frame:TD3D7ImageFrame	= TD3D7ImageFrame(image.frame(frame))
		frame.setUV (l/image.width, t/image.height, (l1) / image.width, (h1) / image.height)
		frame.Draw x0,y0,x0+dw,y0+dh,x+origin_x,y+origin_y
		frame.setUV (0,0,1,1)
	EndIf
	
End Function

Rem
	image: handle of the image you want to draw
	x , y: Position at which you want to draw the imagerect
	w,h: width and height of the imagerect you want to draw
	l,t: top left position on the image you want to start drawing (in pixels)
	dw,dh: Drawing height and width of the image part you want do draw.
End Rem


While Not KeyDown (KEY_ESCAPE)

	Cls
	
	SetColor  255, 255,255
	
	DrawRect 300,100,200,150
	DrawImage hImage, 250,100
	
	DrawRect 300,300,200,150
	DrawImagearea hImage, 300,300,200,150,50,0,200, 250
	Flip

Wend