#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; }