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; }
标签:透明,palette,freeimage,image,c++,transparency,0xFF,include,256 来源: https://www.cnblogs.com/nanfei/p/14326869.html