From 54081f1e108cb4a385f951cbc293368829e39320 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 7 Nov 2021 01:32:55 +0000 Subject: Release 10.96.03 git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4176 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/other/sunicontopnm.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'converter/other') diff --git a/converter/other/sunicontopnm.c b/converter/other/sunicontopnm.c index eff1be58..db26663e 100644 --- a/converter/other/sunicontopnm.c +++ b/converter/other/sunicontopnm.c @@ -12,10 +12,12 @@ /* Most icon images are monochrome: Depth=1 + Depth=8 images are extremely rare. At least some of these are color - images but we can't tell the palette color order. + images but we haven't found information on the palette color order. Output will be in pgm. Convert to ppm with pgmtoppm or pamlookup - if necessary. + if necessary. It is up to the user to provide the color palette in + a form acceptable by the above conversion utilities. */ #include @@ -93,12 +95,19 @@ ReadIconFileHeader(FILE * const file, if (*widthP <= 0) pm_error("invalid width (must be positive): %d", *widthP); + else if (*widthP % 8 > 0) + pm_message("warning: width not a multiple of 8: %d", *widthP); + /* We don't know whether widths which are not a multiple of 8 + are allowed. The program must gracefully handle this case + because sun icon files are easy to edit by hand. + */ if (*heightP <= 0) pm_error("invalid height (must be positive): %d", *heightP); } + int main(int argc, const char ** argv) { @@ -125,7 +134,7 @@ main(int argc, const char ** argv) { maxval = 1; pbm_writepbminit(stdout, cols, rows, 0); bitrow = pbm_allocrow_packed(cols); - colChars = cols / 8; + colChars = pbm_packed_bytes(cols); } else { assert(depth == 8); format = PGM_TYPE; @@ -166,6 +175,11 @@ main(int argc, const char ** argv) { pgm_writepgmrow(stdout, grayrow, cols, maxval, 0); } + if (format == PBM_TYPE) + pbm_freerow_packed(bitrow); + else + pgm_freerow(grayrow); + pm_close(ifP); pm_close(stdout); return 0; -- cgit 1.4.1