Tim Evans wrote:
Ionutz Borcoman wrote:
Hi,
I try to display and rotate images using pixbuf's. The images are
loaded using:
old_pix = gtk.gdk.pixbuf_new_from_file(name)
Later in the program I try to rotate the images. I get the
characteristics of the images using:
width = old_pix.get_width()
height = old_pix.get_height()
pixel_size = old_pix.get_rowstride() / width
data = old_pix.get_pixels()
For some images I get:
len(data) > width*height*pixel_size
If I try to rotate such images, I get errors (each column is moved
with 1 pixel up or down and I get a saw-shaped image).
In most cases, GdkPixbuf will create images such that each row starts at
a 4-byte boundary. For many images this results in padding bytes at the
end of the rows. In fact there can be any number of padding bytes, with
the actual offset from the start of one row to the start of the next
given by p.get_rowstride().
Where 'p' is a pixbuf, the number of bytes per pixel is
'p.get_n_channels()', and row 'i' starts at byte 'i * p.get_rowstride()'.
Thanks again. This was the problem and is now solved :)
--
Ionutz Borcoman
http://borco.net/
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/