Back to index

plt-scheme  4.2.1
Classes | Defines | Functions | Variables
scan.c File Reference
#include "xpmP.h"

Go to the source code of this file.

Classes

struct  PixelsMap

Defines

#define MAXPRINTABLE
#define RETURN(status)

Functions

 LFUNC (storePixel, int,(Pixel pixel, PixelsMap *pmap, unsigned int *index_return))
 LFUNC (storeMaskPixel, int,(Pixel pixel, PixelsMap *pmap, unsigned int *index_return))
 LFUNC (GetImagePixels, int,(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap))
 LFUNC (GetImagePixels32, int,(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap))
 LFUNC (GetImagePixels16, int,(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap))
 LFUNC (GetImagePixels8, int,(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap))
 LFUNC (GetImagePixels1, int,(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap, int(*storeFunc)()))
 LFUNC (ScanTransparentColor, int,(XpmColor *color, unsigned int cpp, XpmAttributes *attributes))
 LFUNC (ScanOtherColors, int,(Display *display, XpmColor *colors, int ncolors, Pixel *pixels, unsigned int mask, unsigned int cpp, XpmAttributes *attributes))
static int storePixel (Pixel pixel, PixelsMap *pmap, unsigned int *index_return)
static int storeMaskPixel (Pixel pixel, PixelsMap *pmap, unsigned int *index_return)
int XpmCreateXpmImageFromImage (Display *display, XImage *image, XImage *shapeimage, XpmImage *xpmimage, XpmAttributes *attributes)
static int ScanTransparentColor (XpmColor *color, unsigned int cpp, XpmAttributes *attributes)
static int ScanOtherColors (Display *display, XpmColor *colors, int ncolors, Pixel *pixels, unsigned int mask, unsigned int cpp, XpmAttributes *attributes)
static int GetImagePixels (XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)
static int GetImagePixels32 (XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)
static int GetImagePixels16 (XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)
static int GetImagePixels8 (XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)
static int GetImagePixels1 (XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap, int(*)() storeFunc)
int XpmCreateXpmImageFromPixmap (Display *display, Pixmap pixmap, Pixmap shapemask, XpmImage *xpmimage, XpmAttributes *attributes)

Variables

static char * printable
static unsigned long Const low_bits_table []
static unsigned long byteorderpixel = MSBFirst << 24

Class Documentation

struct PixelsMap

Definition at line 55 of file scan.c.

Class Members
unsigned int mask_pixel
unsigned int ncolors
unsigned int * pixelindex
Pixel * pixels
unsigned int size

Define Documentation

#define MAXPRINTABLE
Value:
92                   /* number of printable ascii chars
                                    * minus \ and " for string compat
                                    * and ? to avoid ANSI trigraphs. */

Definition at line 42 of file scan.c.

#define RETURN (   status)
Value:
{ \
    if (pmap.pixelindex) XpmFree(pmap.pixelindex); \
    if (pmap.pixels) XpmFree(pmap.pixels); \
    if (colorTable) xpmFreeColorTable(colorTable, pmap.ncolors); \
    return(status); \
}

Definition at line 155 of file scan.c.


Function Documentation

static int GetImagePixels ( XImage *  image,
unsigned int  width,
unsigned int  height,
PixelsMap pmap 
) [static]

Definition at line 567 of file scan.c.

