1

读取 8 位 bmp 并使用 resize() 调整(缩小)它会导致它在内部变为 24 位。Scale() 保持深度,但当然看起来不太好,所以我更喜欢使用较慢的 resize()。

调用 resize() 后,depth() 仍然报告为 8 位,但不是(总颜色超过 400.000)

我尝试将深度设置为 8,但是在将磁盘从 24 位写入到 8 位时,这不会改变输出。还尝试写入 blob 指定格式 (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
4

0 回答 0