[Gtk2forpascal-devel] Problem with PGdkPixbufLoader
Brought to you by:
mgaertner
From: <wan...@ya...> - 2004-06-08 01:44:10
|
Hello, everybody I met a very strange problem when using gdk_pixbuf_loader_get_pixbuf() when this function is put into a function. In the following program, the "if" block is exactly the same as the "else" block except that in the "if" block gdk_pixbuf_loader_get_pixbuf() is put into getImage() function. The "else" block can work well and output the correct image, but the "if" block can't work, just give some errors: (test:2999): GdkPixbuf-CRITICAL **: file gdk-pixbuf-loader.c: line 472 (gdk_pixbuf_loader_write): assertion `error == NULL || *error == NULL' failed error! Can anyone help me? Thank you so much, Zhong ===============>>>> program test; {$H+} {$mode objfpc} uses gtk2, glib2, gdk2pixbuf, classes; function getImage(loader:PGdkPixbufLoader; var s:string):boolean; var error : pgerror; begin result := gdk_pixbuf_loader_write(loader,@(s[1]),length(s),@error); end;//getImage() var window,image : PGtkWidget; fs : TFileStream; loader : PGdkPixbufLoader; s : string; error : pgerror; pixbuf : PGdkPixbuf; begin gtk_init(@argc, @argv); window := gtk_window_new(GTK_WINDOW_TOPLEVEL); image := gtk_image_new; gtk_widget_show(image); gtk_container_add(GTK_CONTAINER(window), image); loader := gdk_pixbuf_loader_new; fs := TFileStream.Create('aaa.gif',fmOpenRead); setLength(s,fs.size); fs.read(s[1],fs.size); fs.free; if (true) then begin //switch to false, it will succeed if getImage(loader,s) then begin pixbuf := gdk_pixbuf_loader_get_pixbuf(loader); gtk_image_set_from_pixbuf(PGtkImage(image),pixbuf); end else begin writeln('error!'); end; end else begin if (gdk_pixbuf_loader_write(loader,@(s[1]),length(s),@error)) then begin pixbuf := gdk_pixbuf_loader_get_pixbuf(loader); gtk_image_set_from_pixbuf(PGtkImage(image),pixbuf); end else begin writeln('error!'); end; end; gtk_widget_show(window); gtk_main(); end. _________________________________________________________ Do You Yahoo!? 嫌邮箱太小?雅虎电邮自助扩容! http://cn.rd.yahoo.com/mail_cn/tag/10m/*http://cn.mail.yahoo.com/event/10m.html |