Mercurial > hg > octave-lojdl
changeset 9275:86f475d5e7d1
imwrite.m: convert indexed images to RGB before calling __magick_write__
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 27 May 2009 10:34:59 -0400 |
parents | 6e519bd01615 |
children | f5e4b5fd1f1e |
files | scripts/ChangeLog scripts/image/imwrite.m src/ChangeLog src/DLD-FUNCTIONS/__magick_read__.cc |
diffstat | 4 files changed, 31 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,8 @@ 2009-05-27 John W. Eaton <jwe@octave.org> + * image/imwrite.m: Convert indexed images to RGB before calling + __magick_write__. + * image/imshow.m: In demo, convert image to rgb before scaling components. Use imread instead of loadimage.
--- a/scripts/image/imwrite.m +++ b/scripts/image/imwrite.m @@ -142,10 +142,19 @@ error ("imwrite: %s invalid class for indexed image colormap", class (map)); endif + + ## FIXME -- we should really be writing indexed images here but + ## __magick_write__ needs to be fixed to handle them. + + [r, g, b] = ind2rgb (img, map); + tmp = uint8 (cat (3, r, g, b) * 255); + if (has_param_list) - __magick_write__ (filename, fmt, img, map, options); + __magick_write__ (filename, fmt, tmp, options); + ## __magick_write__ (filename, fmt, img, map, options); else - __magick_write__ (filename, fmt, img, map); + __magick_write__ (filename, fmt, tmp); + ## __magick_write__ (filename, fmt, img, map); endif endif
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-05-27 John W. Eaton <jwe@octave.org> + + * DLD-FUNCTIONS/__magick_read__.cc (write_image): + Bail out if given indexed image. + 2009-05-27 Jaroslav Hajek <highegg@gmail.com> * DLD-FUNCTIONS/__magick_read__.cc (encode_map): Fix RGB color
--- a/src/DLD-FUNCTIONS/__magick_read__.cc +++ b/src/DLD-FUNCTIONS/__magick_read__.cc @@ -697,16 +697,24 @@ { std::vector<Magick::Image> imvec; + bool has_map = map.is_defined (); + + if (has_map) + { + error ("__magick_write__: direct saving of indexed images not currently supported; use ind2rgb and save converted image"); + return; + } + if (img.is_bool_type ()) encode_bool_image (imvec, img); else if (img.is_uint8_type ()) - encode_uint_image<uint8NDArray> (imvec, img, map.is_defined ()); + encode_uint_image<uint8NDArray> (imvec, img, has_map); else if (img.is_uint16_type ()) - encode_uint_image<uint16NDArray> (imvec, img, map.is_defined ()); + encode_uint_image<uint16NDArray> (imvec, img, has_map); else error ("__magick_write__: image type not supported"); - if (! error_state && map.is_defined ()) + if (! error_state && has_map) { NDArray cmap = map.array_value (); @@ -720,7 +728,7 @@ // Insert calls here to handle parameters for various image formats if (fmt == "jpg" || fmt == "jpeg") - jpg_settings (imvec, options, map.is_defined ()); + jpg_settings (imvec, options, has_map); else warning ("warning: your parameter(s) currently not supported"); }