I am trying to combine 2 images (ex. both 10x10 pixels) so that if all the pixels in image 1 are all "1" and in image 2 all pixels are "2", the resultant image is: (The resultant image needs to be 40x40 pixels)
1111111111222222222211111111112222222222 1111111111222222222211111111112222222222 ...
Therfore I need to take the first row (10 pixels wide) from Image 1 & then the first row (10 pixels wide) from Image 2 and combine them into one row and repeat for second, third rows... until all pixels have been used.
So far I have got to the stage where I can print the first row of both images together but I am having trouble incrementing the columns (y) to get the rest of the rows and add them.
Thanks for the help.
def interweavePictures():
x1 = 0
x2 = 100
for x in range(x1, x2):
xA = x
y1 = 0
y2 = 1
for y in range(y1, y2):
pixelA20 = getPixel(imageA, x, y)
pixelB20 = getPixel(imageB, x, y)
colorA20 = getColor(pixelA20)
colorB20 = getColor(pixelB20)
setColor(getPixel(canvas, xA, y), colorA20)
setColor(getPixel(canvas, x+100, y), colorB20)
y1 += 1
y2 += 1
xA += 200
repaint(canvas)
imageA = makePicture(pickAFile())
widthA = getWidth(imageA)
heightA = getHeight(imageA)
show(imageA)
imageB = makePicture(pickAFile())
widthB = getWidth(imageB)
heightB = getHeight(imageB)
show(imageB)
canvas = makeEmptyPicture(400, 400)
show(canvas)
interweavePictures()
Aucun commentaire:
Enregistrer un commentaire