Saving images after using MakeTransparent() creates huge files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jbro22
    New Member
    • Aug 2008
    • 2

    Saving images after using MakeTransparent() creates huge files

    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.MakeTransp arent(Color.Bla ck);
    bmp1.Save("test .gif");

    Code 2:
    System.Drawing. Bitmap bmp1 = new System.Drawing. Bitmap(Pic);
    bmp1.MakeTransp arent(Color.Bla ck); bmp1.Save("test .gif",System.Dr awing.Imaging.I mageFormat.Gif) ;

    Thanks so much in advance!
    ~John
  • boxfish
    Recognized Expert Contributor
    • Mar 2008
    • 469

    #2
    This code doesn't look like C++ to me; does this question go in the java forum?

    Comment

    • jbro22
      New Member
      • Aug 2008
      • 2

      #3
      No you are right it is not C++ but it is C# and I couldn't find another forum topic that was closer than C++. Any suggestions on where I should place it? Thanks

      Comment

      • boxfish
        Recognized Expert Contributor
        • Mar 2008
        • 469

        #4
        I think C# goes in the .NET forum; a moderator should be able to move this thread.

        Comment

        • SpecialKay
          New Member
          • Mar 2008
          • 109

          #5
          just so i understand. you are trying to turn all the pixels that are black, to another color? in this case Transparent?

          Comment

          Working...