Weird scaleimage error

Blitz3D Forums/Blitz3D Beginners Area/Weird scaleimage error

chwaga(Posted 2008) [#1]
I keep getting a MAV on this:
ScaleImage b\img, GraphicsWidth()/1680, GraphicsHeight()/1050

b\img IS an image loaded correctly and draws correctly if I don't use the ScaleImage line. It also doesn't work on:
ScaleImage b\img, 1024/1680, 768/1050

But for some STRANGE reason, this works:
ScaleImage b\img, 0.609, 0.713

????


GfK(Posted 2008) [#2]
Your X and Y parameters in ScaleImage are probably returning zero, since you're dividing one integer by another (which will also return an integer, when you need a float). Make at least one side a float and that should sort it:
ScaleImage b\img, GraphicsWidth()/1680.0, GraphicsHeight()/1050.0



chwaga(Posted 2008) [#3]
Ok, that works, thanks.

Is this because the floats are flooring to zero when a decimal is returned automatically?


GfK(Posted 2008) [#4]
Is this because the floats are flooring to zero when a decimal is returned automatically?
If you divide one integer by another, you get an integer as the result. With what you're doing there's a strong possibility that'll return zero a lot (probably more often than not), or 1, or 2, depending on what the resolution is.

If you divide an integer by a float, or a float by an integer, then you get a float back, which is what ScaleImage really requires.

If you try to scale an image by 0 on either axis, then that's when you'll get errors since you're creating an image which is 0 pixels wide/high.