Re: gdk_pixbuf_composite_color() help needed.



I'm trying to overlay my application's logo over an empty space in my gtk+2
prog (MegaTunix).  In this mostly empty window exists a label and a
drawingarea, bothed packed into a vbox.  I've successfully setup the
expose/configure events modeling after the "testpixbuf" demo from the gtk+
source code. For the most part it works, EXCEPT I want to be able to display
the logo and have it blend in smoothly with the window no matter what color 
the
window may be (User may have a theme with different BG colors than mine, or a
pixmap background)

The only way I found thus far, was to retrieve the style of the parent widget
(the vbox in this case) and extract the bgcolor from it, the problem is it's 
a
GdkColor which stores the colors in 16 bit formats.  The
gdk_pixbuf_composite_color() accepts two colors  with 8 bits per component 
only
(I use the same color for each to avoid a checkerpattern) but in RGB packed
format (only 8 bits per R, G or B component).  In my conversion from 16 to 8,

I
loose resolution and the composition ends up having a rectangular box (the 
size
of the drawingarea) that is close, but not exactly the same color as the rest
of the applications background color.  It works (with the slight color
mismatch) with theme changes as long as the theme doesn't use a pixmap
background (instead ofa solid color).

I want to be able to display my logo (which has an alpha channel) on one of 
my
app's panes (gtk_notebook used) and have it blend into the background 
properly
no matter if the user is running a pixmap style theme or an arbritrary color
schemed theme..  (it almost works for the latter, I have no idea how to do 
the
former..)

Anyone got any ideas?  I'm currently stuck at this point.

Why not just create a GtkImage widget and use that to display your 
pixbuf?  GtkImage is a subclass of GtkMisc, just like GtkLabel, so it's 
basically a label that displays an image instead of some text.  Use 
gtk_image_new_from_pixbuf to easily create the widget and set it to 
display your pixbuf.

I did that originally,  but the logo has an alpha channel and a gentle fade at
the edges,  since X11 doesn't natively handle alpha channels, the GtkImage
clips it and make the logo look like crap. (sharp edge) By compositing it with
the color of the background it has a nice smooth transition,  the problem comes
with getting the background color in the same format that
gdk_pixbuf_composite_color accepts (I get the color back in 16 bit,  the gdk
call wants it in packed 8 bit,  the resolution loss causes errors and leaves
unwated artifacts onscreen.  

If I could find the code to actually take a screenshot of the empty space on my
app before the pixmap is placed and use that as my compositing source, that
would solve all of my problems.  Thus far I haven't figured out how to do that.


=====
Dave J. Andruczyk

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com



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