g.DrawImage(b,
new System.Drawing.Rectangle(0, 0, dstImage.Width, dstImage.Height),
new System.Drawing.Rectangle(0, 0, b.Width, b.Height),
System.Drawing.GraphicsUnit.Pixel);
g.Save();
g.Dispose();
return dstImage;
} // end of Resize
private void reSizeProcess()
{
string pathStrSelText;
int n = 0;
this.label1.Text="";
//string pathStrResize="";
//MessageBox.Show(NewWidth.ToString());
foreach (ListViewItem SelItems in this.listView1.Items)
{
pathStrSelText = SelItems.Text;
Bitmap zc = new Bitmap(SelItems.Text);
zc = ResizeBitmap(zc, NewHeight, NewWidth);
EncoderParameters ep = new EncoderParameters();
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
//find the encoder with the image/jpeg mime-type
ImageCodecInfo ici = null;
foreach (ImageCodecInfo codec in codecs)
{
if (codec.MimeType == "image/jpeg")
ici = codec;
}
//We'll save images with 25%, 50%, 75% and 100% quality as compared with the original
//for (int x = 25; x < 101; x += 25)
//{
//Create an encoder parameter for quality with an appropriate level setting
ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)50);
//}
// zc.Save(@"d:\1.jpg");
Directory.CreateDirectory(Path.GetDirectoryName(pathStrSelText) + @"\" + "bakPhoto" + @"\" + "reSize");
zc.Save((Path.GetDirectoryName(pathStrSelText) + @"\" + "bakPhoto" + @"\" + "reSize" + @"\" + Path.GetFileNameWithoutExtension(pathStrSelText) + Path.GetExtension(pathStrSelText)), ici, ep);
//Directory.CreateDirectory(Application.StartupPath + @"\bakPhoto");
//zc.Save(Application.StartupPath + @"\bakPhoto\" + Path.GetFileName(pathStrSelText), ici, ep);