diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2018-09-29 03:18:57 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2018-09-29 03:18:57 +0000 |
commit | e227331a6b5626e100705fcff3269fd8479ea988 (patch) | |
tree | fd51fff8ec8dc90185ce5ae457805a0f25a0ded6 /lib/libpamn.c | |
parent | cdd64d00181d5e5a6c8142cdb59f2215014ca82d (diff) | |
download | netpbm-mirror-e227331a6b5626e100705fcff3269fd8479ea988.tar.gz netpbm-mirror-e227331a6b5626e100705fcff3269fd8479ea988.tar.xz netpbm-mirror-e227331a6b5626e100705fcff3269fd8479ea988.zip |
Promote current Development release as Advanced
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@3352 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/libpamn.c')
-rw-r--r-- | lib/libpamn.c | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/lib/libpamn.c b/lib/libpamn.c index 65c8979f..8ae57037 100644 --- a/lib/libpamn.c +++ b/lib/libpamn.c @@ -69,7 +69,8 @@ allocpamrown(const struct pam * const pamP, overflow will not occur in our calculations. NOTE: pnm_readpaminit() ensures this assumption is valid. -----------------------------------------------------------------------------*/ - int const bytes_per_tuple = allocationDepth(pamP) * sizeof(samplen); + unsigned int const bytes_per_tuple = + allocationDepth(pamP) * sizeof(samplen); tuplen * tuplerown; const char * error; @@ -643,6 +644,63 @@ pnm_unapplyopacityrown(struct pam * const pamP, +void +pnm_maketuplergbn(const struct pam * const pamP, + tuplen const tuple) { + + if (allocationDepth(pamP) < 3) + pm_error("allocation depth %u passed to pnm_maketuplergb(). " + "Must be at least 3.", allocationDepth(pamP)); + + if (pamP->depth < 3) + tuple[2] = tuple[1] = tuple[0]; +} + + + +void +pnm_makerowrgbn(const struct pam * const pamP, + tuplen * const tuplerow) { + + if (pamP->depth < 3) { + unsigned int col; + + if (allocationDepth(pamP) < 3) + pm_error("allocation depth %u passed to pnm_makerowrgb(). " + "Must be at least 3.", allocationDepth(pamP)); + + for (col = 0; col < pamP->width; ++col) { + tuplen const thisTuple = tuplerow[col]; + thisTuple[2] = thisTuple[1] = thisTuple[0]; + } + } +} + + + +void +pnm_makearrayrgbn(const struct pam * const pamP, + tuplen ** const tuples) { + + if (pamP->depth < 3) { + unsigned int row; + if (allocationDepth(pamP) < 3) + pm_error("allocation depth %u passed to pnm_makearrayrgb(). " + "Must be at least 3.", allocationDepth(pamP)); + + for (row = 0; row < pamP->height; ++row) { + tuplen * const tuplerow = tuples[row]; + unsigned int col; + for (col = 0; col < pamP->width; ++col) { + tuplen const thisTuple = tuplerow[col]; + thisTuple[2] = thisTuple[1] = thisTuple[0]; + } + } + } +} + + + static void fillInMap(pnm_transformMap const ungammaTransformMap, sample const maxval, |