Back to index

radiance  4R0+20100331
Classes | Defines | Functions
x11raster.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  XRASTER

Defines

#define put_raster(d, xdst, ydst, xr)

Functions

Colormap newcmap (Display *disp, int scrn, Visual *vis)
int init_rcolors (XRASTER *xr, BYTE cmap[][3])
unsigned long * map_rcolors (XRASTER *xr, Window w)
Pixmap make_rpixmap (XRASTER *xr, Window w)
XRASTERmake_raster (Display *disp, XVisualInfo *vis, int npixbits, char *data, int width, int height, int bm_pad)
void patch_raster (Drawable d, int xsrc, int ysrc, int xdst, int ydst, int width, int height, register XRASTER *xr)
void unmap_rcolors (XRASTER *xr)
void free_rpixmap (XRASTER *xr)
void free_raster (XRASTER *xr)

Class Documentation

struct XRASTER

Definition at line 15 of file x11raster.h.

Class Members
XColor * cdefs
Colormap cmap
Display * disp
GC gc
XImage * image
int ncolors
unsigned long * pixels
Pixmap pm
short * pmap
int screen
Visual * visual

Define Documentation

#define put_raster (   d,
  xdst,
  ydst,
  xr 
)
Value:
patch_raster(d,0,0,xdst,ydst, \
                            (xr)->image->width,(xr)->image->height,xr)

Definition at line 41 of file x11raster.h.


Function Documentation

void free_raster ( XRASTER xr)
void free_rpixmap ( XRASTER xr)
int init_rcolors ( XRASTER xr,
BYTE  cmap[][3] 
)
XRASTER* make_raster ( Display *  disp,
XVisualInfo *  vis,
int  npixbits,
char *  data,
int  width,
int  height,
int  bm_pad 
)

Definition at line 19 of file x11raster.c.

{
       static long   swaptest = 1;
       register XRASTER     *xr;

       if ((xr = (XRASTER *)calloc(1, sizeof(XRASTER))) == NULL)
              return(NULL);
       xr->disp = disp;
       xr->screen = vis->screen;
       xr->visual = vis->visual;
       if (npixbits == 1)
              xr->image = XCreateImage(disp,vis->visual,1,
                            XYBitmap,0,data,width,height,bm_pad,0);
       else
              xr->image = XCreateImage(disp,vis->visual,vis->depth,
                            ZPixmap,0,data,width,height,bm_pad,0);
       xr->image->bitmap_bit_order = MSBFirst;
       xr->image->bitmap_unit = bm_pad;
       xr->image->byte_order = *(char *)&swaptest ? LSBFirst : MSBFirst;
       if (vis->depth >= 24 && (xr->image->red_mask != 0xff ||
                     xr->image->green_mask != 0xff00 ||
                     xr->image->blue_mask != 0xff0000) &&
                     (xr->image->red_mask != 0xff0000 ||
                     xr->image->green_mask != 0xff00 ||
                     xr->image->blue_mask != 0xff)) {
              xr->image->red_mask = 0xff;
              xr->image->green_mask = 0xff00;
              xr->image->blue_mask = 0xff0000;
       }
       xr->gc = 0;
       return(xr);
}

Here is the caller graph for this function:

Pixmap make_rpixmap ( XRASTER xr,
Window  w 
)
unsigned long* map_rcolors ( XRASTER xr,
Window  w 
)
Colormap newcmap ( Display *  disp,
int  scrn,
Visual *  vis 
)

Definition at line 100 of file x11raster.c.

{
       XColor thiscolor;
       unsigned long *pixels;
       Colormap      cmap;
       int    n;
       register int  i, j;

       cmap = XCreateColormap(disp, RootWindow(disp,scrn), vis, AllocNone);
       if (cmap == 0 || vis->class != PseudoColor)
              return(cmap);
       pixels=(unsigned long *)malloc(vis->map_entries*sizeof(unsigned long));
       if (pixels == NULL)
              return(0);
       for (n = vis->map_entries; n > 0; n--)
              if (XAllocColorCells(disp, cmap, 0, NULL, 0, pixels, n) != 0)
                     break;
       if (n == 0)
              return(0);
                                   /* reset black and white */
       for (i = 0; i < n; i++) {
              if (pixels[i] != BlackPixel(disp,scrn)
                            && pixels[i] != WhitePixel(disp,scrn))
                     continue;
              thiscolor.pixel = pixels[i];
              thiscolor.flags = DoRed|DoGreen|DoBlue;
              XQueryColor(disp, DefaultColormap(disp,scrn), &thiscolor);
              XStoreColor(disp, cmap, &thiscolor);
              for (j = i; j+1 < n; j++)
                     pixels[j] = pixels[j+1];
              n--;
              i--;
       }
       XFreeColors(disp, cmap, pixels, n, 0);
       free((void *)pixels);
       return(cmap);
}

Here is the caller graph for this function:

void patch_raster ( Drawable  d,
int  xsrc,
int  ysrc,
int  xdst,
int  ydst,
int  width,
int  height,
register XRASTER xr 
)

Definition at line 216 of file x11raster.c.

{
       if (xsrc >= xr->image->width || ysrc >= xr->image->height)
              return;
       if (xsrc < 0) {
              xdst -= xsrc; width += xsrc;
              xsrc = 0;
       }
       if (ysrc < 0) {
              ydst -= ysrc; height += ysrc;
              ysrc = 0;
       }
       if (width <= 0 || height <= 0)
              return;
       if (xsrc + width > xr->image->width)
              width = xr->image->width - xsrc;
       if (ysrc + height > xr->image->height)
              height = xr->image->height - ysrc;

       if (xr->gc == 0) {
              xr->gc = XCreateGC(xr->disp, d, 0, 0);
              XSetState(xr->disp, xr->gc, BlackPixel(xr->disp,xr->screen),
                     WhitePixel(xr->disp,xr->screen), GXcopy, AllPlanes);
       }
       if (xr->pm == 0)
              XPutImage(xr->disp, d, xr->gc, xr->image, xsrc, ysrc,
                            xdst, ydst, width, height);
       else
              XCopyArea(xr->disp, xr->pm, d, xr->gc, xsrc, ysrc,
                            width, height, xdst, ydst);
}
void unmap_rcolors ( XRASTER xr)