Re: slow pixbuf drawing, how get rid of alpha channel



On Wed, 2003-06-04 at 19:12, Fritz Ganter wrote:
Hello!

I'm using image=gdk_pixbuf_new_from_file to load gifs and png files.
Then I have to do
      tempimage = gdk_pixbuf_new (GDK_COLORSPACE_RGB, 1, 8, 1280, 1024);
There my program eats 30-35% of CPU. This is much more than the old
gtk+1.2 version.
If I use no alpha channel instead 
gdk_pixbuf_new (GDK_COLORSPACE_RGB, 0,...);
the cpus load drops down to about 10-15% which is ok.
Unfurtunatly it works only with png images, if a gif is loaded i get:

** (gpsdrive:20432): CRITICAL **: file pixops.c: line 1618
(pixops_scale): assertion `!(src_has_alpha && !dest_has_alpha)' failed

If gdk_pixbuf_copy_area() from your image to a non-alpha pixbuf
worked, then the source pixbuf didn't have alpha, and it was
pointless. (See gdk_pixbuf_get_has_alpha() to check)

Removing alpha from an image is something that is fairly nonsensical,
unless you happen to know it didn't have alpha to begin with -
for the extreme case, consider completely transparent pixels. Their
color is undefined.

How can I remove the alpha channel from image if it is a gif-file?

It should be easy to write such a function yourself; functions
you need:

 gdk_pixbuf_new()
 gdk_pixbuf_get_pixels()
 gdk_pixbuf_get_rowstride()
 gdk_pixbuf_get_width()
 gdk_pixbuf_get_height()
 gdk_pixbuf_get_has_alpha()

Plus the knowledge that the data in a pixbuf with alpha is stored
(fixed byte order) as RGBARGBARGBA... while the data in a pixbuf
without alpha is stored RGBRGBRGBRGB...

Regards,
                                          Owen





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