diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-06-28 17:29:32 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-06-28 17:29:32 +0000 |
commit | 23ce26f64c34e30951ad9ade2151552ed77e7357 (patch) | |
tree | d73b31a0c2f7c7be4a69f8a8e84e00dd39c432b5 /converter/other/pamtogif.c | |
parent | 1b6e51a266008348ad93ed8b6ac9ec91b5024fea (diff) | |
download | netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.tar.gz netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.tar.xz netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.zip |
promote Advanced to Stable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@4558 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other/pamtogif.c')
-rw-r--r-- | converter/other/pamtogif.c | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/converter/other/pamtogif.c b/converter/other/pamtogif.c index 022b7343..341c9c03 100644 --- a/converter/other/pamtogif.c +++ b/converter/other/pamtogif.c @@ -19,15 +19,14 @@ #define MAXCMAPSIZE 256 -static unsigned int const gifMaxval = 255; - static bool verbose; enum TransparencyType {TRANS_NONE, TRANS_COLOR, TRANS_ALPHA}; - // The source of transparency for the GIF: nothing is transparent, - // All pixels of a certain color are transparent, or the alpha plane - // in the input tells what is transparent. + /* The source of transparency for the GIF: nothing is transparent, + All pixels of a certain color are transparent, or the alpha plane + in the input tells what is transparent. + */ typedef unsigned int StringCode; /* A code to be place in the GIF raster. It represents @@ -813,7 +812,7 @@ typedef struct { */ bool lzw; /* We're actually doing LZW compression. False means we follow - the algorithm enough tht an LZW decompressor will recover the + the algorithm enough that an LZW decompressor will recover the proper data, but always using one code per pixel, and therefore not effecting any compression and not using the LZW patent. */ @@ -1676,7 +1675,7 @@ computeTransparent(enum TransparencyType const transType, case TRANS_NONE: { cmapP->haveTransparent = FALSE; } break; - } // switch + } /* switch */ reportTransparent(transType, cmapP); } @@ -1893,14 +1892,14 @@ computeColormapFromInput(struct pam * const pamP, static void -computeLibnetpbmColormap(struct pam * const pamP, - bool const haveAlpha, - const char * const mapfile, - tuple * const color, - tuplehash * const tuplehashP, - struct pam * const mapPamP, - unsigned int * const colorCountP, - bool const sort) { +computeLibnetpbmColormap(struct pam * const pamP, + enum TransparencyType const transType, + const char * const mapfile, + tuple * const color, + tuplehash * const tuplehashP, + struct pam * const mapPamP, + unsigned int * const colorCountP, + bool const sort) { /*---------------------------------------------------------------------------- Compute a colormap, libnetpbm style, for the image described by 'pamP', which is positioned to the raster. @@ -1914,21 +1913,23 @@ computeLibnetpbmColormap(struct pam * const pamP, The tuples of the color map have a meaningful depth of 1 (grayscale) or 3 (color) and *mapPamP reflects that. - While we're at it, count the colors and validate that there aren't - too many. Return the count as *colorCountP. In determining if there are - too many, allow one slot for a fake transparency color if 'haveAlpha' - is true. If there are too many, issue an error message and abort the + While we're at it, count the colors and validate that there aren't too + many. Return the count as *colorCountP. In determining if there are too + many, allow one slot for a fake transparency color if 'transType' is + 'TRANS_ALPHA'. If there are too many, issue an error message and abort the program. 'sort' means to sort the colormap by red intensity, then by green intensity, then by blue intensity, as opposed to arbitrary order. -----------------------------------------------------------------------------*/ - unsigned int const maxcolors = haveAlpha ? MAXCMAPSIZE - 1 : MAXCMAPSIZE; + unsigned int const maxcolors = + transType == TRANS_ALPHA ? MAXCMAPSIZE - 1 : MAXCMAPSIZE; /* The most colors we can tolerate in the image. If we have our own made-up entry in the colormap for transparency, it isn't included in this count. */ - unsigned int const nInputComp = haveAlpha ? pamP->depth - 1 : pamP->depth; + unsigned int const nInputComp = + pamAlphaPlane(pamP) ? pamP->depth - 1 : pamP->depth; /* Number of color components (not alpha) in the input image */ unsigned int i; @@ -2011,16 +2012,16 @@ main(int argc, char *argv[]) { pm_tell2(ifP, &rasterPos, sizeof(rasterPos)); - computeLibnetpbmColormap(&pam, !!pamAlphaPlane(&pam), cmdline.mapfile, + transType = cmdline.transparent ? TRANS_COLOR : + pamAlphaPlane(&pam) ? TRANS_ALPHA : + TRANS_NONE; + + computeLibnetpbmColormap(&pam, transType, cmdline.mapfile, cmap.color, &cmap.tuplehash, &cmap.pam, &cmap.cmapSize, cmdline.sort); assert(cmap.pam.maxval == pam.maxval); - transType = cmdline.transparent ? TRANS_COLOR : - pamAlphaPlane(&pam) ? TRANS_ALPHA : - TRANS_NONE; - if (transType == TRANS_ALPHA) { /* Add a fake entry to the end of the colormap for transparency. Make its color black. @@ -2036,7 +2037,7 @@ main(int argc, char *argv[]) { gifEncode(&pam, stdout, rasterPos, cmdline.interlace, 0, bitsPerPixel, &cmap, cmdline.comment, cmdline.aspect, !cmdline.nolzw, cmdline.noclear, - !cmdline.transparent); + transType==TRANS_ALPHA); destroyCmap(&cmap); |