[Mono-devel-list] In memory transform from byte[] to pixbuf

Phillip Neumann bob at sofsis.cl
Sat Oct 16 12:10:59 EDT 2004


El sáb, 16-10-2004 a las 15:57, Chris Morgan escribió:
> From monodoc 'public Pixbuf (System.IO.Stream stream)'
> 
> /* buffer containing an image */
> System.Byte[] buffer = new System.Byte[256];
> 
> /* create a memory stream to the buffer */
> System.IO.MemoryStream memorystream = new System.IO.MemoryStream(buffer);    
> 
> /* create a pixbuf from the stream as if it was a file */
> Gdk.Pixbuf pb = new Gdk.Pixbuf(memorystream);
>   
> Chris


Thank you very much...


now, i have to do the opposite...   8)
i got a PixBuf loaded from a file, and scalled. (the reason why i open
it as a pixbuf... the ScaleSimple...)

this pixbuf, i need to save it in my database. im doing this with
DbType.Binary, and try to change it to typeof(Pixbuf) but obviously the
database doesnt know how to handle that:

System.InvalidCastException: Can't cast System.MonoType into any valid
DbType.


How do i transform my Pixbuf to a byte[] ?




Thanks!

> 
> 
> On Friday 15 October 2004 8:49 pm, Phillip Neumann wrote:
> > Hello.
> >
> > I got an jpeg image from a database:  (actually they are jpg, png and/or
> > gifs)
> >
> > byte[] jpegpix
> >
> >
> > i wish to create a pixbuf from that, so i can use it in Gtk widgets
> >
> > how would i do that, without writng the bits to a file, an load it like
> > Pixbuf p = new Pixbuf ("file.jpg") ?
> >
> >
> > thanks in advance!
-- 
Phillip Neumann <bob at sofsis.cl>




More information about the Mono-devel-list mailing list