FitMesh-like function for images?
BlitzMax Forums/BlitzMax Programming/FitMesh-like function for images?
| ||
Hi there, I'd like to load a bunch of images for my tile editor but they are all different sizes. Some are 128x128, some are 64x128 and so on. What I would love to do is scale them all to 64xAspect So that they are all the same width, and the height is scaled in proportion to the width (so that they are not warped). This will allow them to fit into the tile browser really nicely, which is limited by width but not height. I really appreciate any tips on finding the right SetScale sizes... Thanks lads! |
| ||
Something like this? (untested) local a:float=64.0/tile.width SetScale tile.width*a,tile.height/a |
| ||
hmmm nope... I wonder if it's something to do with the fact it doesn't accept scale values but something else. |
| ||
local a:float=64.0/Float(tile.width) SetScale Float(tile.width)*a,Float(tile.height)/a ? |
| ||
How about something like... (for each tile) tile.scaling=tile.width/64 - ie to make all the widths 64 tile.newwidth=tile.width/tile.scaling tile.newheight=tile.height/tile.scaling It's up to you whether you think you would need to use floats for the division - if you are using sizes in powers of 2 (ie 32,64,128,256 etc) then integers should be fine. |
| ||
Whoops sorry... Wasn't thinking. This works: SetScale 64.0/img.width,64.0/img.width |
| ||
Are you sure these work? SetScale doesn't use the actual image's scale - it starts at 1,1 |
| ||
Yes, that will pass the scale value based on the width of the tile to SetScale. |