# HG changeset patch # User Carnë Draug # Date 1377591855 -3600 # Node ID 51c011825bcc240c807e9b4077e1cffe80f06b02 # Parent eb7e9a991ffbf896f677d54c57868c3f1016ac7d __magick_write__: make sure binary images are saved as bilevel for some coders. diff --git a/libinterp/dldfcn/__magick_read__.cc b/libinterp/dldfcn/__magick_read__.cc --- a/libinterp/dldfcn/__magick_read__.cc +++ b/libinterp/dldfcn/__magick_read__.cc @@ -878,7 +878,8 @@ octave_idx_type img_idx = 0; for (octave_idx_type frame = 0; frame < nFrames; frame++) { - // For some reason, we can't set the type to Magick::BilevelType. + // For some reason, we can't set the type to Magick::BilevelType or + // the output image will be black, changing to white has no effect. // However, this will still work fine and a binary image will be // saved because we are setting the bitdepth to 1. Magick::Image m_img = init_enconde_image (nCols, nRows, 1, @@ -901,6 +902,9 @@ } // Save changes to underlying image. m_img.syncPixels (); + // While we could not set it to Bilevel at the start, we can do it + // here otherwise some coders won't save it as binary. + m_img.type (Magick::BilevelType); imvec.push_back (m_img); } }