[Vala] sqlite blob to GTK image



Hello,

I'm not very experienced with Vala or GTK and I was trying to display a
jpg picture from a sqlite db... thanks the the Internet I was able to
find some code from different sources to get it to work:

                unowned uint8[] data = (uint8[]) stmt.column_blob(9);
                data.length = stmt.column_bytes(9);
                var data2 = data;
                FileUtils.set_data("temp.jpg", data2);
                Pixbuf pixbuf = new
Pixbuf.from_file_at_scale("temp.jpg",320,240,true);
                var image1 = builder.get_object ("image1") as Gtk.Image;
                image1.set_from_pixbuf(pixbuf);

However I'm not happy to have to save the data to a file... to load it
again to display it. (I consier this a workaround)

I'm sure there is a more elegant way doing this, could someone please
give me a hint or point me in the right direction on how to do that.

Thanks,
Markus

PS: this is for a ham radio exam study program:
https://github.com/alpharesearch/HEH2011 that is still very alpha



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]