Drawing a specific part of an image
BlitzMax Forums/BlitzMax Beginners Area/Drawing a specific part of an image
| ||
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. :) |
| ||
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) |
| ||
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. :) |
| ||
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. |
| ||
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. |
| ||
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. |
| ||
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? |
| ||
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. |
| ||
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. ;) |
| ||
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? |
| ||
this might help |