On Thursday, 3 August 2017 at 13:12:03 UTC, Mengu wrote:
On Thursday, 3 August 2017 at 03:59:40 UTC, Johnson Jones wrote:
How can be use gtkD to load images, I assume through
gdkpixbuf? While I am getting errors loading images through
glade's image:
(test.exe:8188): Gtk-[1;33mWARNING[0m **: Could not load
image 'a.jpg': Couldn't recognize the image file format for
file 'test\a.jpg'
(loads fine in glade)
which needs to be resolved, I'd also like to be able to use
gdkpixbuf to load images programmatically. There seems to be
no demos on the gtkD github page that deals with image loading.
I've tried to do something like
import gtkc.gdkpixbuf;
auto x = c_gdk_pixbuf_get_formats().data;
but I don't know how to interpret x.
Also something like
import gtkc.gdkpixbuf;
void* x;
auto p = c_gdk_pixbuf_get_formats();
for(int i = 0; i < 10; i++)
{
x = p.data;
p = p.next;
}
which doesn't offer any help.
Aside: How can we call the gtk functions directly using gtkD?
Seems it uses stuff like
Linker.link(gdk_pixbuf_get_formats, "gdk_pixbuf_get_formats",
LIBRARY_GDKPIXBUF);
It does seem to alias to these function but something is off
and I'm not sure what.
hi
- is the gtk.Image class not working for you?
https://api.gtkd.org/gtkd/gtk/Image.html
- there's also a gdkpixbuf.Pixbuf that you can use.
https://api.gtkd.org/gtkd/gdkpixbuf/Pixbuf.html
- you can import those functions from gdkpixbuf.c.functions.
So, like I said, I've tried
import gdkpixbuf.Pixbuf;
auto x = Pixbuf.newFromResource("C:\\a.jpg");
which gives me that error I stated before for x86. For x64 it
simply crashes and no exception is given.
If I use a dummy image I get the same error:
"Unhandled exception: glib.GException.GException The resource at
“C:\adf.jpg” does not exist at
generated\gtkd\glib\GException.d(40)"
The error message makes look like like it should be
"Unhandled exception: glib.GException.GException The resource at
“C:\adf.jpg” does not exist at “C:\”
generated\gtkd\glib\GException.d(40)"
I'd rather use Pixbuf than image because I don't need to generate
a full blow image widget.
If I do
GError* err = null;
auto p = gdk_pixbuf_new_from_resource(Str.toStringz("C:\\a.jpg"),
&err);
p is null and err is
The resource at “D:\a.jpgâ€. does not exist.
which is clearly not true.
So not sure what is going on ;/ Seems to be a bug in pixbuf or am
I specifying the path wrong? If gtk.Image uses these internally
then it is working so...