0

I am trying to copy pic2 to pic1's bottom right corner (Adding a logo to a picture) Im pretty sure this is the part of the code that im having difficulty with as I cannot figure out whats next after the two getPixel statements.

for x in range(0, getWidth(pic2)):
for y in range(0, getHeight(pic2)):
   p1 = getPixel(pic1, x, y)
   p2 = getPixel(pic2, x, y)
   setPixel = p1
Tony
  • 1
  • 1

1 Answers1

0

Assuming one image is bigger than the other, you don't need to collect pixels from both picture objects, just the logo.

Seems like this might be homework so I'll just help you along.

for x in range(0, getWidth(pic2)):
   for y in range(0, getHeight(pic2)):
       p1 = getPixel(pic2, x, y)
       p1Col = getColor(p1)

Also, your nested for loops will start in the top left of the image, to apply the logo in the bottom right we use some simple math after getting the logo pixel color.

imageWidth - logoWidth + x - 1

Where the -1 is to prevent the logo exceeding the image width. Use that same style of formula for the height.

Ari
  • 745
  • 1
  • 7
  • 23