【问题标题】:Create 24bit Bitmap with Imagemagick with special background color used for transparency使用具有特殊背景颜色的 Imagemagick 创建 24 位位图,用于透明度
【发布时间】:2015-12-21 11:44:54
【问题描述】:

我正在为仅加载 24 位 BMP 的旧游戏开发软件创建 oldskool 精灵图像。软件会检测左上角的像素颜色并在运行时使其透明。

我正在尝试使用 Imagemagick 从我拥有的透明 PNG 生成此类 BMP 图像,但我需要背景为石灰 #32cd32。

批处理文件中的以下命令仅生成 24 位 BMP 文件,但透明区域无论如何都显示为黑色。

convert %1 -format bmp -type truecolor -background lime BMP3:"out.bmp"

【问题讨论】:

  • 那你想做什么?使每个图像的左上角像素变成石灰?还是用石灰替换所有透明像素?

标签: command-line bitmap imagemagick batch-processing


【解决方案1】:

使用“-flatten”选项:

convert $1 -background "#32cd32" -flatten BMP3:out.bmp

这会将透明图像与指定的背景颜色合成。

在 ImageMagick 中,“石灰”是饱和绿色 (#00ff00)。如果你想要 #32cd32 使用 ' -background "#32cd32" '

【讨论】:

    【解决方案2】:

    没有看到图像就很难估计问题,我希望需要删除 alpha 并用背景颜色替换。

    convert %1 -format bmp \
               -type truecolor \
               -alpha Remove \
               -background lime \
               BMP3:"out.bmp"
    

    请参阅“Alpha Remove”部分。

    -alpha Remove”方法(添加到 IMv6.7.5)旨在使用当前的“-background”去除图像的透明度。

    【讨论】:

    • 那不行,我也试过-alpha off,但没有。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-05
    • 2018-03-25
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2014-03-22
    相关资源
    最近更新 更多