+#ifdef HAVE_XSHM_EXTENSION
+ pBumps->bUseShm = get_boolean_resource(dpy, "useSHM", "Boolean" );
+
+ if( pBumps->bUseShm )
+ {
+ pBumps->pXImage = create_xshm_image( pBumps->dpy, XWinAttribs.visual, XWinAttribs.depth,
+ ZPixmap, NULL, &pBumps->XShmInfo, iDiameter, iDiameter );
+ if( !pBumps->pXImage )
+ {
+ fprintf( stderr, "%s: Unable to create XShmImage.\n", progname );
+ pBumps->bUseShm = False;
+ }
+ }
+#endif /* HAVE_XSHM_EXTENSION */
+ if( !pBumps->pXImage )
+ {
+ pBumps->pXImage = XCreateImage( pBumps->dpy, XWinAttribs.visual, XWinAttribs.depth,
+ ZPixmap, 0, NULL, iDiameter, iDiameter, BitmapPad( pBumps->dpy ), 0 );
+ pBumps->pXImage->data = malloc( pBumps->pXImage->bytes_per_line * pBumps->pXImage->height * sizeof(int8_) );
+ }
+
+ /* For speed, access the XImage data directly using my own PutPixel routine. */
+ switch( pBumps->pXImage->bits_per_pixel )
+ {
+ case 32:
+ pBumps->bytesPerPixel = 4;
+ MyPutPixel = PutPixel32;
+ break;
+
+ case 24:
+ pBumps->bytesPerPixel = 3;
+ MyPutPixel = PutPixel24;
+ break;
+
+ case 16:
+ pBumps->bytesPerPixel = 2;
+ MyPutPixel = PutPixel16;
+ break;
+
+ case 8:
+ pBumps->bytesPerPixel = 1;
+ MyPutPixel = PutPixel8;
+ break;
+
+ default:
+ fprintf( stderr, "%s: Unknown XImage depth.", progname );
+#ifdef HAVE_XSHM_EXTENSION
+ if( pBumps->bUseShm )
+ destroy_xshm_image( pBumps->dpy, pBumps->pXImage, &pBumps->XShmInfo );
+ else
+#endif /* HAVE_XSHM_EXTENSION */
+ XDestroyImage( pBumps->pXImage );
+ exit( 1 );
+ }
+