ID:169184
 
mob/verb/resize(factor as num) //scale factor, eg: 0.5 will halve the icon
var/icon/result = icon('Blank.dmi') //this will be used for the end product
for(var/py=1,py<=32,py++)
for(var/px=1,px<=32,px++) //the loops are made so that we go through every pixel in the icon
var/icon/I = icon('is.dmi') //this is the icon we scale
var/icon/pixel = icon('Blank.dmi') //this is a blank icon
var/pxd = round(px*factor) //the location of the pixel scaled
var/pyd = round(py*factor)
pixel = I.GetPixel(px,py) //using Wizkidd0123's GetPixel(), we get the current pixel we were working on and put it in to the blank icon
pixel.Shift(SOUTH,py-pyd) //move that pixel to the scaled location
pixel.Shift(WEST,px-pxd)
result.Blend(pixel,ICON_OR) //put it in to the final result
usr<<browse(result,"window=x,size=100x100") //once every pixel has been scaled, we browse the end product


This resizing function is working to a certain extent but not as smoothely as it can.

OneFishDown managed to produce this(use the up and down arrows to resize yourself):

Icon Scaling

You'll notice that in his, the quality is better than in mine.

I was wondering how to achieve that quality(but don't give any code) and how he managed to go above 100% (again no code).
it either scaled an icon horizontally or vertically, to scale the entire icon up or down, it would stretch ir horizontally, then vertically.

suppose you wanted to shrink an icon to half its width. the scaling factor would be 0.5. you'd want to take every other column of pixels, so you take the first column, then the column 2 pixels to the right, and the column 2 more to the right.

what if the scaling factor is 1.0? you'd take every column. so you'd take the first column, and the column one pixel to the right, and the column one more pixel to the right.

1 / 0.5 = 2
1 / 1.0 = 1

1 / scaling factor = increment

in those examples the increment comes out to integer values. the increment could be a decimal, but when you go to take a column/row of pixels you'd just have to round it.

to enlarge the icon, it uses the same thing, the scaling factor is just greater than one.

suppose the scaling factor is 2.0.

1 / 2.0 = 0.5

the increment is one half, so you'd take every column twice. the only problem here is that it will go over the bounds of one icon, so you have to use several icons.
In response to OneFishDown
Yeah thanks OFD but I figured this out a long time ago =P