Drawing Part of an Image

BlitzMax Forums/BlitzMax Beginners Area/Drawing Part of an Image

z80jim(Posted 2005) [#1]
I'm new to all the Blitz programming and am just starting to learn Blitz. So far I think it is great.

My question is if there is any way to draw only a portion of an image? It looks like DrawImage will only draw the whole image that was loaded.

Thanks,
Jim


GfK(Posted 2005) [#2]
Assuming this command still exists in Blitzmax (haven't got it on this PC so can't check but I'm sure I remember seeing it in the documentation):

DrawImageRect image,x,y,rect_x,rect_y,rect_width,rect_height,[frame]



ImaginaryHuman(Posted 2005) [#3]
This command does exist. From what I can tell it draws an image within a rectangular window in the backbuffer. I presume if you use a handle offset you could effectively cause a given section of an image to be drawn. I am guessing this command sets up a `scissor` window so that only pixels within the window area are drawn?

You could use this to store several frames of an animation in a single `Image` and only draw a given frame - saves a lot of video memory. I've no idea whether this works with rotation and scaling or not. And if you wanted to rotate an image taken from part of a larger image, and draw the whole thing, I am thinking the corners would get clipped?


Warren(Posted 2005) [#4]
Noel Cower posted a routine to the code archives that does this. I don't know why BlitzMax doesn't have a native function for this, but...


z80jim(Posted 2005) [#5]
Thanks for the quick response. For one particular tile animation I need to draw my images from a larger image so that it can scroll.

Looks like Noel Cower module will do the trick.

Thanks
Jim


tonyg(Posted 2005) [#6]
Can you use PixmapWindow?


Bot Builder(Posted 2005) [#7]
You could just use SetViewport and set the viewport to the position you are drawing the image and then set it to the width/height of the image you want to draw. Just remember to set it back to the full screen after. Hmm. This could actually be pretty effective way of drawing say, progress bars.


Clyde(Posted 2005) [#8]
Would this also apply to the old command CopyRect?

Thanks,
THUMBZ