I want to write a program that will take all the files in a folder (assuming they are all bmp's) and convert them to jpeg's. In my mind it's a simple loop through all the files, process them with some algorithm, output them as jpeg's. Unfortunately I have no clue whatsoever as where to start. So I googled this and found some code and due to my lack of knowledge on the subject (and C# for that matter) I have no clue what is happening. Not wanting to be in ignorant bliss could someone please explain the following to me:
CODE
private void saveJpeg(string path, Bitmap img, long quality)
{
EncoderParameter qualityParam =
new EncoderParameter(Encoder.Quality, (long)quality);
ImageCodecInfo jpegCodec =
this.getEncoderInfo("image/jpeg");
if(jpegCodec == null)
return;
EncoderParameters encoderParams = new EncoderParameters(1);
encoderParams.Param[0] = qualityParam;
img.Save(path, jpegCodec, encoderParams);
}
private ImageCodecInfo getEncoderInfo(string mimeType)
{
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
for (int i = 0; i <codecs.Length; i++)
if (codecs[i].MimeType == mimeType)
return codecs[i];
return null;
}