On Fri, 2004-10-08 at 10:37 +0159, Matthias Teege wrote:
> I try to read an image from a database but I've problems with the
> type. I don't have problems to create a pixbuf from file but if I try
> 
> pixbuffer = dbres[5]   # a postgresql bytea field
> 
> I get TypeError: pixbuf should be a GdkPixbuf or None.
> 
> I understand the error but I don't know how to solve this problem. How
> do I assign an image from a database to a pixbuf?


Depends - what is stored in the database? If the data in the database is
PNG/GIF/JPEG encoded data, you need to decode it to a pixbuf.

If you store a "raw" pixbuf in the database, you must serialize the
pixbuf (convert it to a byte-stream) before storing it in the database,
and deserialize when fetching it. This can be done with
gdk_pixdata_serialize() (don't know if it's available in pygtk), or I
believe you can also use Python's pickle system for this.

Never tried any of this in practice, tough - anyone else care to
comment?

-- 
Erik Grinaker <[EMAIL PROTECTED]>

"We act as though comfort and luxury were the chief requirements of
life, when all that we need to make us happy is something to be
enthusiastic about."
                                                  -- Albert Einstein

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to