function math.round(x) return math.floor(x+0.5) end newwidth=math.round(width*zoom) newheight=math.round(height*zoom) newpixels = {} for y=0,newheight-1 do for x=0,newwidth-1 do newpixels[y*newwidth+x+1] = pixels[math.floor(x/zoom)+math.floor(y/zoom)*width+1] end end width=newwidth height=newheight pixels=newpixels newpixels=nil