@CumQuaT Thanks, but I need to generate them on-the-fly.
@SvenB Thanks that looks good! Can I just do this:
get image 1,0,0,origX,origY
ik convert to render target 1
ik resize image 1,newX,newY,1
paste image 1,0,0
delete image 1
Or do I have to clean up anything after converting it to a render target? (It does work fine as-is, but I don't write anything 3D or gaming so I'm a bit of a novice in this area)
It's a bit excessive to use a 164kb plugin for a single command though, I'm really trying to limit the `bloat` of using lots of plugins. Would the source for the resize algorithm be fairly simple for me to convert to db?
Edit: This is what I have so far, but it doesn't seem to be very effective.
for x=0 to 100 step 8
for y=0 to 100 step 8
box x,y,x+5,y+5
next y
next x
scale(100,100,60,60)
wait key
end
function scale(xOrig,yOrig,xDest,yDest)
local floorX as float
local ceilX as float
local floorY as float
local ceilY as float
local scaleX as float
local scaleY as float
local fracX as float
local fracY as float
scaleX=xOrig/(xDest*1.0) `Scaling factor between original & new image size
scaleY=yOrig/(yDest*1.0)
for x=0 to xDest
floorX=x*scaleX `X coordinate from original image
ceilX=min(floorX+1.0,xOrig) `Keep within original image boundaries
for y=0 to yDest
floorY=y*scaleY `and Y from original image
ceilY=min(floorY+1.0,yOrig)
p1=point(floorX,floorY) `Get 4 pixels from original image
p2=point(ceilX,floorY)
p3=point(floorX,ceilY)
p4=point(ceilX,ceilY)
fracX=floorX-int(floorX) `Weighting of floor/ceiling pixels
fracY=floorY-int(floorY)
r1=(rgbr(p1)*(1.0-fracX))+(rgbr(p2)*fracX) `Interpolated pixel 1st row
r2=(rgbr(p3)*(1.0-fracX))+(rgbr(p4)*fracX) `and 2nd
r=(r2*(1.0-fracY))+(r1*fracY) `Combined rows
g1=(rgbg(p1)*(1.0-fracX))+(rgbg(p2)*fracX)
g2=(rgbg(p3)*(1.0-fracX))+(rgbg(p4)*fracX)
g=(g2*(1.0-fracY))+(g1*fracY)
b1=(rgbb(p1)*(1.0-fracX))+(rgbb(p2)*fracX)
b2=(rgbb(p3)*(1.0-fracX))+(rgbb(p4)*fracX)
b=(b2*(1.0-fracY))+(b1*fracY)
ink rgb(r,g,b),0 `Draw interpolated pixel
dot x+200,y
ink p1,0 `Normal for comparison
dot x+400,y
next y
next x
endfunction