diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-03-09 17:58:10 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-03-09 17:58:10 +0000 |
commit | 1ca92b339a0c65bfadab923c618863b71955c5be (patch) | |
tree | 1e8317dad092f8802c524326a12a76219cef194e /converter/other/pamtoxvmini.c | |
parent | f2ff7fc0202fad727ec2fea4bc628205130dd86d (diff) | |
download | netpbm-mirror-1ca92b339a0c65bfadab923c618863b71955c5be.tar.gz netpbm-mirror-1ca92b339a0c65bfadab923c618863b71955c5be.tar.xz netpbm-mirror-1ca92b339a0c65bfadab923c618863b71955c5be.zip |
Release 10.35.24
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@246 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other/pamtoxvmini.c')
-rw-r--r-- | converter/other/pamtoxvmini.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/converter/other/pamtoxvmini.c b/converter/other/pamtoxvmini.c index 449b3c99..3207b0d5 100644 --- a/converter/other/pamtoxvmini.c +++ b/converter/other/pamtoxvmini.c @@ -75,15 +75,20 @@ makeXvPalette(xvPalette * const xvPaletteP) { static void writeXvHeader(FILE * const ofP, unsigned int const cols, - unsigned int const rows, - unsigned int const maxval) { + unsigned int const rows) { fprintf(ofP, "P7 332\n"); fprintf(ofP, "# Created by Pamtoxvmini\n"); fprintf(ofP, "#END_OF_COMMENTS\n"); - fprintf(ofP, "%u %u %u\n", cols, rows, maxval); + /* I don't know what the maxval number (3rd field) means here, since + the maxvals are fixed at red=7, grn=7, blu=3. We used to have + it put the maxval of the input image there. That generated an + output that Xv choked on when the input maxval was 65535. + */ + + fprintf(ofP, "%u %u 255\n", cols, rows); } @@ -105,7 +110,7 @@ findClosestColor(struct pam * const pamP, colors in the XV palette: */ assert(pamP->depth >= 3); - assert(pamP->maxval = 255); + assert(pamP->maxval == 255); bestPaletteIndex = 0; bestDistanceSoFar = UINT_MAX; @@ -185,30 +190,34 @@ writeXvRaster(struct pam * const pamP, tuple * tuplerow; unsigned int row; unsigned char * xvrow; + struct pam scaledPam; paletteHash = pnm_createtuplehash(); tuplerow = pnm_allocpamrow(pamP); xvrow = (unsigned char*)pm_allocrow(pamP->width, 1); + scaledPam = *pamP; + scaledPam.maxval = 255; + for (row = 0; row < pamP->height; ++row) { unsigned int col; pnm_readpamrow(pamP, tuplerow); - pnm_scaletuplerow(pamP, tuplerow, tuplerow, 255); - pnm_makerowrgb(pamP, tuplerow); + pnm_scaletuplerow(pamP, tuplerow, tuplerow, scaledPam.maxval); + pnm_makerowrgb(&scaledPam, tuplerow); - for (col = 0; col < pamP->width; ++col) { + for (col = 0; col < scaledPam.width; ++col) { unsigned int paletteIndex; - getPaletteIndexThroughCache(pamP, tuplerow[col], xvPaletteP, + getPaletteIndexThroughCache(&scaledPam, tuplerow[col], xvPaletteP, paletteHash, &paletteIndex); assert(paletteIndex < 256); xvrow[col] = paletteIndex; } - fwrite(xvrow, 1, pamP->width, ofP); + fwrite(xvrow, 1, scaledPam.width, ofP); } pm_freerow((char*)xvrow); @@ -240,7 +249,7 @@ main(int argc, pnm_setminallocationdepth(&pam, 3); - writeXvHeader(stdout, pam.width, pam.height, pam.maxval); + writeXvHeader(stdout, pam.width, pam.height); writeXvRaster(&pam, &xvPalette, stdout); |