Re: pixmap and png..background



On Fri, 2002-07-26 at 23:04, AKILA M wrote:
hello,
    i create a pixmap from a png file using the following API

      pixbuf = gdk_pixbuf_new_from_file("filename.png");
        gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, &mask, 127);
        image = gtk_pixmap_new(pixmap, mask);

      i put the image in an event box and display it in a fixed
container. My problem is that i get a white backgroud in the image. i have
                                        ^^^^^^^^^^^^^^^^

Umm, you're getting a white background because that's what's in the png
file (ie there's no transparency in the png)!  Evolution shows
transparent pngs properly, and this one shows up as a blue circle on a
white background.  I loaded the png into the gimp and added an alpha
channel and changed the white into transparent.  The new png is
attached.  Try it and see if it doesn't show up as transparent.

By the way, you might want to use a GtkDrawingArea widget instead of
just an event box.  Then you can render the GdkPixbuf to it with fill
alpha blending, instead of just a threshold transparency level.

Michael


read the previous discussions on this problem(one posted 2 days earlier).
i can't use

      gtk_image_from_new_file (GTK2.0)

since i use gtk1.2.8. i create the png image file using XPaint. i
alternatively use gimp also. but the background is the same white. i have
tried converting png to xpm file. i also found out this(background in
white) doesnot happen with xpm files stored in buffers...and can be used
in API

       pixmap = gdk_pixmap_create_from_xpm_d(fcontainer->window,
                                                &mask,
                                                &style->bg[GTK_STATE_NORMAL],
                                                buffer_xpm);

But i want to know how i can get transparent background in png
files.(using GTK1.2.8)

Any help would be very useful....

i have attached a sample png file with this.."dot_circle.png"

Thankx a lot
akila




******************************************************************************
M. Akila,
Central Research Laboratory,
Bharat Electronics,
Jalahalli,
Bangalore.

Ph.No (off): 91-080-8381125
E-Mail Id  : akila crlbel ernet in
              
                               HAVE A NICE DAY
******************************************************************************
-- 
Public key available from http://students.cs.byu.edu/~torriem


Attachment: dot_circle.png
Description: PNG image

Attachment: signature.asc
Description: This is a digitally signed message part



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