Gtk2::Gdk::Pixbuf on win32

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Gtk2::Gdk::Pixbuf on win32

T.J. Ferraro
Not sure if this is a problem with the gtk2 bindings or the underlying
libraries so I figured I'd start here and work my way back. The attached
script runs fine on linux. However, I get this on windows:

Couldn't recognize the image file format for file 'image.bmp' at
imagetest.pl line 13.

Which is the line: $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file('image.bmp');

On the perl side: Cairo-1.045, Glib 1.164, Gtk2-1.164
Gtk2 libraries: cairo-1.4.14, glib-2.14.6, gtk+-2.12.8

As an aside, in my production script I call something slightly different
because the bmp data is already in memory:

$loader = Gtk2::Gdk::PixbufLoader->new;
$loader->write($bmpdata);
$loader->close();
$pixbuf = $loader->get_pixbuf();
$pixbuf->render_to_drawable($fpdraw->window,$fpgc,0,0,0,0,-1,-1,'none',0,0);

But I felt the attached case was more succinct for a demonstration of
the same issue.

Any help is much appreciated. Thanks.
T.J.

use Glib qw/TRUE FALSE/;
use Gtk2 '-init';

$mw = Gtk2::Window->new('toplevel');
$mw->signal_connect(destroy => sub { Gtk2->main_quit; });

$fpdraw = Gtk2::DrawingArea->new;
$mw->add($fpdraw);
$fpdraw->realize;
$fpgc = Gtk2::Gdk::GC->new($fpdraw->window);
$fpdraw->signal_connect(expose_event => \&expose_event);

$pixbuf = Gtk2::Gdk::Pixbuf->new_from_file('image.bmp');
$pixbuf->render_to_drawable($fpdraw->window,$fpgc,0,0,0,0,-1,-1,'none',0,0);

$mw->maximize;
$mw->show_all;
Gtk2->main();

sub expose_event
{
        $pixbuf->render_to_drawable($fpdraw->window,$fpgc,0,0,0,0,-1,-1,'none',0,0);
        return FALSE;
}
_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

