Pretty new to programming and wasn't able to find any ways of doing this without the use of PIL etc, if I am wrong please point me in the right direction!
I need to modify the following code so that it will copy the image to TGT at a size chosen by the scale input. At this stage I have gotten it so that the picture copies onto a canvas which size is determined by the scale input but cannot workout how to make the image itself scale.
Any help is greatly appreciated.
def driver():
pic = makePicture(pickAFile())
repaint(pic)
modifiedPic = scale(pic,2.0)
repaint(modifiedPic)
def scale(srcPic,scale):
xStart = 0
yStart = 0
xEnd = getWidth(srcPic)
yEnd = getHeight(srcPic)
width = getWidth(srcPic)
height = getHeight(srcPic)
tgt = makeEmptyPicture(width*int(scale),height*int(scale))
for x in range(0,width):
for y in range(0,height):
pxSrc=getPixel(srcPic,x,y)
pxTgt=getPixel(tgt,x,y)
setColor(pxTgt,getColor(pxSrc))
srcWidth = xEnd -xStart
srcHeight = yEnd - yStart
tgtWidth = int(srcWidth*scale)
tgtHeight = int(srcHeight*scale)
for y in range(0,tgtHeight):
for x in range(0,tgtWidth):
pxSrc=getPixel(srcPic,int(x/scale)+xStart,int(y/scale)+yStart)
pxTgt=getPixel(tgt,int(xStart*scale),int(yStart*scale))
setColor(pxTgt,getColor(pxSrc))
return tgt