[comp.windows.x] How do you draw a bitmap into a window?

mikeh@fsd.cpsc.ucalgary.ca (Michael Hoffos) (05/08/91)

This may be a stupid question, but what is the magic to putting a bitmap
into a window?  I made a window with XCreateSimpleWindow, used
XCreateBitmapFromData to make the bitmap, and then realized I have *no*
idea where to go from here!

The code is going to be used to display bitmaps that are generated by
a contour tracing program (which is already written).

I would appreciate any help/suggestions/code that any of you can pass along.

Mike Hoffos

erc@pai.UUCP (Eric F. Johnson) (05/09/91)

>This may be a stupid question, but what is the magic to putting a bitmap
>into a window?  I made a window with XCreateSimpleWindow, used
>XCreateBitmapFromData to make the bitmap, and then realized I have *no*
>idea where to go from here!

>Mike Hoffos (mikeh@fsd.cpsc.ucalgary.ca)

In X jargon...
You want to copy the contents of one drawable (your bitmap) to another
drawable (your window). Bitmaps are really single-plane pixmaps, by 
the way.

So, look up XCopyPlane():

XCopyPlane( display, src_drawable, dest_drawable, gc, src_x, src_y,
   width, height, dest_x, dest_y, bitplane )

Where     src_drawable     is your bitmap
          dest_drawable    is your window
          src_x, src_y     are 0,0 (assuming you want to draw the 
                           entire bitmap)
          width, height    are the size of your bitmap (ditto)
          dest_x, dest_y   is where you want the bitmap to appear in 
                           the window 
          bitplane         is 0x01 since bitmaps are really pixmaps that
                           have ONE bitplane (they are one-bit deep).

For more information on this, look up pages 312-314 in _X Window
Applications Programming_ (1989, MIS: Press, ISBN 1-55828-016-2).

Hope this helps,
-Eric

-- 
Eric F. Johnson               phone: +1 612 894 0313    BTI: Industrial
Boulware Technologies, Inc.   fax:   +1 612 894 0316    automation systems
415 W. Travelers Trail        email: erc@pai.mn.org     and services
Burnsville, MN 55337 USA