日期:2014-05-17 浏览次数:20963 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
namespace BatchChangeImgFormat {
public partial class Form1: Form {
#region
private string[] picNames = null; //选择转换的所有图片路径.
private string strSavePath = null; //转换后存储的路径.
private int nFormat; //标志选择转换的格式.
private Bitmap bMap; //转换用的BitMap.
#endregion
public Form1() {
InitializeComponent();
tsbtn_Open.Click += (sender, e) => InitializeSelectedPics(sender, e); //加载图片.
this.Load += (sender, e) => { tscombox_ChangeFormat.SelectedIndex = 0; }; //初始选择第一项.
tsbtnClear.Click += (sender, e) => ClearSelectedPic(sender, e); //清空列表.
tsbtn_Save.Click += (sender, e) => StorePathAfterChanged(sender, e);//存储转换后保存图片的路径.
tsbtnStart.Click += (sender, e) => ConvertFormatSelected(sender, e); //开始转换.
tsbtnClose.Click += (sender, e) => CloseForm(sender, e); //关闭.
}
//加载需要转换的图片.
void InitializeSelectedPics(object sender, EventArgs e) {
openFD.Filter = "所有图片|*.jpg;*.jpeg;*.gif;*.bmp;*.png";
if(openFD.ShowDialog() != DialogResult.OK) return;