Cool!
You can also use the raster commands for scaling, flipping and 90 degree rotations. The problem is that 'draw hraster' and 'draw vraster' were created with nothing but raycasting and mode7 in mind (they draw textured horizontal and vertical lines). They treat the alpha channel as "fog density". But as long as you don't need to do colorized/additive drawing and the image data only contains pixels with full opacity or full transparency it works.
Full support for drawing transformed images (scaling + rotating) is at the absolute top of my todo list. It'll run faster than this solution.
You can also use the raster commands for scaling, flipping and 90 degree rotations. The problem is that 'draw hraster' and 'draw vraster' were created with nothing but raycasting and mode7 in mind (they draw textured horizontal and vertical lines). They treat the alpha channel as "fog density". But as long as you don't need to do colorized/additive drawing and the image data only contains pixels with full opacity or full transparency it works.
Code:
#win32
set window "Raster scaling", 640, 480
set redraw off
img = loadimage("weird.png")
a = 0 ' angle for sin scale effect.
while not keydown(KEY_ESCAPE)
a = (a + 0.01)%(PI*2)
' calculate width and height.
w = (0.25 + 0.75*(1.0 + sin(a)))*width(img)
h = (0.25 + 0.75*(1.0 + sin(a)))*height(img)
set color 0, 0, 0
cls
' draw centered.
DrawImageScaled(img, (width(primary) - w)/2, (height(primary) - h)/2, w, h)
DrawImageRotated90(img, 0, 0)
redraw
fwait 60
wend
function DrawImageScaled(img, x, y, w, h)
if w <= 0 or h <= 0 return
set color 255, 255, 255, 0
du = 1/w
u = 0
for x = x to x + w - 1
draw vraster img, x, y, y + h - 1, u, 0, u, 1
u = u + du
next
endfunc
function DrawImageRotated90(img, x, y)
set color 255, 255, 255, 0
dv = 1/height(img)
v = 1
for x = x to x + height(img) - 1
draw vraster img, x, y, y + width(img) - 1, 0, v, 1, v
v = v - dv
next
endfunc
Full support for drawing transformed images (scaling + rotating) is at the absolute top of my todo list. It'll run faster than this solution.