image.bmp (90 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Gdk::Pixbuf on win32

rahed
"T.J. Ferraro" <[hidden email]> writes:

> Which is the line: $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file('image.bmp');

Instead of Gtk2::Gdk::Pixbuf I use:

Gtk2::Image->new_from_file('image.jpg');

Also tried your way but found Gtk2::Image works to my purpose. Now I
don't remember what was wrong with Pixbuf.

--
Radek

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Gdk::Pixbuf on win32

T.J. Ferraro
rahed wrote:

> "T.J. Ferraro" <[hidden email]> writes:
>
>  
>> Which is the line: $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file('image.bmp');
>>    
>
> Instead of Gtk2::Gdk::Pixbuf I use:
>
> Gtk2::Image->new_from_file('image.jpg');
>
> Also tried your way but found Gtk2::Image works to my purpose. Now I
> don't remember what was wrong with Pixbuf.
>
>  
Well, for my purpose the bitmap image is already in memory. Which is why
I was using the pixbuf way because it has a new_from_data method whereas
Gtk2::Image does not. Which is a small performance hit when you have to
write something to disk only to read it again.

In any case, I figured I would give it a try right now. However, when I
use Gtk2::Image and pack it all I get is a small box with a red X.
Calling either get_pixbuf or get_image, gives me either:

Gtk-CRITICAL **: gtk_image_get_image: assertion `image->storage_type ==
GTK_IMAGE_IMAGE || image->storage_type == GTK_IMAGE_EMPTY'

Gtk-CRITICAL **: gtk_image_get_image: assertion `image->storage_type ==
GTK_IMAGE_IMAGE || image->storage_type == GTK_IMAGE_EMPTY'

Any other suggestions? Thanks.

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Gdk::Pixbuf on win32

muppet-6

On Mar 2, 2008, at 11:07 PM, T.J. Ferraro wrote:

> rn any case, I figured I would give it a try right now. However,  
> when I
> use Gtk2::Image and pack it all I get is a small box with a red X.
> Calling either get_pixbuf or get_image, gives me either:
>
> Gtk-CRITICAL **: gtk_image_get_image: assertion `image->storage_type  
> ==
> GTK_IMAGE_IMAGE || image->storage_type == GTK_IMAGE_EMPTY'
>
> Gtk-CRITICAL **: gtk_image_get_image: assertion `image->storage_type  
> ==
> GTK_IMAGE_IMAGE || image->storage_type == GTK_IMAGE_EMPTY'

That's most likely because the image failed to load.


> Any other suggestions? Thanks.

Are you sure that your gtk+ (actually, gdk-pixbuf) supports BMP?  This  
works in a nice, comfy linux shell, so you'll have to experiment with  
quoting on your rickety windows shells:

$ perl -MGtk2 -e 'printf " %5s   %s\n", $_->{name}, $_->{description}  
foreach Gtk2::Gdk::Pixbuf->get_formats'
    ani   The ANI image format
    bmp   The BMP image format
    gif   The GIF image format
    ico   The ICO image format
   jpeg   The JPEG image format
    pcx   The PCX image format
    png   The PNG image format
    pnm   The PNM/PBM/PGM/PPM image format family
    ras   The Sun raster image format
    tga   The Targa image format
   tiff   The TIFF image format
   wbmp   The WBMP image format
    xbm   The XBM image format
    xpm   The XPM image format
    svg   Scalable Vector Graphics



In your earlier message, you gave the error message:

> Couldn't recognize the image file format for file 'image.bmp' at  
> imagetest.pl line 13.

This comes from gtk+/gdk-pixbuf/gdk-pixbuf-io.c around line 728 (line  
numbers may vary by version), in the function  
_gdk_pixbuf_get_module(), and basically tells you that no installed  
image module claimed that it could recognize and knew how to parse the  
data from the file.


If your system lists BMP as supported, are you sure your file is  
correctly formatted?  As i recall, the file header should start with  
the characters "B" and "M".

(Note that the pixbuf loader expects you to write all the data that  
would be in the file, header and all, even if compressed.  If you just  
have the uncompressed image data, then  
Gtk2::Gdk::Pixbuf::new_from_data is more what you need.)


If you're absolutely certain that BMP is supported by your gtk+ and  
that your data is correct, try forcing the loader to recognize the  
mime type:

     $loader = Gtk2::Gdk::PixbufLoader->new_with_mime_type ('image/
bmp');

(Note: on older versions of the Gtk2 binding, new_with_mime_type() was  
misbound as a function.)

--
Diane, ten-oh-three, Great Northern Hotel.
Sheriff Truman and I have just been with the one-armed man, or what's  
left of him.
In another time, another culture, he may have been a seer, or a shaman  
priest, but in our world, he's a shoe salesman, and lives among the  
shadows.
-- Special Agent Dale Cooper

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Gdk::Pixbuf on win32

T.J. Ferraro
C:\>perl -MGtk2 -e "printf \" %5s   %s\n\", $_->{name},
$_->{description} foreach Gtk2::Gdk::Pixbuf->get_formats"
   ani   The ANI image format
   bmp   The BMP image format
   gif   The GIF image format
   ico   The ICO image format
  jpeg   The JPEG image format
   pcx   The PCX image format
   png   The PNG image format
   pnm   The PNM/PBM/PGM/PPM image format family
   ras   The Sun raster image format
   tga   The Targa image format
  tiff   The TIFF image format
  wbmp   The WBMP image format
   xbm   The XBM image format
   xpm   The XPM image format

I have tried using different bmp files. I am confident they are valid
bitmaps as the same code/images render fine on linux.

When I call $loader = Gtk2::Gdk::PixbufLoader->new_with_mime_type
('image/bmp'); I get: Unrecognized image file format

Also just tried png and gif files. And whether calling
Gtk2::Gdk::Pixbuf::new_from_data or loading a file directly all result
in the same errors.

T.J.

muppet wrote:

>
> On Mar 2, 2008, at 11:07 PM, T.J. Ferraro wrote:
>
>> rn any case, I figured I would give it a try right now. However, when I
>> use Gtk2::Image and pack it all I get is a small box with a red X.
>> Calling either get_pixbuf or get_image, gives me either:
>>
>> Gtk-CRITICAL **: gtk_image_get_image: assertion `image->storage_type ==
>> GTK_IMAGE_IMAGE || image->storage_type == GTK_IMAGE_EMPTY'
>>
>> Gtk-CRITICAL **: gtk_image_get_image: assertion `image->storage_type ==
>> GTK_IMAGE_IMAGE || image->storage_type == GTK_IMAGE_EMPTY'
>
> That's most likely because the image failed to load.
>
>
>> Any other suggestions? Thanks.
>
> Are you sure that your gtk+ (actually, gdk-pixbuf) supports BMP?  This
> works in a nice, comfy linux shell, so you'll have to experiment with
> quoting on your rickety windows shells:
>
> $ perl -MGtk2 -e 'printf " %5s   %s\n", $_->{name}, $_->{description}
> foreach Gtk2::Gdk::Pixbuf->get_formats'
>    ani   The ANI image format
>    bmp   The BMP image format
>    gif   The GIF image format
>    ico   The ICO image format
>   jpeg   The JPEG image format
>    pcx   The PCX image format
>    png   The PNG image format
>    pnm   The PNM/PBM/PGM/PPM image format family
>    ras   The Sun raster image format
>    tga   The Targa image format
>   tiff   The TIFF image format
>   wbmp   The WBMP image format
>    xbm   The XBM image format
>    xpm   The XPM image format
>    svg   Scalable Vector Graphics
>
>
>
> In your earlier message, you gave the error message:
>
>> Couldn't recognize the image file format for file 'image.bmp' at
>> imagetest.pl line 13.
>
> This comes from gtk+/gdk-pixbuf/gdk-pixbuf-io.c around line 728 (line
> numbers may vary by version), in the function
> _gdk_pixbuf_get_module(), and basically tells you that no installed
> image module claimed that it could recognize and knew how to parse the
> data from the file.
>
>
> If your system lists BMP as supported, are you sure your file is
> correctly formatted?  As i recall, the file header should start with
> the characters "B" and "M".
>
> (Note that the pixbuf loader expects you to write all the data that
> would be in the file, header and all, even if compressed.  If you just
> have the uncompressed image data, then
> Gtk2::Gdk::Pixbuf::new_from_data is more what you need.)
>
>
> If you're absolutely certain that BMP is supported by your gtk+ and
> that your data is correct, try forcing the loader to recognize the
> mime type:
>
>     $loader = Gtk2::Gdk::PixbufLoader->new_with_mime_type ('image/bmp');
>
> (Note: on older versions of the Gtk2 binding, new_with_mime_type() was
> misbound as a function.)
>
> --
> Diane, ten-oh-three, Great Northern Hotel.
> Sheriff Truman and I have just been with the one-armed man, or what's
> left of him.
> In another time, another culture, he may have been a seer, or a shaman
> priest, but in our world, he's a shoe salesman, and lives among the
> shadows.
> -- Special Agent Dale Cooper
>
>


_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Gdk::Pixbuf on win32

muppet-6

On Mar 3, 2008, at 4:51 PM, T.J. Ferraro wrote:

> I have tried using different bmp files. I am confident they are valid
> bitmaps as the same code/images render fine on linux.
>
> When I call $loader = Gtk2::Gdk::PixbufLoader->new_with_mime_type
> ('image/bmp'); I get: Unrecognized image file format
>
> Also just tried png and gif files. And whether calling
> Gtk2::Gdk::Pixbuf::new_from_data or loading a file directly all result
> in the same errors.

Do other gtk+ programs work correctly with loading images on your  
machine?

At this point, if you have the ability, i'd say port your example code  
to C and verify that the C program still can't load the images.

If the C program can't load the images, that means that your gtk+ is  
broken somehow, and the bug report goes to gnome bugzilla.

If the C program can load the images, then something is wrong with  
your setup at runtime.  Are the gdk-pixbuf loader modules being picked  
up correctly?  (I don't know how to tell on windows; on linux i'd use  
strace.)

On further inspection of the gtk+ source, it looks like if there are  
no builtin loader modules, gdk-pixbuf will scan the loader config file  
to get the list spewed back by gdk_pixbuf_get_formats(); but this may  
not reflect whether the modules can actually be loaded.  So there may  
be an issue with the loader module dlls not being in a path that you  
can find at runtime.


--
Diane, ten-oh-three, Great Northern Hotel.
Sheriff Truman and I have just been with the one-armed man, or what's  
left of him.
In another time, another culture, he may have been a seer, or a shaman  
priest, but in our world, he's a shoe salesman, and lives among the  
shadows.
-- Special Agent Dale Cooper

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Gdk::Pixbuf on win32

T.J. Ferraro
Sorry for the delay. It looks like I will have to file a report as after
building a simple C program I'm getting a segfault calling
gdk_pixbuf_new_from_file. I will get around to that some time this
weekend along with testing the other more complex methods.

In the mean time, however, I also built another small C program. This
one using gtk_image_new_from_file. Suffice it to say this works fine in
C, but Gtk2::Image->new_from_file simply does not. It just shows the
little page icon with a red X. Of course, the same script in linux runs
fine. I can provide either the C code or the (very) simple perl script
on request. I tried looking through the xs code...but it looks like
there is very little translation for this function.

At this point I'm willing to settle for any way to display an image in
gtk2 on windows, so, any suggestions are welcome :)

Thanks,
T.J.

>
> Do other gtk+ programs work correctly with loading images on your
> machine?
>
> At this point, if you have the ability, i'd say port your example code
> to C and verify that the C program still can't load the images.
>
> If the C program can't load the images, that means that your gtk+ is
> broken somehow, and the bug report goes to gnome bugzilla.
>
> If the C program can load the images, then something is wrong with
> your setup at runtime.  Are the gdk-pixbuf loader modules being picked
> up correctly?  (I don't know how to tell on windows; on linux i'd use
> strace.)
>
> On further inspection of the gtk+ source, it looks like if there are
> no builtin loader modules, gdk-pixbuf will scan the loader config file
> to get the list spewed back by gdk_pixbuf_get_formats(); but this may
> not reflect whether the modules can actually be loaded.  So there may
> be an issue with the loader module dlls not being in a path that you
> can find at runtime.
>
>
> --
> Diane, ten-oh-three, Great Northern Hotel.
> Sheriff Truman and I have just been with the one-armed man, or what's
> left of him.
> In another time, another culture, he may have been a seer, or a shaman
> priest, but in our world, he's a shoe salesman, and lives among the
> shadows.
> -- Special Agent Dale Cooper
>
>


_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Gdk::Pixbuf on win32

Grant McLean
On Thu, 2008-03-06 at 01:05 -0800, T.J. Ferraro wrote:
> At this point I'm willing to settle for any way to display an image in
> gtk2 on windows, so, any suggestions are welcome :)

