Re: pixmap and png..background



 hello,

   Thank u Michael...... And yes the your modified png file you have sent
IS TRANSPARENT

   And one more question., i tried to convert my other png files as you
have said by adding alpha channel to the image in GIMP. But i am unable to
do so. Can you please let me know how to do it. what i did was

        1. i loaded the corresponding png file in GIMP
        2.Right clicked on image
        3.clicked  "Layers"
        4.clicked "Add Alpha Channel"

   i saved and used it for display. the background was same(white).
   i am sure that i am missing something very vital, i tried some other
options also, but couldn't
   please let me know whats to be done exactly.

And thanks a lot 
akila

On 26 Jul 2002, Michael Torrie wrote:

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







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