Everything about my daily life as a programmer/Electrical Engineer!

Convert Bitmaps to transparent png

Not much to say.  This was really useful with an icon set we were using.


using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;

namespace ConsoleApplication2
class Program
static void Main(string[] args)
string directory=@"c:\temp\";
string[] files = Directory.GetFiles(directory, "*.bmp");
foreach (string path in files)
Bitmap bmp = new Bitmap(path);
FileInfo fi = new FileInfo(path);
bmp.Save(directory + fi.Name.Replace(".bmp", "") + ".png", ImageFormat.Png);


No comments: