icestac
asked on
How to write an image in GIF format
I would like a function that takes in a System.Image object and a file name and will save the Image to the file in GIF format.
void ConvertToGif(System.Image img, string gifFileName)
{
// Save img to gifFileName as Gif...
}
Please take into account transparency
Thanks!
void ConvertToGif(System.Image img, string gifFileName)
{
// Save img to gifFileName as Gif...
}
Please take into account transparency
Thanks!
ASKER
Those articles were not really helpful. I have gotten to this point, but the transparency does not work.
string [] images = System.IO.Directory.GetFil es(this.tb Dir.Text, "*.png");
foreach (string image in images)
{
try
{
Image i = Image.FromFile(image);
string gif = System.IO.Path.ChangeExten sion(image , ".gif");
System.IO.FileStream fs = System.IO.File.Create(gif, 256);
i.Save(fs, System.Drawing.Imaging.Ima geFormat.G if);
fs.Close();
}
catch (Exception e2)
{
System.Diagnostics.Trace.W riteLine(" Unable to convert image: " + e2.ToString());
}
}
For the 500 points, I am really just looking for a function that I can copy and paste.
string [] images = System.IO.Directory.GetFil
foreach (string image in images)
{
try
{
Image i = Image.FromFile(image);
string gif = System.IO.Path.ChangeExten
System.IO.FileStream fs = System.IO.File.Create(gif,
i.Save(fs, System.Drawing.Imaging.Ima
fs.Close();
}
catch (Exception e2)
{
System.Diagnostics.Trace.W
}
}
For the 500 points, I am really just looking for a function that I can copy and paste.
ASKER
I just ended up finding a thrid party utility to convert the images... pngConverter by Incors
ASKER
By the way, there is a Microsoft article that gets most of the way there (except it is in grayscale instead of color)
See Q319061
See Q319061
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.codeguru.com/Cpp/Cpp/cpp_managed/nfc/article.php/c4839/#more
or
http://www.csharphelp.com/archives3/archive551.html