Mercurial > hg > octave-lyh
comparison libinterp/dldfcn/__magick_read__.cc @ 17381: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 | b76b14e386b3 |
comparison
equal
deleted
inserted
replaced
17380:63b53ea33a8b | 17381:8508b8ae46a8 |
---|---|
69 // least create workarounds for the most common problems. | 69 // least create workarounds for the most common problems. |
70 // | 70 // |
71 // 1) A grayscale jpeg image can report being indexed even though the | 71 // 1) A grayscale jpeg image can report being indexed even though the |
72 // JPEG format has no support for indexed images. We can at least | 72 // JPEG format has no support for indexed images. We can at least |
73 // fix this one. | 73 // fix this one. |
74 // 2) A PNG file is only an indexed image if color type orig is 3 (value comes | |
75 // from libpng) | |
74 static bool | 76 static bool |
75 is_indexed (const Magick::Image& img) | 77 is_indexed (const Magick::Image& img) |
76 { | 78 { |
77 bool retval = false; | 79 bool retval = false; |
78 | 80 const std::string format = img.magick (); |
79 if (img.classType () == Magick::PseudoClass && img.magick () != "JPEG") | 81 if (img.classType () == Magick::PseudoClass |
82 && format != "JPEG" | |
83 && (format != "PNG" | |
84 || const_cast<Magick::Image&> (img).attribute ("PNG:IHDR.color-type-orig") == "3")) | |
80 retval = true; | 85 retval = true; |
81 | 86 |
82 return retval; | 87 return retval; |
83 } | 88 } |
84 | 89 |
99 // from RGB, CMYK, grayscale, and transparency. | 104 // from RGB, CMYK, grayscale, and transparency. |
100 static octave_idx_type | 105 static octave_idx_type |
101 get_depth (Magick::Image& img) | 106 get_depth (Magick::Image& img) |
102 { | 107 { |
103 octave_idx_type depth = img.depth (); | 108 octave_idx_type depth = img.depth (); |
104 if (depth != 1 | 109 if (depth == 8 |
105 && img.channelDepth (Magick::RedChannel) == 1 | 110 && img.channelDepth (Magick::RedChannel) == 1 |
106 && img.channelDepth (Magick::CyanChannel) == 1 | 111 && img.channelDepth (Magick::CyanChannel) == 1 |
107 && img.channelDepth (Magick::OpacityChannel) == 1 | 112 && img.channelDepth (Magick::OpacityChannel) == 1 |
108 && img.channelDepth (Magick::GrayChannel) == 1) | 113 && img.channelDepth (Magick::GrayChannel) == 1) |
109 depth = 1; | 114 depth = 1; |