GraphicsMagick: ReadJPEGImage(): Add support for reading deep gr...
GraphicsMagick Commits <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.22786.1669405846.1350.graphicsmagick-commit@lists.sourceforge.net> |
changeset 3136789dc62e in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=3136789dc62e summary: ReadJPEGImage(): Add support for reading deep gray images. diffstat: ChangeLog | 11 ++++++ VisualMagick/installer/inc/version.isx | 4 +- coders/jpeg.c | 60 ++++++++++++++++++++++++++------- coders/topol.c | 4 +- magick/version.h | 4 +- magick/xwindow.c | 10 +++- www/Changelog.html | 11 ++++++ 7 files changed, 82 insertions(+), 22 deletions(-) diffs (196 lines): diff -r ac03e84f4529 -r 3136789dc62e ChangeLog --- a/ChangeLog Thu Nov 24 17:51:45 2022 -0600 +++ b/ChangeLog Fri Nov 25 13:50:32 2022 -0600 @@ -1,3 +1,14 @@ +2022-11-25 Bob Friesenhahn <[email protected]> + + * coders/jpeg.c (ReadJPEGImage): Eliminate Clang Analyzer + diagnostic. Add support for reading deep gray images. + + * magick/xwindow.c (MagickXDitherImage): Update documentation to + add a link to an article about the HP Color Recovery algorithm. + + * coders/topol.c (ReadTOPOLImage): Eliminate Clang Analyzer + diagnostic. + 2022-11-24 Bob Friesenhahn <[email protected]> * coders/jpeg.c (WriteJPEGImage): Useful data_precision range is 8 diff -r ac03e84f4529 -r 3136789dc62e VisualMagick/installer/inc/version.isx --- a/VisualMagick/installer/inc/version.isx Thu Nov 24 17:51:45 2022 -0600 +++ b/VisualMagick/installer/inc/version.isx Fri Nov 25 13:50:32 2022 -0600 @@ -10,5 +10,5 @@ #define public MagickPackageName "GraphicsMagick" #define public MagickPackageVersion "1.4" -#define public MagickPackageVersionAddendum ".020221124" -#define public MagickPackageReleaseDate "snapshot-20221124" +#define public MagickPackageVersionAddendum ".020221125" +#define public MagickPackageReleaseDate "snapshot-20221125" diff -r ac03e84f4529 -r 3136789dc62e coders/jpeg.c --- a/coders/jpeg.c Thu Nov 24 17:51:45 2022 -0600 +++ b/coders/jpeg.c Fri Nov 25 13:50:32 2022 -0600 @@ -1532,8 +1532,7 @@ jpeg_calc_output_dimensions(&jpeg_info); image->columns=jpeg_info.output_width; image->rows=jpeg_info.output_height; - image->storage_class = jpeg_info.output_components == 1 ? PseudoClass : DirectClass; - image->depth=Min(jpeg_info.data_precision,QuantumDepth); + image->depth=Min(jpeg_info.data_precision,Min(16,QuantumDepth)); if (image->logging) { @@ -1597,13 +1596,20 @@ "Sampling Factors: %s", attribute); } - image->depth=Min(jpeg_info.data_precision,QuantumDepth); + image->depth=Min(jpeg_info.data_precision,Min(16,QuantumDepth)); if (jpeg_info.out_color_space == JCS_GRAYSCALE) - if (!AllocateImageColormap(image,1 << image->depth)) - { - jpeg_destroy_decompress(&jpeg_info); - ThrowJPEGReaderException(ResourceLimitError,MemoryAllocationFailed,image); - } + { + /* + Build colormap if we can + */ + unsigned long max_index = MaxValueGivenBits(image->depth); + if (max_index <= MaxMap) + if (!AllocateImageColormap(image,max_index+1LU)) + { + jpeg_destroy_decompress(&jpeg_info); + ThrowJPEGReaderException(ResourceLimitError,MemoryAllocationFailed,image); + } + } /* Store profiles in image. @@ -1758,12 +1764,40 @@ if (jpeg_info.output_components == 1) { - for (x=0; x < (long) image->columns; x++) + if (image->storage_class == PseudoClass) + { + for (x=0; x < (long) image->columns; x++) + { + index=(IndexPacket) (GETJSAMPLE(*p++)); + VerifyColormapIndex(image,index); + indexes[x]=index; + *q++=image->colormap[index]; + } + } + else { - index=(IndexPacket) (GETJSAMPLE(*p++)); - VerifyColormapIndex(image,index); - indexes[x]=index; - *q++=image->colormap[index]; + if (jpeg_info.data_precision > 8) + { + unsigned int + scale_short; + + scale_short=65535U/MaxValueGivenBits(jpeg_info.data_precision); + for (x=0; x < (long) image->columns; x++) + { + q->red=q->green=q->blue=ScaleShortToQuantum(scale_short*GETJSAMPLE(*p++)); + q->opacity=OpaqueOpacity; + q++; + } + } + else + { + for (x=0; x < (long) image->columns; x++) + { + q->red=q->green=q->blue=ScaleCharToQuantum(GETJSAMPLE(*p++)); + q->opacity=OpaqueOpacity; + q++; + } + } } } else if ((jpeg_info.output_components == 3) || diff -r ac03e84f4529 -r 3136789dc62e coders/topol.c --- a/coders/topol.c Thu Nov 24 17:51:45 2022 -0600 +++ b/coders/topol.c Fri Nov 25 13:50:32 2022 -0600 @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2020 GraphicsMagick Group +% Copyright (C) 2003-2022 GraphicsMagick Group % % This program is covered by multiple licenses, which are described in % Copyright.txt. You should have received a copy of Copyright.txt with this @@ -350,7 +350,7 @@ unsigned char *BImgBuff = NULL, - MEZ[256]; + MEZ[256] = { 0 }; ImportPixelAreaOptions import_options; diff -r ac03e84f4529 -r 3136789dc62e magick/version.h --- a/magick/version.h Thu Nov 24 17:51:45 2022 -0600 +++ b/magick/version.h Fri Nov 25 13:50:32 2022 -0600 @@ -38,8 +38,8 @@ #define MagickLibVersion 0x272400 #define MagickLibVersionText "1.4" #define MagickLibVersionNumber 27,24,0 -#define MagickChangeDate "20221124" -#define MagickReleaseDate "snapshot-20221124" +#define MagickChangeDate "20221125" +#define MagickReleaseDate "snapshot-20221125" /* The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines diff -r ac03e84f4529 -r 3136789dc62e magick/xwindow.c --- a/magick/xwindow.c Thu Nov 24 17:51:45 2022 -0600 +++ b/magick/xwindow.c Fri Nov 25 13:50:32 2022 -0600 @@ -2109,9 +2109,11 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method XDitherImage dithers the reference image as required by the HP -% Color Recovery algorithm. The color values are quantized to 3 bits of red -% and green, and 2 bits of blue (3/3/2) and can be used as indices into a -% 8-bit X standard colormap. +% Color Recovery algorithm +% (https://www.hpl.hp.com/hpjournal/95apr/apr95a6.pdf). +% The color values are quantized to 3 bits of red and green, and 2 bits +% of blue (3/3/2) and can be used as indices into a 8-bit X standard +% colormap. % % The format of the XDitherImage method is: % @@ -2221,6 +2223,8 @@ value=x-32; if (x < 112) value=x/2+24; + /* Cast to unsigned added below to avoid undefined + behavior. Not sure if result is what was expected! */ value+=((magick_uint32_t) dither_blue[i][j] << 1); blue_map[i][j][x]=(unsigned char) ((value < 0) ? 0 : (value > 255) ? 255 : value); diff -r ac03e84f4529 -r 3136789dc62e www/Changelog.html --- a/www/Changelog.html Thu Nov 24 17:51:45 2022 -0600 +++ b/www/Changelog.html Fri Nov 25 13:50:32 2022 -0600 @@ -37,6 +37,17 @@ </div> <div class="document"> +<p>2022-11-25 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p> +<blockquote> +<ul class="simple"> +<li><p>coders/jpeg.c (ReadJPEGImage): Eliminate Clang Analyzer +diagnostic. Add support for reading deep gray images.</p></li> +<li><p>magick/xwindow.c (MagickXDitherImage): Update documentation to +add a link to an article about the HP Color Recovery algorithm.</p></li> +<li><p>coders/topol.c (ReadTOPOLImage): Eliminate Clang Analyzer +diagnostic.</p></li> +</ul> +</blockquote> <p>2022-11-24 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p> <blockquote> <ul class="simple">