[Gtk-sharp-list] System.Drawing.Image from Gtk.Image
Arx Henrique
arxcruz at gmail.com
Sat Dec 24 14:19:55 EST 2005
well, i try this code, but always throw a exception telling that
cannot know the image format... :(
On 12/23/05, Michael Hutchinson <m.j.hutchinson at gmail.com> wrote:
> Hi,
>
> > Is possible i get a System.Drawing.Image and transform to Gtk.Image?
> >
> > if yes, anyone have a sample? or can tell me how?
>
> Gtk.Image can load Gdk.Pixbufs. Pixbufs can load from common image
> encodings. So use the following function to get your pixbuf by saving
> the System.Drawing.Image into memory then loading into the pixbuf
> (originally posted by Eric Butler in May:
> http://lists.ximian.com/pipermail/gtk-sharp-list/2005-May/005880.html)
>
> private Gdk.Pixbuf ImageToPixbuf (System.Drawing.Image image)
> {
> using (System.IO.MemoryStream stream = new System.IO.MemoryStream ()) {
> image.Save (stream, System.Drawing.Imaging.ImageFormat.Bmp);
> stream.Position = 0;
> return new Gdk.Pixbuf (stream);
> }
> }
>
>
> Michael
>
--
"A fé remove montanhas, mas eu prefiro a dinamite"
More information about the Gtk-sharp-list
mailing list