Re: [Vala] sqlite blob to GTK image
- From: Iñigo Serna <inigoserna gmail com>
- To: vala-list gnome org
- Subject: Re: [Vala] sqlite blob to GTK image
- Date: Sun, 17 Jul 2011 10:21:27 +0200
Hi,
On 17 July 2011 03:11, Markus Schulz <schulz alpharesearch de> wrote:
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
I had the same issue a couple of weeks ago.
Here is the code I'm using:
Gdk.Pixbuf pb;
#if (GDKPIXBUF_HIGHERTHAN_212)
var imgstream = new
GLib.MemoryInputStream.from_data(imgdata, null);
pb = new Gdk.Pixbuf.from_stream(imgstream);
#else
FileUtils.set_data(TEMP_IMG, imgdata);
pb = new Gdk.Pixbuf.from_file(TEMP_IMG);
File.new_for_path(TEMP_IMG).delete();
#endif
Hope it helps,
Iñigo Serna
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]