Hello,
I think I found a bug in Image.putpixel() for 16bit images. It writes
the given x coordinates in bytes, not pixels. i.e. x==0 is lower byte of
pixel 0, x==1 addresses upper byte of pixel zero. y indices are ok.
The following code shows the problem (using PIL 1.1.6):
im = Image.open("text16black.tif")
print im.format, im.size, im.mode
dx = size[0]
for i in range(0, dx):
# reopening to restore data every time
im = Image.open("test16black.tif")
im.putpixel((i, 0), 2)
print [im.getpixel((x, 0)) for x in range(0, dx)]
output (for completely black test image):
TIFF (9, 15) I;16
[2, 0, 0, 0, 0, 0, 0, 0, 0]
[512, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 2, 0, 0, 0, 0, 0, 0, 0]
[0, 512, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 2, 0, 0, 0, 0, 0, 0]
[0, 0, 512, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 2, 0, 0, 0, 0, 0]
[0, 0, 0, 512, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 2, 0, 0, 0, 0]
Because of range checking based on the pixels I cannot even work around
supplying the data in an appropriate format. There is no way to address
the right half of the line.
BTW the same problem occurs in putdata().
Thanks for your comments,
Tim
_______________________________________________
Image-SIG maillist - Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig