Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

xxx.c

Go to the documentation of this file.
00001 
00002 /*-------------------------------------------------------------------------
00003    Return an array of XColor that define the colormap for the given
00004    window.  This only works for PseudoColor visuals..
00005 ---------------------------------------------------------------------------*/
00006 
00007 void xxx_get_colormap( Display * display , Window w , XColor ** xcar , int * ncar )
00008 {
00009    Status sss ;
00010    XWindowAttributes xwat ;
00011    XColor * xcol ;
00012    VisualID vid ;
00013    XVisualInfo vinfo , * vin ;
00014    int count , ii ;
00015 
00016    sss = XGetWindowAttributes( display , w , &xwat ) ;
00017    if( sss == 0 ){ *xcar = NULL ; *ncar = 0 ; return ; }
00018 
00019    vinfo.visualid = vid = XVisualIDFromVisual(xwat.visual) ;
00020    vin = XGetVisualInfo( display , VisualIDMask , &vinfo , &count ) ;
00021    if( count == 0 || vin == NULL ){ *xcar = NULL ; *ncar = 0 ; return ; }
00022 
00023 #if defined(__cplusplus) || defined(c_plusplus)
00024    if( vin->c_class != PseudoColor ){ XFree(vin) ; *xcar = NULL ; *ncar = 0 ; return ; }
00025 #else
00026    if( vin->class != PseudoColor ){ XFree(vin) ; *xcar = NULL ; *ncar = 0 ; return ; }
00027 #endif
00028 
00029    count = vin->colormap_size ;
00030    xcol  = (XColor *) malloc( sizefo(XColor) * count ) ;
00031    for( ii=0 ; ii < count ; ii++ ) xcol[ii].pixel = (Pixel) ii ;
00032 
00033    XQueryColors( display , xwat.colormap , xcol , count ) ;
00034 
00035    fprintf(stderr,"xxx_get_colormap: found %d colors:\n",count) ;
00036    for( ii=0 ; ii < count ; ii++ )
00037       fprintf(stderr,"  %3d: r = %x  g = %x  b = %x\n" ,
00038               ii , (int)xcol[ii].red , (int)xcol[ii].green , (int)xcol[ii].blue ) ;
00039 
00040    *xcar = xcol ; *ncar = count ; XFree(vin) ; return ;
00041 }
 

Powered by Plone

This site conforms to the following standards: