Problem displaying image with alpha channel in a transparent window

2008-07-23 Thread Yann Droneaud
Hi,

I'm trying to write a program to display a picture with full
transparency in its own window (without border), using Composite
extension (ARGB colormap and visual).

I've written a couple of programs doing this using Xlib alone or with
libXrender.

Using GTK+ to do the same seems easy since programs like cairo-clock [1]
are able to draw window with non rectangular shape and full
transparency.

But after many hours, and many version of my GTK+ demonstration program,
I'm still wandering how to display a GdkPixBuf with alpha layer in a
GtkWindow without any background or artefact.

So here are my little demonstration programs

- test-gdkpixbuf.c : 

  This program does the following:
  - looks up the RGBA colormap with gdk_screen_get_rgba_colormap()
  - installs the colormap with gtk_widget_set_default_colormap()
  - creates a GdkPixbuf with gdk_pixbuf_new_from_file()
  - creates a GtkWindow
  - sets the widget as GTK_APP_PAINTABLE with  
gtk_widget_set_app_paintable()
  - disables double buffering with gtk_widget_set_double_buffered()
  - in the realize signal handler, it removes any background pixmap 
using gdk_window_set_back_pixmap()
  - in the expose event handler, it draws the GdkPixBuf using
gdk_draw_pixbuf()

  At first, it seems to work, but in fact, as soon as you move the 
  picture using CTRL+Button 1, you will realize the problem: the 
  window's background is a snapshot of the root window (see post from 
  Matt Hoosier [2]), and is fixed for the window's lifetime.
  At least, the content of the picture is well composited with the   
  background, but it's not the full transparency I'm looking for.

  See:
  - test-gdkpixbuf.png

- test-gdkpixbuf-bg.patch:
  
  Apply the patch on top of test-gdkpixbuf.c to create 
  test-gdkpixbuf-background.c
  This patch set a pixmap as a background, and draw nothing on the 
  window. Only the realize signal and expose event handlers are 
  modified:
  - realize signal handler creates a new pixmap with gdk_pixmap_new(),
writes the content of the GdkPixBuf with gdk_draw_pixbuf() and then
install the background with gdk_window_set_back_pixmap().
  - expose event handler only call to gdk_window_clear()

  With this version, the background is really transparent, but many 
  artefacts are visibles: the background is corrupted.
  On some configuration, I'm even able to see some other pixmap content 
  as background, strange !

  See:
  - test-gdkpixbuf-background.png

Note: those were tested with Gtk+ 2.10 and Gtk+ 2.12.

So I'm stuck. Either I'm always getting a unwanted background (filled
with solid color or a root window snapshot) or I'm getting a corrupted
image.

I've tried to: 
- use a GtkImage widget made from the GdkPixBuf
- use a GtkDrawingArea in the main window and draw into it
- use gdk_draw_rgb_32_image() instead of gdk_draw_pixbuf()
- paint with gdk_cairo_set_source_pixbuf()
I'm always getting an image composited with the window background.

Could someone provide me a link, a tips, or something to help me.
Thanks.

[1] http://macslow.thepimp.net/?page_id=23
[2] http://mail.gnome.org/archives/gtk-list/2006-October/msg00246.html

-- 
Yann Droneaud [EMAIL PROTECTED]

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

save image and display image from postgresql

2008-07-23 Thread paragasu
i am very new to gtk programming. I am sorry for this beginner
questions, but after asking
google i fail the get the right answer. I hope this mailing list will help me.

anyone can please point me a way on how to save image to postgresql
database and
display the image again.

thank you
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Screenshot of a GtkWindow

2008-07-23 Thread Andrew Cowie
On Wed, 2008-07-23 at 13:32 +0200, Gabriele Greco wrote:
 I need to make a screenshot of a GtkWindow from the program itself

We used code from gnome-utils's gnome-screenshot/gnome-screenshot.c and
gnome-screenshot/screenshot-utils.c to add a capture capability to
java-gnome (we wanted window decorations and all, not just the GdkWindow
behind something; the drop shadows are nice too). We use this when
generating our API documentation, for example:
http://java-gnome.sourceforge.net/4.0/doc/api/org/gnome/gtk/AboutDialog.html

I certainly appreciate now that gathering a screenshot (window borders
and all) is very tricky and involves some voodoo mucking about with X. I
am quite thankful that such code existed to be reused.

Unfortunately it's not a library as yet, so we had to copy it manually.
Our import of it was a bit hack-and-slash, but our versions of the above
two files, as gnome_screenshot_capture.c and gnome_screenshot_utils.c,
can be found in a checkout of a java-gnome in the src/jni/ directory,
ie
http://research.operationaldynamics.com/bzr/java-gnome/mainline/src/jni/

AfC
Sydney

-- 
Andrew Frederick Cowie

Operational Dynamics is an operations and engineering consultancy
focusing on IT strategy, organizational architecture, systems
review, and effective procedures for change management. We actively
carry out research and development in these areas on behalf of our
clients, and enable successful use of open source in their mission
critical enterprises, worldwide.

http://www.operationaldynamics.com/

Sydney   New York   Toronto   London
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Screenshot of a GtkWindow

2008-07-23 Thread jcupitt
2008/7/23 Gabriele Greco [EMAIL PROTECTED]:
 I need to make a screenshot of a GtkWindow from the program itself, there is
 a crossplatform way to do it (with 2.12 stable)?

 I thought about copying the window-window drawable to a gdkpixbuf, but
 maybe there is a cleaner way

No, that's what you need, as far as I know:

  
http://library.gnome.org/devel/gdk/stable/gdk-Pixbufs.html#gdk-pixbuf-get-from-drawable

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: save image and display image from postgresql

2008-07-23 Thread Vivien Malerba
2008/7/23 paragasu [EMAIL PROTECTED]:
 i am very new to gtk programming. I am sorry for this beginner
 questions, but after asking
 google i fail the get the right answer. I hope this mailing list will help me.

 anyone can please point me a way on how to save image to postgresql
 database and
 display the image again.

To save an image in Postgres, you can sither use a blob type, a binary
string, or convert your picture to an ASCII string (in base64 for
example) and use a normal string field. Loading it back is a matter of
doing the reverse.

As to display the image in GTK+, you can use
gtk_image_new_from_pixbuf() along with a GdkPixbufLoader. This is
what's done in Libgnomedb (for example in
http://svn.gnome.org/viewvc/libgnomedb/trunk/libgnomedb/plugins/common-pict.c?revision=1686view=markup).

Regards,

Vivien
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list