#include "ImageDisplay.h" class ImageDisplay { ... public: // constructor ImageDisplay(Display *display, Visual *visual, GC gc, int depth, int useXShm, int verbose); // destructor ~ImageDisplay(); // create or update an XImage with the given size int update(int width, int height); // copy the XImage to a Drawable in the X Server void put(Drawable, int src_x, int src_y, int dest_x, int dest_y, int width, int height); // return a pointer to the XImage data unsigned char* data(); // inline query methods int width(); int height(); int bitmapPad(); int bytesPerLine(); // return true if we are really using X shared memory int usingXShm(); };
This class manages the creation, display and disposal of an XImage, optionally using X shared memory, if available.
The constructor takes as arguments: the X display, visual, GC and image depth, all for later reference in X calls. In addition, 2 flags may be specified: "useXshm" is set to true if X shared memory should be tried for and "verbose" is set to true if diagnostic messages should be printed out at run time.
There are two main methods. One to create or update an XImage and one to copy it to the X server: int update(int width, int height) Create or update the XImage so that it has the given width and height, using X shared memory, if applicable. void put(Drawable d, int src_x, int src_y, int dest_x, int dest_y, int width, int height) Copy the contents of the XImage to the given drawable with the given arguments, using X shared memory, if applicable. In addition, there are inline methods defined to query the XImage width and height, bytes per line and padding. Note: always use "bytesPerLine()" rather than width() in calculations, since padding in X shared memory can make the two different.
Please send questions or comments to abrighto@eso.org.
Copyright © 1998 ESO - European Southern Observatory