diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-12-31 08:08:29 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-12-31 08:08:29 +0000 |
commit | 31fc573df625b06a5f7b8b8e769e9f35cbfdaf91 (patch) | |
tree | caf153af4ea24150e1f54e77c35b9ee51e727055 /other/pamx/image.c | |
parent | 2cc04cae07f40a7c58616e4614e88cf0ae8e63c7 (diff) | |
download | netpbm-mirror-31fc573df625b06a5f7b8b8e769e9f35cbfdaf91.tar.gz netpbm-mirror-31fc573df625b06a5f7b8b8e769e9f35cbfdaf91.tar.xz netpbm-mirror-31fc573df625b06a5f7b8b8e769e9f35cbfdaf91.zip |
Release 10.37.0
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@187 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'other/pamx/image.c')
-rw-r--r-- | other/pamx/image.c | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/other/pamx/image.c b/other/pamx/image.c index 892a9768..0e719438 100644 --- a/other/pamx/image.c +++ b/other/pamx/image.c @@ -237,95 +237,3 @@ freeImage(Image * const imageP) { free(imageP); } - - - - -static void -fillRow1(struct pam * const pamP, - tuple * const tuplerow, - unsigned char ** const pP) { - - unsigned int col; - - for (col = 0; col < pamP->width; ++col) { - unsigned int plane; - for (plane = 0; plane < pamP->depth; ++plane) - *(*pP)++ = - pnm_scalesample(tuplerow[col][0], pamP->maxval, 255); - } -} - - - -static void -fillRow3(struct pam * const pamP, - tuple * const tuplerow, - unsigned char ** const pP) { - - unsigned int col; - - for (col = 0; col < pamP->width; ++col) { - unsigned int plane; - for (plane = 0; plane < pamP->depth; ++plane) - *(*pP)++ = - pnm_scalesample(tuplerow[col][plane], pamP->maxval, 255); - } -} - - - -Image * -pbmLoad(const char * const fullname, - const char * const name, - bool const verbose) { - - FILE * ifP; - struct pam pam; - Image * imageP; - unsigned int row; - const char * filename; - tuple * tuplerow; - unsigned char * p; - enum {DEPTH_1, DEPTH_3} depth; - - if (STREQ(fullname, "stdin")) - filename = "-"; - else - filename = fullname; - - ifP = pm_openr(filename); - - pnm_readpaminit(ifP, &pam, PAM_STRUCT_SIZE(tuple_type)); - - if (strncmp(pam.tuple_type, "RGB", 3) == 0) { - depth = DEPTH_3; - if (pam.depth < 3) - pm_error("Invalid depth %u for RGB tuple type.", pam.depth); - } else - depth = DEPTH_1; - - imageP = newTrueImage(pam.width, pam.height); - - p = &imageP->data[0]; /* initial value */ - - tuplerow = pnm_allocpamrow(&pam); - - for (row = 0; row < pam.height; ++row) { - pnm_readpamrow(&pam, tuplerow); - - switch (depth) { - case DEPTH_3: - fillRow3(&pam, tuplerow, &p); - break; - case DEPTH_1: - fillRow1(&pam, tuplerow, &p); - break; - } - } - pnm_freepamrow(tuplerow); - - pm_close(ifP); - - return imageP; -} |