1. Resize Routine
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Oct 14, 1997
- 588 views
To Einar Mogen.. Here's the resize routine.. I posted it on the list-serv cause it is small and other poeple might also find this usefull... I isn't like a normal resizer: Look at this example: We have 9 lines and want to resize to 3.. line <-> normal return <-> this routine returns 1st 1st -- 2nd -- 1st 3rd -- -- 4th 2nd -- 5th -- 2nd 6th -- -- 7th 3rd -- 8th -- 3rd 9th -- -- See how this routine centers it. (Looks a lot nicer) Here is the routine: -- Warning!! This isn't totally speed optimized.. -- If you need to this is real time, use look-up-tables!! global function resize (sequence image, sequence newdim ) sequence ret atom yi, xi, stepx, stepy, beginx stepx = length(image[1]) / newdim[1] stepy = length(image) / newdim[2] beginx = 1 + ((length(image[1]) - ((stepx * (newdim[1]-1))+1))/2) ret = repeat ( repeat ( 0 , newdim[1] ) , newdim[2] ) yi = 1 + ((length(image) - ((stepy * (newdim[2]-1))+1))/2) for y = 1 to length(ret) do xi = beginx for x = 1 to length(ret[1]) do ret[y][x] = image[yi][xi] xi = xi + stepx end for yi = yi + stepy end for return ret end function -- This routine will crash if you give an image sequence with different -- length images ( i.e. { {1,1,1} , {1} , {1,1,1,1,1} } ) -- But none of the normal Euphoria routine will create such a sequence. Ralf Nieuwenhuijsen nieuwen at xs4all.nl