tags:

views:

39

answers:

1

srcImage.paste(letters['H'], (10,15))

The above code will paste the letter H on the image (srcimage). letters is dict which contains the font images.. I cannot use paste in my assignment but i can use getpixel, load, putpixel, and save. I tried this but this is giving error:

srcImage.putpixel((10,15),letters['H'])

Error is:

File "C:\Users\Naveen\Desktop\a1\a1_template.py", line 23, in doLOLImage srcImage.putpixel((10,15),letters['H']) File "C:\Python26\lib\site-packages\PIL\Image.py", line 1267, in putpixel
return self.im.putpixel(xy, value)
SystemError: new style getargs format but argument is not a tuple

can you please provide me how to do this function of paste just using getpixel, putpixel, load, and save.

A: 

I'm not familiar with PIL and the details of your assignment, so this will be pseudocode:

for every pixel in letter['H']:
    putpixel (at position + position in letter['H'])

Essentially, get every pixel and its position in the letter, and put that pixel into the image at the position you're currently at plus the position of the pixel in the letter. (thinking from the top left) – in other words, copy the image (letter['H']) pixel by pixel.

stefano palazzo