Reputation: 1027
I am successfully converting a 24-bit PNG image which has a transparent background to 4-bit PNG image using FreeImage C# wrapper. However, the 4-bit image's background becomes black instead of being transparent. Here is the code. Any ideas?
FIBITMAP dib = FreeImageAPI.FreeImage.LoadEx("C:\title_normal.png"); FreeImage.SetTransparent(dib, true); FreeImage.SaveEx(ref dib, "C:\title_normal.png", FREE_IMAGE_FORMAT.FIF_PNG, FREE_IMAGE_SAVE_FLAGS.PNG_Z_DEFAULT_COMPRESSION, FREE_IMAGE_COLOR_DEPTH.FICD_04_BPP, true);
Upvotes: 1
Views: 2134
Reputation: 1027
Actually I figured out. Here is the code if someone is interested:
dib = FreeImageAPI.FreeImage.LoadEx("C:\\title_selected.png");
dib = FreeImage.ConvertColorDepth(dib, FREE_IMAGE_COLOR_DEPTH.FICD_04_BPP);
byte[] Transparency = new byte[1];
Transparency[0] = 0x00;
FreeImage.SetTransparencyTable(dib, Transparency);
FreeImage.Save(FREE_IMAGE_FORMAT.FIF_PNG, dib, "C:\\title_selected1.png", FREE_IMAGE_SAVE_FLAGS.DEFAULT);
Resulting image is 4-bit transparent PNG!
Upvotes: 2
Reputation: 18430
I dont think 4-bit png has channel for Albha.
check here
http://en.wikipedia.org/wiki/Portable_Network_Graphics
Upvotes: 1