diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-12-31 00:29:22 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-12-31 00:29:22 +0000 |
commit | 88974357f5508b3f5c3867f67fd18fa7270c53f0 (patch) | |
tree | 7252252d479176e84f87acf6c4a56d6db4116190 /other | |
parent | 0e1ad2d06a4c00a9172cc6409e0964cc86eb6c78 (diff) | |
download | netpbm-mirror-88974357f5508b3f5c3867f67fd18fa7270c53f0.tar.gz netpbm-mirror-88974357f5508b3f5c3867f67fd18fa7270c53f0.tar.xz netpbm-mirror-88974357f5508b3f5c3867f67fd18fa7270c53f0.zip |
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4226 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'other')
-rw-r--r-- | other/pamendian.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/other/pamendian.c b/other/pamendian.c index d82ebd38..75fa3cbc 100644 --- a/other/pamendian.c +++ b/other/pamendian.c @@ -1,17 +1,18 @@ -/****************************************************************************** +/*============================================================================= pamendian -******************************************************************************* +=============================================================================== Reverse the endianness of multi-byte samples in a Netpbm stream. I.e. convert between the true format and the little endian variation of it. -******************************************************************************/ - +=============================================================================*/ + #include "pam.h" static sample -reverseSample(sample const insample, unsigned int const bytesPerSample) { +reverseSample(sample const insample, + unsigned int const bytesPerSample) { /*---------------------------------------------------------------------------- Return a sample whose value is the least significant 'bytes_per_sample' bytes, in reverse order. @@ -30,14 +31,14 @@ reverseSample(sample const insample, unsigned int const bytesPerSample) { -int main(int argc, char *argv[]) { +int main(int argc, const char ** argv) { struct pam inpam, outpam; tuple * intuplerow; tuple * outtuplerow; unsigned int row; - pnm_init(&argc, argv); + pm_proginit(&argc, argv); pnm_readpaminit(stdin, &inpam, PAM_STRUCT_SIZE(tuple_type)); @@ -46,7 +47,7 @@ int main(int argc, char *argv[]) { pnm_writepaminit(&outpam); - intuplerow = pnm_allocpamrow(&inpam); + intuplerow = pnm_allocpamrow(&inpam); outtuplerow = pnm_allocpamrow(&outpam); for (row = 0; row < inpam.height; row++) { @@ -54,17 +55,19 @@ int main(int argc, char *argv[]) { pnm_readpamrow(&inpam, intuplerow); for (col = 0; col < inpam.width; col++) { unsigned int plane; - for (plane = 0; plane < inpam.depth; plane++) - outtuplerow[col][plane] = - reverseSample(intuplerow[col][plane], + for (plane = 0; plane < inpam.depth; plane++) + outtuplerow[col][plane] = + reverseSample(intuplerow[col][plane], inpam.bytes_per_sample); } pnm_writepamrow(&outpam, outtuplerow); } - pnm_freepamrow(outtuplerow); - pnm_freepamrow(intuplerow); + pnm_freepamrow(outtuplerow); + pnm_freepamrow(intuplerow); - exit(0); + return 0; } + + |