I expected the image retrieved by the get image command to have fixed dimensions. In fact it doesn't as the following demo shows. In some situations the image is stretched (as expected), in others it isn't. Also, the behaviour differs between my Vista and XP machines as follows:
Vista PC (nVidia GFX card)
--------------------------
saved version is stretched to next powers of 2 (expected behaviour)
image width() and image height() return unstretched values (not expected)
sprite uses unstretched version of image (not expected)
XP Laptop (ATI integrated GFX card)
-----------------------------------
saved version is stretched to next powers of 2 (expected behaviour)
image width() and image height() return unstretched values (not expected)
sprite uses stretched version of image (not sure whether this is expected!!!)
Here's the code: (image attached - but I guess any image might do)
set display mode 640, 480, 32
load bitmap "three dots.png", 1 ` this bitmap is 1000 x 400
copy bitmap 1, 0, 0, 1000, 400, 0, 0, 0, 640, 480 ` stretches and shrinks the bitmap to a section of bitmap 0
set current bitmap 0
get image 1, 0, 0, 640, 480 ` gets the same bit of bitmap 0 as an image with size 640x480 but should stretch it to 1024 x 512
`get image 1, 0, 0, 640, 480, 0 ` should be same as above (default)
`get image 1, 0, 0, 640, 480, 1 ` should create an image of size 640 x 480
` in fact none of the above three options works completely correctly on either my XP or my Vista machine
cls 0 `clear bitmap 0 to black
if file exist("temp.png") then delete file "temp.png"
save image "temp.png", 1 ` saves the same image - it should be 1024 x 512 on the disk using the first two options
draw sprites first
sprite 1, 0, 0, 1 ` this should not fit in the screen with the first two options - but does on Vista
do
text 20, 20, "image dimensions: "+str$(image width(1))+" x "+str$(image height(1)) ` this should always be the same as the saved image - but isn't
loop
Edit Addendum: If the get image texture flag is set to 1 then things work correctly on my Vista machine, but if set to 0 then the behaviour is as described above, i.e. inconsistent. I'll add the results for my XP laptop later.
Edit2 Well. The results for my XP laptop are very weird - each of the following options fails to work consistently:
get image 1, 0, 0, sw, sh
get image 1, 0, 0, sw, sh, 0
get image 1, 0, 0, sw, sh, 1 (see Edit4 below)
In the first two the sprite dimensions are scaled to the next powers of 2 as are those of the saved image. But image width(1) and image height(1) both report the unscaled dimensions. My understanding is that they should all be scaled.
In the third, the sprite is scaled but the reported dimensions and the saved copy are all unscaled. My understanding is that they should all be unscaled.
Edit3 Changed and simplified the code snippet to focus on the relevant parts. Also changed the source image file.
Edit4 The third option of the revised snippet DOES work correctly on both XP and Vista (not sure why I thought it didn't
). It's the first two that give confused results.