Re: [gtk-list] Placing a GdkBitmap into a GtkPixmap widget
- From: Havoc Pennington <hp redhat com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Placing a GdkBitmap into a GtkPixmap widget
- Date: Sat, 23 Oct 1999 13:51:45 -0400 (EDT)
On Fri, 22 Oct 1999, Arthur Jerijian wrote:
>
> I am writing a test program which will display monochrome bitmaps inside a GTK+
> window. I understand that in many cases, a GdkBitmap can be used instead of a
> GdkPixmap in GTK+ function calls, since they are both drawables. However, when
> I create a GtkPixmap widget using the following functions:
>
Bitmaps and pixmaps are not only drawables, they are both pixmaps -
bitmaps are pixmaps with a depth of 1. In this case the Gdk types are just
for human consumption, the types are the same on the server side.
The BadMatch error is because copying one drawable to another requires
those drawables to have the same bit depth. In that case the server can do
a memcpy()-equivalent operation to perform the copy. With different bit
depths, the server would have to figure out how to translate one to the
other (and there's no obviously right way to do that). So X just doesn't
let you do that normally (at least not with XCopyArea() which is the
gdk_draw_pixmap() underlying function).
There is an XCopyPlane() function which does what you want, and in gdk.h
there's a gdk_draw_bitmap() which is probably supposed to wrap it, but
gdk_draw_bitmap() isn't implemented. :-( Check the man page for
XCopyPlane() for more info.
Anyway one workaround is suggested in the XCopyPlane() man page:
- Draw a rectangle with the stipple set to your bitmap
and another is:
- Draw the foreground you want in a big rectangle, set the bitmap
as a clip mask, then draw your background (the background won't
obscure the foreground in the clip area).
and another:
- Implement gdk_draw_bitmap() yourself for now, just copy
gdk_draw_pixmap() but use XCopyPlane()
and in Gdk 1.4:
- Use gdk_draw_bitmap()
HTH,
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]