I've attached a standalone program that displays an image on a button.
The source image was a PNG but I've encoded the bytestream inline using
Base64 encoding.  I don't have Windows so I'm unable to try it there,
but it works on Linux.

Cheers
Grant





_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

image_button.pl (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Gdk::Pixbuf on win32

T.J. Ferraro
Yep, works on linux, but...

C:\>perl image_button.pl
Unrecognized image file format at image_button.pl line 45.

Thanks for the effort, though :)

T.J.

Grant McLean wrote:

> On Thu, 2008-03-06 at 01:05 -0800, T.J. Ferraro wrote:
>  
>> At this point I'm willing to settle for any way to display an image in
>> gtk2 on windows, so, any suggestions are welcome :)
>>    
>
> I've attached a standalone program that displays an image on a button.
> The source image was a PNG but I've encoded the bytestream inline using
> Base64 encoding.  I don't have Windows so I'm unable to try it there,
> but it works on Linux.
>
> Cheers
> Grant
>
>
>
>
>  


_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Gdk::Pixbuf on win32

rahed
In reply to this post by Grant McLean
Grant McLean <[hidden email]> writes:

> I've attached a standalone program that displays an image on a button.
> The source image was a PNG but I've encoded the bytestream inline using
> Base64 encoding.  I don't have Windows so I'm unable to try it there,
> but it works on Linux.

