ID:146307
 
Code:
obj/proc/Resize(factor as num)
var/icon/result = icon('Blank.dmi')
for(var/py=1,py<=32,py++)
for(var/px=1,px<=32,px++) //loop through every pixel
var/icon/I = icon(src.icon,src.icon_state)
var/icon/pixel = icon('Blank.dmi')
var/pxd = round(px*factor) //this is the x loc of where the pixel should be. But since we don't know the RGB of the pixel, we can't DrawBox().
var/pyd = round(py*factor) //This is the y loc of where the pixel should be.
pixel = I.GetPixel(px,py) //use Wizkidd0123's GetPixel to get the current pixel we were working on
if(pxd<1) pxd=1
if(pyd<1) pyd=1
pixel.Shift(SOUTH,py-pyd,1) //shift the pixel to where we needed it to be
pixel.Shift(WEST,px-pxd,1)
result.Blend(pixel,ICON_OVERLAY) //add the current, resized, pixel to the final result
src.icon = result
return src


Problem description:

The purpose of the above is to shrink the icon of an obj. So, for example, make an icon 50% of what it used to be. It works I guess but it works really really slowly. Can someone help me speed it up?
I can't say for sure, but with a for() proc, it does one, then it goes to the next one, and so on. If it were doing the all at the same time, then the SERVER would get laggy while it works... but it would go fast.

So, I dunno how to make it speed up... I don't use pixel type things much.
In response to Hiddeknight
I don't think you can access every single pixel at once.
Bump, I would really appreciate help on this. YMIHere suggested that in order to speed up the proc in the long term, I could add the icons to the cache. How would I do this and would it be worth it considering that the thing this is being used for(Showtext) asks to resize more than 120 objects.