8 ビットの bmp を読み取り、resize() を使用してサイズ変更 (ダウンスケーリング) すると、内部で 24 ビットに変更されます。Scale() は深さを保持しますが、もちろん見栄えがよくないので、より遅い resize() を使用することを好みます。
resize() を呼び出した後も、depth() は 8 ビットとして報告されますが、そうではありません (合計色数が 400.000 を超えています)。
深さを 8 に設定しようとしましたが、ディスクに 24 ビットから 8 ビットに書き込むときの出力は変わりません。また、フォーマット (BMP) および 8 ビットを指定するブロブに書き込もうとしました。それも24ビットを出力します。
質問は、サイズ変更を使用するときに同じビット深度を維持するにはどうすればよいですか?
Magick::Image image;
const int depth2 = image.depth(); // 16
image.read("C:\\earth-huge.bmp"); // 8 bit. 64 colors
const int depth = image.depth(); // 8
int colors2 = image.totalColors(); // 64
image.filterType(Magick::FilterTypes::LanczosFilter);
image.resize(Magick::Geometry(1024, 512));
const int depth3 = image.depth(); // 8
int colors = image.totalColors(); // 409246
image.depth(8); // no effect
int colors3 = image.totalColors(); // 409246
image.write("C:\\earth-huge-magick++.bmp"); // outputs 24 bit bmp