c++ freeimage 指定颜色透明

#include <iostream>
#include "freeimage.h"
#include "FreeImagePlus.h"
int main()
{
    const char* srcImagePath = "E:/Desktop/01.tif";
    const char* dstImagePath = "E:/Desktop/01.png";

    fipImage image;
    if (!image.load(srcImagePath))
        return false;

    //image.convertTo24Bits();
    image.convertTo8Bits();
    image.colorQuantize(FIQ_WUQUANT);

    RGBQUAD * palette = image.getPalette();

    BYTE transparency[256];
    for (unsigned i = 0; i < 256; i++)
    {
        transparency[i] = 0xFF;
        if (palette[i].rgbGreen >= 0xFF && palette[i].rgbBlue == 0xFF && palette[i].rgbRed == 0xFF)
            transparency[i] = 0x00;
    }

    image.setTransparencyTable(transparency, 256);

    image.save(dstImagePath);

    return 0;
}

 

上一篇:【LaTeX】颜色的使用(包含:多种多样的颜色,做出好看的颜色,color palette 颜色板,多种方式定义颜色)


下一篇:图片占位符 lqip-loader 简介与使用