Here it runs ok on windows.
I have gtk+ 2.10.11, glib 2.12.11.

--
Radek

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Gdk::Pixbuf on win32

T.J. Ferraro
Are you running ActiveState perl? What version of Gtk2 and Glib perl
bindings? What compiler did you use?

Thanks.

T.J.

rahed wrote:

> Grant McLean <[hidden email]> writes:
>
>  
>> I've attached a standalone program that displays an image on a button.
>> The source image was a PNG but I've encoded the bytestream inline using
>> Base64 encoding.  I don't have Windows so I'm unable to try it there,
>> but it works on Linux.
>>    
>
> Here it runs ok on windows.
> I have gtk+ 2.10.11, glib 2.12.11.
>
>  


_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Gdk::Pixbuf on win32

rahed
"T.J. Ferraro" <[hidden email]> writes:

> Are you running ActiveState perl? What version of Gtk2 and Glib perl
> bindings? What compiler did you use?

I've got perl v5.10.0 compiled with MinGW, Gtk2 1.164, Glib 1.164.

--
Radek

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Gtk2::Image on win32 (Was Gtk2::Gdk::Pixbuf on win32)

T.J. Ferraro
Been kind of busy, but back on track now. Instead of reviving this via
Gtk2::Gdk::Pixbuf, I figured I'd try to get Gtk2::Image working
considering I know from compiling a C program the libraries are working
on win32. (Whereas I could not get the Pixbuf stuff working in C on win32)

