Load and Display an Image
The Filters sample is a fully functional Motif-based GUI sample that demonstrates all major operations that can be accomplished using ImageGear. This section provides information about how to display an image with the most common parameters by invoking just two ImageGear functions.
Although all ImageGear functions are based on pure Xlib and XToolkit capabilities and do not require additional libraries, the Filters sample uses Motif 1.2 libraries to demonstrate several advanced ImageGear functions. Motif can be found at http://www.opengroup.org/openmotif/.
- IG_dspl_update_rect_set() specifies the rectangular area of a window to be repainted
- IG_dspl_image_draw() draws the images according to currently set display parameters. These parameters allow you to set various geometric and orientation layouts as well as perform image anti-aliasing, dithering, transparency, and gamma correction.
According to the Motif programming concept, a Callback function, wndDrawImage_callback, in the filters.c module is called every time a window must be updated. The IG_dspl_update_rect_set() function passes a pointer to a structure with information that is part of the window to ImageGear. After that, IG_dspl_image_draw() should be called to make the actual drawing in this area.
The following is a segment from the filters.c module that demonstrates this:
|
Copy Code
|
void wndDrawImage_callback( Widget w, XtPointer data, XtPointer call_data )
{
XmDrawingAreaCallbackStruct*cbs =
(XmDrawingAreaCallbackStruct*)call_data;
XExposeEvent*event = (XExposeEvent*)cbs->event;
AT_RECTANGLE UpdateRect;
...
/* Redisplay only on last event of the series */
if( IG_image_is_valid( hIGear ) )
{
/* Set the dirty rectangle for repaint */
UpdateRect.x = event->x;
UpdateRect.y = event->y;
UpdateRect.width = event->width;
UpdateRect.height = event->height;
IG_dspl_update_rect_set( hIGear, IG_GRP_DEFAULT, &UpdateRect );
/* Repaint window on expose events */
IG_dspl_image_draw( hIGear, IG_GRP_DEFAULT, XtWindow(w),
XDefaultGCOfScreen(XtScreen(w)), NULL );
}
...
}
|