Mercurial > hg > octave-nkf
changeset 17373:8508b8ae46a8
imread: fix identification of PNG files as indexed.
* __magick_read__.cc (is_indexed): expand extra check for PNG files by
confirming value in color_type_orig.
(get_depth): only fix indentification as binary for depth of 8. When
Magick reports different than 1 for binary images, seems to always
change it for 8, not anything else different than 1.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Wed, 04 Sep 2013 22:21:08 +0100 |
parents | 63b53ea33a8b |
children | 991c7c812e38 |
files | libinterp/dldfcn/__magick_read__.cc |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/dldfcn/__magick_read__.cc +++ b/libinterp/dldfcn/__magick_read__.cc @@ -71,12 +71,17 @@ // 1) A grayscale jpeg image can report being indexed even though the // JPEG format has no support for indexed images. We can at least // fix this one. +// 2) A PNG file is only an indexed image if color type orig is 3 (value comes +// from libpng) static bool is_indexed (const Magick::Image& img) { bool retval = false; - - if (img.classType () == Magick::PseudoClass && img.magick () != "JPEG") + const std::string format = img.magick (); + if (img.classType () == Magick::PseudoClass + && format != "JPEG" + && (format != "PNG" + || const_cast<Magick::Image&> (img).attribute ("PNG:IHDR.color-type-orig") == "3")) retval = true; return retval; @@ -101,7 +106,7 @@ get_depth (Magick::Image& img) { octave_idx_type depth = img.depth (); - if (depth != 1 + if (depth == 8 && img.channelDepth (Magick::RedChannel) == 1 && img.channelDepth (Magick::CyanChannel) == 1 && img.channelDepth (Magick::OpacityChannel) == 1