I installed Strawberry Perl 5.10, and made Cairo-1.045, Glib-1.181,
Gtk2-1.181 without any issue (well, I had a little help via
http://www.perlmonks.org/?node_id=671479). Anyways, using the
mingw/dmake toolchain gives me the same issue w/ Gtk2::Image as did
compiling with activestate/msvc. I still get the little file with the red X.

Is there anything else special you did?

Thanks,
T.J.

rahed wrote:

> "T.J. Ferraro" <[hidden email]> writes:
>
>  
>> Are you running ActiveState perl? What version of Gtk2 and Glib perl
>> bindings? What compiler did you use?
>>    
>
> I've got perl v5.10.0 compiled with MinGW, Gtk2 1.164, Glib 1.164.
>
>  



_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Image on win32 (Was Gtk2::Gdk::Pixbuf on win32)

muppet-6

On Mar 20, 2008, at 2:06 AM, T.J. Ferraro wrote:
> Been kind of busy, but back on track now. Instead of reviving this via
> Gtk2::Gdk::Pixbuf, I figured I'd try to get Gtk2::Image working
> considering I know from compiling a C program the libraries are  
> working
> on win32. (Whereas I could not get the Pixbuf stuff working in C on  
> win32)

This is really starting to sound like a runtime path problem; perhaps  
gtk+ can't find its modules when run from your perl script?  Can you  
run in a C debugger to try it?

> http://www.perlmonks.org/?node_id=671479).

That mentions some grief getting symbols resolved, and asks if the  
Makefile.PL shouldn't take care of that.  Makefile.PL *does* take care  
of that, for the MSVC toolchain -- the find_extra_libs() subroutine at  
the bottom.  It only looks for .lib files, though.  We'll gladly  
accept patches to make this work with mingw, too.


--
I hate to break it to you, but magic data pixies don't exist.
   -- Simon Cozens


_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Image on win32 (Was Gtk2::Gdk::Pixbuf on win32)

T.J. Ferraro
In reply to this post by T.J. Ferraro
Well, here's what I got when running it through OllyDbg.

It runs like:
call perl510.Perl_get_context
call perl510.Perl_Istack_base_ptr
call Glib.gperl_filename_from_sv (After which EAX points to a memory
location that correctly contains the image name)
Then it gets moved to EDX, which is then pushed onto the stack
call libgtk-win32-2.0-0.gtk_image_new_from_file_utf8
call libgtk-win32-2.0-0.gtk_object_get_type
call libgobject-2.0-0.g_type_check_instance_cast
... (More perl specific calls)

In C, the call stack (specifically the relevant ones) is:
call libgtk-win32-2.0-0.gtk_image_new_from_file_utf8
call libgtk-win32-2.0-0.gtk_container_get_type
call libgobject-2.0-0.g_type_check_instance_cast

I see that in perl it calls gtk_container_get_type instead of
gtk_object_get_type, not sure if that makes a difference, though.

Also, after calling gtk_image_new_from_file_utf8, eax seems to contain a
pointer to a memory location. The data pointed to by eax is very
similar, though not identical in both cases.

LastErr stays 0 after making all of the relevant calls, is there
anything else I should be specifically be looking for?

I've attached the two sources just in case the slight discrepancies
could be explained by differences in the code?

Thanks for your help.

T.J.

muppet wrote:

>
> On Mar 20, 2008, at 2:06 AM, T.J. Ferraro wrote:
>> Been kind of busy, but back on track now. Instead of reviving this via
>> Gtk2::Gdk::Pixbuf, I figured I'd try to get Gtk2::Image working
>> considering I know from compiling a C program the libraries are working
>> on win32. (Whereas I could not get the Pixbuf stuff working in C on
>> win32)
>
> This is really starting to sound like a runtime path problem; perhaps
> gtk+ can't find its modules when run from your perl script?  Can you
> run in a C debugger to try it?
>
>> http://www.perlmonks.org/?node_id=671479).
>
> That mentions some grief getting symbols resolved, and asks if the
> Makefile.PL shouldn't take care of that.  Makefile.PL *does* take care
> of that, for the MSVC toolchain -- the find_extra_libs() subroutine at
> the bottom.  It only looks for .lib files, though.  We'll gladly
> accept patches to make this work with mingw, too.
>
>
> --
> I hate to break it to you, but magic data pixies don't exist.
>   -- Simon Cozens

#include <gtk/gtk.h>

gint delete_event(GtkWidget *widget, GdkEvent  *event, gpointer data)
{
        gtk_main_quit ();
        return TRUE;
}

void destroy(GtkWidget *widget, gpointer data)
{
    gtk_main_quit ();
}

int main(int argc, char *argv[])
{
        GtkWidget *image;
        GtkWidget *window;
       
        gtk_init (&argc, &argv);
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete_event), NULL);
        g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy), NULL);
       
        image = gtk_image_new_from_file ("image.bmp");
        gtk_container_add (GTK_CONTAINER (window), image);
        gtk_widget_show (image);
        gtk_widget_show (window);
       
        gtk_main ();
        return 0;
}

