DrawImageInsideRect?

BlitzMax Forums/BlitzMax Beginners Area/DrawImageInsideRect?

(tu) ENAY(Posted 2005) [#1]
Is there any sort of command that is like DrawImageRect but allows you to specify the start draw as well as the size instead of only being able to start from 0,0?

Something like:-

DrawImageRect(image:TImage, X, Y, StartX, StartY, EndX, EndY, frame)


Same sort of theory when you're setting texture coordinates in 3D from a texture.


Dreamora(Posted 2005) [#2]
If you use OO you can access the TGLImageFrame structures "Draw" which allowes that ...

=> graphic.frames[frame].draw ( ... )


Perturbatio(Posted 2005) [#3]
I'm sure you could rig something up using SetViewPort.


(tu) ENAY(Posted 2005) [#4]
Yikes that sounds quite complex. Do you have any code example? :)

The reason is that I'd like to be able to later use the same numbers as 3D texture coordinates with UV mapping. Instead of splitting up my images into separate chunks/anim image.


Eikon(Posted 2005) [#5]
Here you go
Function DrawImageRect2(img:TImage, x#, y#, rx#, ry#, rw#, rh#)
	SetViewport x, y, rw, rh
	DrawImage img, x - rx, x - ry
	
	SetViewport 0, 0, GFX_WIDTH, GFX_HEIGHT
End Function



(tu) ENAY(Posted 2005) [#6]
Eikon, you are my hero.

Would using SetViewPort be suitable for realtime use?


Eikon(Posted 2005) [#7]
Thanks, ENAY :)

I did some testing and B2D's DrawImageRect took an average of around 15ms with a test image, while BMax was around 10ms with the new DrawImageRect2. I don't think you'll have any speed problems.