Drawing a specific part of an image

BlitzMax Forums/BlitzMax Beginners Area/Drawing a specific part of an image

byo(Posted 2008) [#1]
Hi.

I think I need some help here. :)
I'm trying to convert an old Blitzbasic demo I made and I had this command I used:

DrawBlockRect

I have a really large image (2400x2760) and I need to draw a 640x480 rect from this image from any position to simulate map scrolling.

I know there is a DrawImageRect command but I can't specify the starting x and y point of the source image I want to draw.

Is there a better way using TImage?

Thanks in advance. :)


Jesse(Posted 2008) [#2]
I know there is a DrawImageRect command but I can't specify the starting x and y point of the source image I want to draw.

That instruction stretches or shrinks an image. What you need is completely different.

first you need to extract the complete pixmap from the original image:
pixmap:tpixmap = lockimage(image)

extract the wanted pixmap from the original pixmap.
extractedpixmap:tpixmap = pixmap.window(x,y,width,height)

then convert that new pixmap back to an image:
extractedimage:Timage = loadimage(extractedpixmap)



byo(Posted 2008) [#3]
Hi, Jesse.

Thanks for the reply. I'll try that. I'll have to learn how to use TPixmap.

But after some tries I could make DrawImageRect work the way I needed. I informed the X and Y position of the drawing and the TImage was correctly drawn from any 640x480 rectangle.

Thanks again. One more thing to study. :)


Grey Alien(Posted 2008) [#4]
I have a really large image (2400x2760)
Lots of video cards will not handle that. I deliberately don't use higher that 1024x1024 textures. Ideally you should make a tilemap instead.


byo(Posted 2008) [#5]
Hi, Grey Alien.

Do you mean dividing the the image into smaller pieces and then putting them side by side?

Hmm... I wasn't aware of limitations like this. Good to know. Thanks.


Grey Alien(Posted 2008) [#6]
Do you mean dividing the the image into smaller pieces and then putting them side by side?
Yes. You'd have found out the problem as soon as you tested it on someone else's lower spec PC.


ImaginaryHuman(Posted 2008) [#7]
What do you guys think as to the feasibility of releasing a version of a game with `fixes` like this targetted at lower-to-mid-range PC's, and then another version with extra capabilities/use of bigger textures/etc, for higher end pc's? I guess kinda like a `regular` version and a `pro` version?


TaskMaster(Posted 2008) [#8]
Wouldn't it be better to come up with a system that could determine the capabilities of the PC and do it whichever way was possible on the machine.


MGE(Posted 2008) [#9]
I've had this conversation with several developers and the answer is always the same.

"Pick a target spec and write the best game you can targeted to that spec."

At some point you just have to write the game and go with it. ;)

re: scrolling

Just use 512x512 or 1kx1k and draw each section side by side to scroll the entire bit map world. But you should also keep in mind video ram. 32-64mb should be a target for typical lower end systems.

And also, lower the res of your game and you can create a larger scrolling world with lower res textures. ;)


byo(Posted 2008) [#10]
Nice tips and advices. Thanks, guys.

MGE: I want to make a game (possibly a demo) with a map that has much detail and the resolution I'm using is 640x480. It's working fine so far and I'll post something once I have things working as expected.

I'm still crawling through the Blitzmax help and I'm not finding it an easy task. Any recommendations?


tonyg(Posted 2008) [#11]
this might help