use Glib qw/TRUE FALSE/;
use Gtk2 '-init';

$mw = Gtk2::Window->new('toplevel');
$mw->signal_connect(destroy => sub { Gtk2->main_quit; });

$image = Gtk2::Image->new_from_file('image.bmp');

$mw->add($image);
$mw->maximize;
$mw->show_all;
Gtk2->main();

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Image on win32 (Was Gtk2::Gdk::Pixbuf on win32)

muppet-6

On Mar 20, 2008, at 5:47 PM, T.J. Ferraro wrote:
> Well, here's what I got when running it through OllyDbg.
[snip]
> LastErr stays 0 after making all of the relevant calls, is there  
> anything else I should be specifically be looking for?

The messages you've sent before make me think that gdk-pixbuf is  
failing to load the loader modules.

This happens on demand from gdk_pixbuf_new_from_file() and  
gdk_pixbuf_animation_new_from_file(), but i think the function you  
want to step through in the debugger is _gdk_pixbuf_load_module(),  
called by both.  gtk_image_new_from_file() calls  
gtk_image_set_from_file(), which calls  
gdk_pixbuf_animation_new_from_file().


> I've attached the two sources just in case the slight discrepancies  
> could be explained by differences in the code?

Nothing jumps out.


--
The one difference between Dali and a crazy man is very simple: Dali  
is not crazy at all.
   -- Salvador Dali


_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk2::Image on win32 (Was Gtk2::Gdk::Pixbuf on win32)

T.J. Ferraro
Good call. After tracing into those functions I noticed some file not
found(s). It looks like the following is necessary:

gdk-pixbuf.loaders needs to be in an etc/ folder from wherever the perl
file is called.
gdk-pixbuf.loaders must be edited and the path to the respective dlls
must be changed to reflect where they actually are on the current system
(obviously)
subsequently, to ship a standalone program, the entire
/lib/gtk-2.0/2.10.0/ must also be included (most of which are referenced
by gdk-pixbuf.loaders)

Thanks for the help =)

T.J.


muppet wrote:

> On Mar 20, 2008, at 5:47 PM, T.J. Ferraro wrote:
>  
>> Well, here's what I got when running it through OllyDbg.
>>    
> [snip]
>  
>> LastErr stays 0 after making all of the relevant calls, is there  
>> anything else I should be specifically be looking for?
>>    
>
> The messages you've sent before make me think that gdk-pixbuf is  
> failing to load the loader modules.
>
> This happens on demand from gdk_pixbuf_new_from_file() and  
> gdk_pixbuf_animation_new_from_file(), but i think the function you  
> want to step through in the debugger is _gdk_pixbuf_load_module(),  
> called by both.  gtk_image_new_from_file() calls  
> gtk_image_set_from_file(), which calls  
> gdk_pixbuf_animation_new_from_file().
>
>
>  
>> I've attached the two sources just in case the slight discrepancies  
>> could be explained by differences in the code?
>>    
>
> Nothing jumps out.
>
>
> --
> The one difference between Dali and a crazy man is very simple: Dali  
> is not crazy at all.
>    -- Salvador Dali
>
>
> _______________________________________________
> gtk-perl-list mailing list
> [hidden email]
> http://mail.gnome.org/mailman/listinfo/gtk-perl-list
>
>  


_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list