Got it! Thank you very much, I was trying something similar, but without success:
First convert the string to bytes and then use MemoryInputStream.from_bytes () Your solution is perfect: I owe you a place in the acknowledgments of my application. Thank you! El 08/03/17 a las 12:49, Al Thomas escribió: >> ----- Original Message ----- >> From: "webie...@gmail.com" <webie...@gmail.com> >> Sent: Wednesday, 8 March 2017, 10:59 >> Subject: [Vala] Genie + Gtk: Image Base64 >> I would like to know if in Genie (with Gtk +) I can visualize an image >> that I have as a string in base64 format? >> I tried to use Base64.decode like this: >> Decoded: string = (string) Base64.decode ("iVBORw0KGgoAAAAN ...") >> But I do not know if this can be translated somehow to Gdk.Pixbuf? > > Base64.decode returns an array of unsigned char (uchar[]). This is the > same as uint8[], also known as a buffer. Instead of casting to string > assign the data to a buffer and then use MemoryInputStream: > > [indent=4] > uses Gdk > > init > data:array of uint8 = Base64.decode ("iVBORw0KGgoAAAAN ...") > var stream = new MemoryInputStream.from_data( data ) > try > var image = new Pixbuf.from_stream( stream ) > except err:Error > print( err.message ) > > You dummy data gives me: > Premature end-of-file encountered > > So it kind of works, hopefully it will with a real image. > > Al _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list