473,385 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Saving images after using MakeTransparent() creates huge files

2
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
Aug 22 '08 #1
4 2139
boxfish
469 Expert 256MB
This code doesn't look like C++ to me; does this question go in the java forum?
Aug 23 '08 #2
jbro22
2
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
Aug 25 '08 #3
boxfish
469 Expert 256MB
I think C# goes in the .NET forum; a moderator should be able to move this thread.
Aug 25 '08 #4
SpecialKay
109 100+
just so i understand. you are trying to turn all the pixels that are black, to another color? in this case Transparent?
Aug 25 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Rami A. Kishek | last post by:
I'm new to js. Please help me figure this out WANT: Client to save an image to disk pressing a "download" button. The image name is dynamic, from JS code on another part of the page DID: Read...
4
by: Dom Hicklin | last post by:
I have created a form onto which images can be dropped and thus added to the OLE field of a Table (Access 2000 linked to SQL 2000 server). I use the Stephen Lebans ExportOLE function to do this...
0
by: eruess | last post by:
Here's the scenario: I've got a whole bunch (for the sake of argument, let's say thousands) of different little 32x14 .png files that act as buttons all over a very large website. Each button...
3
by: Fahad Aijaz | last post by:
Can any one tell me how can I create overlapping images using ASP.NET. That is, One rectangle drawn as a background image and then another image is placed over it. If the upper image gets...
1
by: M Keeton | last post by:
I currently have a picture which is stored in a "System.Drawing.Image" variable and I want to save it as a bitmap file. I have tried 2 different approaches and both give me the following error: ...
2
by: Mark Denardo | last post by:
Hi, I need some expert GDI+ person to help me with my RoundOffImage Function: What I'm trying to do is take in an image, crop off the edges around an ellipse region I set up, and then return the...
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
6
by: Eddie | last post by:
Hi all, I am displaying a number of reports, and giving the users an option to display them on the web or download them to Excel. If they want the Excel file, I just use the PHP header command...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.