{
    char *src;
    char *dst;
    unsigned int *iptr;
    char *data;
    int x, y, i;
    int bits, depth, ibu, ibpp, offset;
    unsigned long lbt;
    Pixel pixel, px;

    data = image->data;
    iptr = pmap->pixelindex;
    depth = image->depth;
    lbt = low_bits_table[depth];
    ibpp = image->bits_per_pixel;
    offset = image->xoffset;

    if ((image->bits_per_pixel | image->depth) == 1) {
       ibu = image->bitmap_unit;
       for (y = 0; y < height; y++)
           for (x = 0; x < width; x++, iptr++) {
              src = &data[XYINDEX(x, y, image)];
              dst = (char *) &pixel;
              pixel = 0;
              for (i = ibu >> 3; --i >= 0;)
                  *dst++ = *src++;
              XYNORMALIZE(&pixel, image);
              bits = (x + offset) % ibu;
              pixel = ((((char *) &pixel)[bits >> 3]) >> (bits & 7)) & 1;
              if (ibpp != depth)
                  pixel &= lbt;
              if (storePixel(pixel, pmap, iptr))
                  return (XpmNoMemory);
           }
    } else if (image->format == XYPixmap) {
       int nbytes, bpl, j;
       long plane = 0;
       ibu = image->bitmap_unit;
       nbytes = ibu >> 3;
       bpl = image->bytes_per_line;
       for (y = 0; y < height; y++)
           for (x = 0; x < width; x++, iptr++) {
              pixel = 0;
              plane = 0;
              for (i = depth; --i >= 0;) {
                  src = &data[XYINDEX(x, y, image) + plane];
                  dst = (char *) &px;
                  px = 0;
                  for (j = nbytes; --j >= 0;)
                     *dst++ = *src++;
                  XYNORMALIZE(&px, image);
                  bits = (x + offset) % ibu;
                  pixel = (pixel << 1) |
                         (((((char *) &px)[bits >> 3]) >> (bits & 7)) & 1);
                  plane = plane + (bpl * height);
              }
              if (ibpp != depth)
                  pixel &= lbt;
              if (storePixel(pixel, pmap, iptr))
                  return (XpmNoMemory);
           }
    } else if (image->format == ZPixmap) {
       for (y = 0; y < height; y++)
           for (x = 0; x < width; x++, iptr++) {
              src = &data[ZINDEX(x, y, image)];
              dst = (char *) &px;
              px = 0;
              for (i = (ibpp + 7) >> 3; --i >= 0;)
                  *dst++ = *src++;
              ZNORMALIZE(&px, image);
              pixel = 0;
              for (i = sizeof(unsigned long); --i >= 0;)
                  pixel = (pixel << 8) | ((unsigned char *) &px)[i];
              if (ibpp == 4) {
                  if (x & 1)
                     pixel >>= 4;
                  else
                     pixel &= 0xf;
              }
              if (ibpp != depth)
                  pixel &= lbt;
              if (storePixel(pixel, pmap, iptr))
                  return (XpmNoMemory);
           }
    } else
       return (XpmColorError); /* actually a bad image */

Here is the call graph for this function:

Here is the caller graph for this function:

static int GetImagePixels1 ( XImage *  image,
unsigned int  width,
unsigned int  height,
PixelsMap pmap,
int (*) ()  storeFunc 
) [static]

Definition at line 814 of file scan.c.

{
    unsigned int *iptr;
    int x, y;
    char *data;
    Pixel pixel;
    int xoff, yoff, offset, bpl;

    data = image->data;
    iptr = pmap->pixelindex;
    offset = image->xoffset;
    bpl = image->bytes_per_line;

    if (image->bitmap_bit_order == MSBFirst)
       for (y = 0; y < height; y++)
           for (x = 0; x < width; x++, iptr++) {
              xoff = x + offset;
              yoff = y * bpl + (xoff >> 3);
              xoff &= 7;
              pixel = (data[yoff] & (0x80 >> xoff)) ? 1 : 0;
              if ((*storeFunc) (pixel, pmap, iptr))
                  return (XpmNoMemory);
           }
    else
       for (y = 0; y < height; y++)
           for (x = 0; x < width; x++, iptr++) {
              xoff = x + offset;
              yoff = y * bpl + (xoff >> 3);
              xoff &= 7;
              pixel = (data[yoff] & (1 << xoff)) ? 1 : 0;
              if ((*storeFunc) (pixel, pmap, iptr))
                  return (XpmNoMemory);
           }

Here is the caller graph for this function:

static int GetImagePixels16 ( XImage *  image,
unsigned int  width,
unsigned int  height,
PixelsMap pmap 
) [static]

Definition at line 735 of file scan.c.

{
    unsigned char *addr;
    unsigned char *data;
    unsigned int *iptr;
    int x, y;
    unsigned long lbt;
    Pixel pixel;
    int depth;

    data = (unsigned char *) image->data;
    iptr = pmap->pixelindex;
    depth = image->depth;
    lbt = low_bits_table[depth];
    if (image->byte_order == MSBFirst)
       for (y = 0; y < height; y++)
           for (x = 0; x < width; x++, iptr++) {
              addr = &data[ZINDEX16(x, y, image)];
              pixel = addr[0] << 8 | addr[1];
              if (depth != 16)
                  pixel &= lbt;
              if (storePixel(pixel, pmap, iptr))
                  return (XpmNoMemory);
           }
    else
       for (y = 0; y < height; y++)
           for (x = 0; x < width; x++, iptr++) {
              addr = &data[ZINDEX16(x, y, image)];
              pixel = addr[0] | addr[1] << 8;
              if (depth != 16)
                  pixel &= lbt;
              if (storePixel(pixel, pmap, iptr))
                  return (XpmNoMemory);
           }

Here is the call graph for this function:

Here is the caller graph for this function:

static int GetImagePixels32 ( XImage *  image,
unsigned int  width,
unsigned int  height,
PixelsMap pmap 
) [static]

Definition at line 670 of file scan.c.

{
    unsigned char *addr;
    unsigned char *data;
    unsigned int *iptr;
    int x, y;
    unsigned long lbt;
    Pixel pixel;
    int depth;

    data = (unsigned char *) image->data;
    iptr = pmap->pixelindex;
    depth = image->depth;
    lbt = low_bits_table[depth];
#if !defined(WORD64) && !defined(LONG64)
    if (*((char *) &byteorderpixel) == image->byte_order) {
       for (y = 0; y < height; y++)
           for (x = 0; x < width; x++, iptr++) {
              addr = &data[ZINDEX32(x, y, image)];
              pixel = *((unsigned long *) addr);
              if (depth != 32)
                  pixel &= lbt;
              if (storePixel(pixel, pmap, iptr))
                  return (XpmNoMemory);
           }
    } else
#endif
    if (image->byte_order == MSBFirst)
       for (y = 0; y < height; y++)
           for (x = 0; x < width; x++, iptr++) {
              addr = &data[ZINDEX32(x, y, image)];
              pixel = ((unsigned long) addr[0] << 24 |
                      (unsigned long) addr[1] << 16 |
                      (unsigned long) addr[2] << 8 |
                      (unsigned long) addr[3]);
              if (depth != 32)
                  pixel &= lbt;
              if (storePixel(pixel, pmap, iptr))
                  return (XpmNoMemory);
           }
    else
       for (y = 0; y < height; y++)
           for (x = 0; x < width; x++, iptr++) {
              addr = &data[ZINDEX32(x, y, image)];
              pixel = (addr[0] |
                      (unsigned long) addr[1] << 8 |
                      (unsigned long) addr[2] << 16 |
                      (unsigned long) addr[3] << 24);
              if (depth != 32)
                  pixel &= lbt;
              if (storePixel(pixel, pmap, iptr))
                  return (XpmNoMemory);
           }

Here is the call graph for this function:

Here is the caller graph for this function:

static int GetImagePixels8 ( XImage *  image,
unsigned int  width,
unsigned int  height,
PixelsMap pmap 
) [static]

Definition at line 781 of file scan.c.

{
    unsigned int *iptr;
    unsigned char *data;
    int x, y;
    unsigned long lbt;
    Pixel pixel;
    int depth;

    data = (unsigned char *) image->data;
    iptr = pmap->pixelindex;
    depth = image->depth;
    lbt = low_bits_table[depth];
    for (y = 0; y < height; y++)
       for (x = 0; x < width; x++, iptr++) {
           pixel = data[ZINDEX8(x, y, image)];
           if (depth != 8)
              pixel &= lbt;
           if (storePixel(pixel, pmap, iptr))
              return (XpmNoMemory);
       }

Here is the call graph for this function:

Here is the caller graph for this function:

LFUNC ( storePixel  ,
int  ,
(Pixel pixel, PixelsMap *pmap, unsigned int *index_return)   
)
LFUNC ( storeMaskPixel  ,
int  ,
(Pixel pixel, PixelsMap *pmap, unsigned int *index_return)   
)
LFUNC ( GetImagePixels  ,
int  ,
(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)   
)
LFUNC ( GetImagePixels32  ,
int  ,
(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)   
)
LFUNC ( GetImagePixels16  ,
int  ,
(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)   
)
LFUNC ( GetImagePixels8  ,
int  ,
(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)   
)
LFUNC ( GetImagePixels1  ,
int  ,
(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap, int(*storeFunc)())   
)
LFUNC ( ScanTransparentColor  ,
int  ,
(XpmColor *color, unsigned int cpp, XpmAttributes *attributes)   
)
LFUNC ( ScanOtherColors  ,
int  ,
(Display *display, XpmColor *colors, int ncolors, Pixel *pixels, unsigned int mask, unsigned int cpp, XpmAttributes *attributes)   
)
static int ScanOtherColors ( Display *  display,
XpmColor colors,
int  ncolors,
Pixel pixels,
unsigned int  mask,
unsigned int  cpp,
XpmAttributes attributes 
) [static]

Definition at line 368 of file scan.c.

{
    /* variables stored in the XpmAttributes structure */
    Colormap colormap;
    char *rgb_fname;

#ifndef FOR_MSW
    xpmRgbName rgbn[MAX_RGBNAMES];
#else
    xpmRgbName *rgbn = NULL; 
#endif    
    int rgbn_max = 0;
    unsigned int i, j, c, i2;
    XpmColor *color;
    XColor *xcolors = NULL, *xcolor;
    char *colorname, *s;
    XpmColor *colorTable, **oldColorTable = NULL;
    unsigned int ancolors = 0;
    Pixel *apixels;
    unsigned int mask_pixel;
    Bool found;

    /* retrieve information from the XpmAttributes */
    if (attributes && (attributes->valuemask & XpmColormap))
        colormap = attributes->colormap;
    else
        colormap = XDefaultColormap(display, XDefaultScreen(display));
    if (attributes && (attributes->valuemask & XpmRgbFilename))
       rgb_fname = attributes->rgb_fname;
    else
       rgb_fname = NULL;

    /* start from the right element */
    if (mask) {
       colors++;
       ncolors--;
       pixels++;
    }

    /* first get character strings and rgb values */
    xcolors = (XColor *) XpmMalloc(sizeof(XColor) * ncolors);
    if (!xcolors)
       return (XpmNoMemory);

    for (i = 0, i2 = mask, color = colors, xcolor = xcolors;
        i < ncolors; i++, i2++, color++, xcolor++, pixels++) {

       if (!(s = color->string = (char *) XpmMalloc(cpp + 1))) {
           XpmFree(xcolors);
           return (XpmNoMemory);
       }
       {
         int i3 = i2;
         c = i3 % MAXPRINTABLE;
         *s++ = printable[c];
         for (j = 1; j < cpp; j++, s++) {
           i3 = (i3 - c) / MAXPRINTABLE;
           c = i3 % MAXPRINTABLE;
           *s = printable[c];
         }
       }
       *s = '\0';

       xcolor->pixel = *pixels;
    }
    XQueryColors(display, colormap, xcolors, ncolors);

#ifndef FOR_MSW
    /* read the rgb file if any was specified */
    if (rgb_fname)
       rgbn_max = xpmReadRgbNames(attributes->rgb_fname, rgbn);
#else
    /* FOR_MSW: rgb names and values are hardcoded in rgbtab.h */
    rgbn_max = xpmReadRgbNames(NULL, NULL);
#endif

    if (attributes && attributes->valuemask & XpmColorTable) {
       colorTable = attributes->colorTable;
       ancolors = attributes->ncolors;
       apixels = attributes->pixels;
       mask_pixel = attributes->mask_pixel;
    }
/* 3.2 backward compatibility code */
    else if (attributes && attributes->valuemask & XpmInfos) {
       oldColorTable = (XpmColor **) attributes->colorTable;
       ancolors = attributes->ncolors;
       apixels = attributes->pixels;
       mask_pixel = attributes->mask_pixel;
    }
/* end 3.2 bc */

    for (i = 0, color = colors, xcolor = xcolors; i < ncolors;
                                            i++, color++, xcolor++) {

       /* look for related info from the attributes if any */
       found = False;
       if (ancolors) {
           unsigned int offset = 0;

           for (j = 0; j < ancolors; j++) {
              if (j == mask_pixel) {
                  offset = 1;
                  continue;
              }
              if (apixels[j - offset] == xcolor->pixel)
                  break;
           }
           if (j != ancolors) {
              unsigned int key;
              char **defaults = (char **) color;
              char **adefaults;

/* 3.2 backward compatibility code */
              if (oldColorTable)
                  adefaults = (char **) oldColorTable[j];
              else
/* end 3.2 bc */
                  adefaults = (char **) (colorTable + j);

              found = True;
              for (key = 1; key <= NKEYS; key++) {
                  if (s = adefaults[key])
                     defaults[key] = (char *) strdup(s);
              }
           }
       }
       if (!found) {
           /* if nothing found look for a color name */
           colorname = NULL;
           if (rgbn_max)
              colorname = xpmGetRgbName(rgbn, rgbn_max, xcolor->red,
                                     xcolor->green, xcolor->blue);
           if (colorname)
              color->c_color = (char *) strdup(colorname);
           else {
              /* at last store the rgb value */
              char buf[BUFSIZ];
#ifndef FOR_MSW
              sprintf(buf, "#%04X%04X%04X",
                     xcolor->red, xcolor->green, xcolor->blue);
#else   
              sprintf(buf, "#%02x%02x%02x",
                     xcolor->red, xcolor->green, xcolor->blue);
#endif               
              color->c_color = (char *) strdup(buf);
           }
           if (!color->c_color) {
              XpmFree(xcolors);
              xpmFreeRgbNames(rgbn, rgbn_max);
              return (XpmNoMemory);
           }
       }
    }

    XpmFree(xcolors);
    xpmFreeRgbNames(rgbn, rgbn_max);

Here is the call graph for this function:

Here is the caller graph for this function:

static int ScanTransparentColor ( XpmColor color,
unsigned int  cpp,
XpmAttributes attributes 
) [static]

Definition at line 315 of file scan.c.

{
    char *s;
    unsigned int b;

    /* first get a character string */
    if (!(s = color->string = (char *) XpmMalloc(cpp + 1)))
       return (XpmNoMemory);
    *s++ = printable[0];
    for (b = 1; b < cpp; b++, s++)
       *s = printable[0];
    *s = '\0';

    /* then retreive related info from the attributes if any */
    if (attributes && (attributes->valuemask & XpmColorTable
/* 3.2 backward compatibility code */
                     || attributes->valuemask & XpmInfos)
/* end 3.2 bc */
       && attributes->mask_pixel != XpmUndefPixel) {

       unsigned int key;
       char **defaults = (char **) color;
       char **mask_defaults;

/* 3.2 backward compatibility code */
       if (attributes->valuemask & XpmColorTable)
/* end 3.2 bc */
           mask_defaults = (char **) (
              attributes->colorTable + attributes->mask_pixel);
/* 3.2 backward compatibility code */
       else
           mask_defaults = (char **)
              ((XpmColor **) attributes->colorTable)[attributes->mask_pixel];
/* end 3.2 bc */
       for (key = 1; key <= NKEYS; key++) {
           if (s = mask_defaults[key]) {
              defaults[key] = (char *) strdup(s);
              if (!defaults[key])
                  return (XpmNoMemory);
           }
       }
    } else {
       color->c_color = (char *) strdup(TRANSPARENT_COLOR);
       if (!color->c_color)
           return (XpmNoMemory);
    }

Here is the caller graph for this function:

static int storeMaskPixel ( Pixel  pixel,
PixelsMap pmap,
unsigned int index_return 
) [static]

Definition at line 136 of file scan.c.

{
    if (!pixel) {
       if (!pmap->ncolors) {
           pmap->ncolors = 1;
           (pmap->pixels)[0] = 0;
           pmap->mask_pixel = 1;
       }
       *index_return = 1;
    } else
       *index_return = 0;

Here is the caller graph for this function:

static int storePixel ( Pixel  pixel,
PixelsMap pmap,
unsigned int index_return 
) [static]

Definition at line 101 of file scan.c.

{
    unsigned int i;
    Pixel *p;
    unsigned int ncolors;

    if (*index_return) {           /* this is a transparent pixel! */
       *index_return = 0;
       return 0;
    }
    ncolors = pmap->ncolors;
    p = pmap->pixels + pmap->mask_pixel;
    for (i = pmap->mask_pixel; i < ncolors; i++, p++)
       if (*p == pixel)
           break;
    if (i == ncolors) {
       if (ncolors >= pmap->size) {
           pmap->size *= 2;
           p = (Pixel *) XpmRealloc(pmap->pixels, sizeof(Pixel) * pmap->size);
           if (!p)
              return (1);
           pmap->pixels = p;

       }
       (pmap->pixels)[ncolors] = pixel;
       pmap->ncolors++;
    }
    *index_return = i;

Here is the caller graph for this function:

int XpmCreateXpmImageFromImage ( Display *  display,
XImage *  image,
XImage *  shapeimage,
XpmImage xpmimage,
XpmAttributes attributes 
)

Definition at line 168 of file scan.c.

{
    /* variables stored in the XpmAttributes structure */
    unsigned int cpp;

    /* variables to return */
    PixelsMap pmap;
    XpmColor *colorTable = NULL;
    int ErrorStatus;

    /* calculation variables */
    unsigned int width = 0;
    unsigned int height = 0;
    unsigned int cppm;                    /* minimum chars per pixel */
    unsigned int c;

    /* initialize pmap */
    pmap.pixels = NULL;
    pmap.pixelindex = NULL;
    pmap.size = 256;               /* should be enough most of the time */
    pmap.ncolors = 0;
    pmap.mask_pixel = 0;

    /*
     * get geometry
     */
    if (image) {
       width = image->width;
       height = image->height;
    } else if (shapeimage) {
       width = shapeimage->width;
       height = shapeimage->height;
    }

    /*
     * retrieve information from the XpmAttributes
     */
    if (attributes && (attributes->valuemask & XpmCharsPerPixel
/* 3.2 backward compatibility code */
                     || attributes->valuemask & XpmInfos))
/* end 3.2 bc */
       cpp = attributes->cpp;
    else
       cpp = 0;

    pmap.pixelindex =
       (unsigned int *) XpmCalloc(width * height, sizeof(unsigned int));
    if (!pmap.pixelindex)
       RETURN(XpmNoMemory);

    pmap.pixels = (Pixel *) XpmMalloc(sizeof(Pixel) * pmap.size);
    if (!pmap.pixels)
       RETURN(XpmNoMemory);

    /*
     * scan shape mask if any
     */
    if (shapeimage) {
#ifndef FOR_MSW
       ErrorStatus = GetImagePixels1(shapeimage, width, height, &pmap,
                                  storeMaskPixel);
#else
       ErrorStatus = MSWGetImagePixels(display, shapeimage, width, height,
                                   &pmap, storeMaskPixel);
#endif
       if (ErrorStatus != XpmSuccess)
           RETURN(ErrorStatus);
    }

    /*
     * scan the image data
     * 
     * In case depth is 1 or bits_per_pixel is 4, 6, 8, 24 or 32 use optimized
     * functions, otherwise use slower but sure general one.
     * 
     */

    if (image) {
#ifndef FOR_MSW
       if (((image->bits_per_pixel | image->depth) == 1)  &&
           (image->byte_order == image->bitmap_bit_order))
           ErrorStatus = GetImagePixels1(image, width, height, &pmap,
                                     storePixel);
       else if (image->format == ZPixmap) {
           if (image->bits_per_pixel == 8)
              ErrorStatus = GetImagePixels8(image, width, height, &pmap);
           else if (image->bits_per_pixel == 16)
              ErrorStatus = GetImagePixels16(image, width, height, &pmap);
           else if (image->bits_per_pixel == 32)
              ErrorStatus = GetImagePixels32(image, width, height, &pmap);
       } else
           ErrorStatus = GetImagePixels(image, width, height, &pmap);
#else                              /* FOR_MSW */
       ErrorStatus = MSWGetImagePixels(display, image, width, height, &pmap);
#endif
       if (ErrorStatus != XpmSuccess)
           RETURN(ErrorStatus);
    }

    /*
     * get rgb values and a string of char, and possibly a name for each
     * color
     */

    colorTable = (XpmColor *) XpmCalloc(pmap.ncolors, sizeof(XpmColor));
    if (!colorTable)
       RETURN(XpmNoMemory);

    /* compute the minimal cpp */
    for (cppm = 1, c = MAXPRINTABLE; pmap.ncolors > c; cppm++)
       c *= MAXPRINTABLE;
    if (cpp < cppm)
       cpp = cppm;

    if (pmap.mask_pixel) {
       ErrorStatus = ScanTransparentColor(colorTable, cpp, attributes);
       if (ErrorStatus != XpmSuccess)
           RETURN(ErrorStatus);
    }

    ErrorStatus = ScanOtherColors(display, colorTable, pmap.ncolors,
                              pmap.pixels, pmap.mask_pixel, cpp,
                              attributes);
    if (ErrorStatus != XpmSuccess)
       RETURN(ErrorStatus);

    /*
     * store found informations in the XpmImage structure
     */
    xpmimage->width = width;
    xpmimage->height = height;
    xpmimage->cpp = cpp;
    xpmimage->ncolors = pmap.ncolors;
    xpmimage->colorTable = colorTable;
    xpmimage->data = pmap.pixelindex;

    XpmFree(pmap.pixels);

Here is the call graph for this function:

Here is the caller graph for this function:

int XpmCreateXpmImageFromPixmap ( Display *  display,
Pixmap  pixmap,
Pixmap  shapemask,
XpmImage xpmimage,
XpmAttributes attributes 
)

Definition at line 886 of file scan.c.

{
    XImage *ximage = NULL;
    XImage *shapeimage = NULL;
    unsigned int width = 0;
    unsigned int height = 0;
    int ErrorStatus;

    /* get geometry */
    if (attributes && attributes->valuemask & XpmSize) {
       width = attributes->width;
       height = attributes->height;
    }
    /* get the ximages */
    if (pixmap)
       xpmCreateImageFromPixmap(display, pixmap, &ximage, &width, &height);
    if (shapemask)
       xpmCreateImageFromPixmap(display, shapemask, &shapeimage,
                             &width, &height);

    /* create the related XpmImage */
    ErrorStatus = XpmCreateXpmImageFromImage(display, ximage, shapeimage,
                                        xpmimage, attributes);

    /* destroy the ximages */
    if (ximage)
       XDestroyImage(ximage);
    if (shapeimage)
       XDestroyImage(shapeimage);

Here is the call graph for this function:


Variable Documentation

unsigned long byteorderpixel = MSBFirst << 24 [static]

Definition at line 666 of file scan.c.

unsigned long Const low_bits_table[] [static]
Initial value:
 {
    0x00000000, 0x00000001, 0x00000003, 0x00000007,
    0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
    0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
    0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
    0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
    0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
    0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
    0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
    0xffffffff
}

Definition at line 544 of file scan.c.

char* printable [static]
Initial value:
" .XoO+@#$%&*=-;:>,<1234567890qwertyuipasdfghjklzxcvbnmMNBVCZ\
ASDFGHJKLPIUYTREWQ!~^/()_`'][{}|"

Definition at line 44 of file scan.c.