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?
So, I dunno how to make it speed up... I don't use pixel type things much.