Hello, I am working on a project in which it is necessary to convert a jpg image which contains lots of black surrounding the actual photograph to a transparent gif in which the black has become transparent. Cropping is not an option because the images are aerial photography, so the "true image" is never the same shape.
My problem is that when I use the MakeTransparent() function and then save it as a gif, the filesize skyrockets from 4MB to 13MB. I would understand it going up to maybe 5.5 since I am adding another channel, but why is it going that far?
MakeTransparent seems to be my only option since going through pixel by pixel would take far to long for the thousands of pictures I have. Here are two pieces of code that I have tried. In the first I just save it as a file name (.gif) and don't tell it the image format. This results in the transparency I desire, but at 13MB. In the second option I specify that the new image is of the gif format. This results in a .gif that is now 1.5MB, but with no transparency at all (still black). Neither of these are usable options.
Code 1:
System.Drawing.Bitmap bmp1 = new System.Drawing.Bitmap(Pic);
bmp1.MakeTransparent(Color.Black);
bmp1.Save("test.gif");
Code 2:
System.Drawing.Bitmap bmp1 = new System.Drawing.Bitmap(Pic);
bmp1.MakeTransparent(Color.Black); bmp1.Save("test.gif",System.Drawing.Imaging.ImageF ormat.Gif);
Thanks so much in advance!
~John