// 用于保存执行了所有操作的图片
        public void SavePhoto()
        {
            Bitmap image    = null;
            Bitmap orgImage = null;

            try
            {
                // 读入原始图片及其原始格式
                Cursor.Current = Cursors.WaitCursor;
                Global.Progress.Update(this, "Processing photo", 1, 2);
                // 确保图片不是只读的
                if (FileManager.IsFileReadOnly(Photo.PhotoPath))
                {
                    throw new ApplicationException(string.Format("The photo \'{0}\' is read-only.", _photo.PhotoPath));
                }
                // 创建可被保存的图片(原始图片的拷贝),保存原始图片知道我们将操作执行于新图片之上
                // 然后使用原始图片来拷贝exif信息
                orgImage = new Bitmap(_photo.PhotoPath);
                // 需要拷贝以便覆写原始图片
                image = new Bitmap(orgImage);
                // 存储此图片的格式,用于后面的保存
                ImageFormat format = orgImage.RawFormat;
                Global.Progress.Complete(this);
                Cursor.Current = Cursors.Default;
                // 在图片上执行所有的操作
                OptimizeActions optimize = new OptimizeActions();
                optimize.Apply(ref image, 0.0F);
                // 在保存前拷贝exif信息
                if (Global.Settings.GetBool(SettingKey.MaintainExifInfo))
                {
                    Exif.Copy(orgImage, image);
                }
                // 在覆写前需要关闭原始图片
                orgImage.Dispose();
                orgImage = null;
                // 将图片存回文件系统
                Global.Progress.Update(this, "Saving photo", 2, 2);
                image.Save(_photo.PhotoPath, format);
                OnNewPhoto(_photo.PhotoPath, image, format);
            }
            catch (Exception ex)
            {
                Global.DisplayError(string.Format("The file \'{0}\' could not be saved.", _photo.PhotoName), ex);
            }
            finally
            {
                // 消除操作
                if (!(orgImage == null))
                {
                    orgImage.Dispose();
                }
                if (!(image == null))
                {
                    image.Dispose();
                }
            }
            //  the crop area should be cleared
            Global.Progress.Complete(this);
            Cursor.Current = Cursors.Default;
        }
        // 在列表中选中的缩略图上执行参数中指定的旋转操作
        private void RotateThumbnails(ActionItem actionItem)
        {
            Bitmap image    = null;
            Bitmap orgImage = null;

            try
            {
                int pos = 1;
                // 要显示的状态栏信息
                string message = string.Format("Processing photo{0}", ((listView.SelectedItems.Count == 1) ? "" : "s"));
                // 将指定的操作实施到选定的图片上
                foreach (ListViewItem item in listView.SelectedItems)
                {
                    Global.Progress.Update(this, message, pos, listView.SelectedItems.Count);
                    pos++;
                    // 确定如何旋转图片
                    RotateFlipType flipType = RotateFlipType.RotateNoneFlipNone;
                    switch (actionItem.Action)
                    {
                    case PhotoAction.RotateLeft:
                        flipType = RotateFlipType.Rotate270FlipNone;
                        break;

                    case PhotoAction.RotateRight:
                        flipType = RotateFlipType.Rotate90FlipNone;
                        break;

                    case PhotoAction.FlipHorizontal:
                        flipType = RotateFlipType.RotateNoneFlipX;
                        break;

                    case PhotoAction.FlipVertical:
                        flipType = RotateFlipType.RotateNoneFlipY;
                        break;
                    }
                    // 获取图片对象
                    Photo photo = (Photo)item.Tag;
                    //// 确保图片不处于只读模式
                    //if (FileManager.IsFileReadOnly(photo.PhotoPath))
                    //{
                    //    throw new ApplicationException(string.Format("The photo \'{0}\' is read-only.", photo.PhotoPath));
                    //}

                    // 创建两个图片对象,image用于在图片上执行操作并保存
                    // orgImage用作原始图片的副本,用于在对image执行操作后其拷贝exif信息
                    orgImage = new Bitmap(photo.Thumbnail, photo.Thumbnail.Width, photo.Thumbnail.Height);
                    // 需要做一个拷贝以便覆写源图片
                    image = new Bitmap(orgImage);
                    // 保留图片的格式信息,用于后面的保存操作
                    ImageFormat format = orgImage.RawFormat;
                    // 旋转图片
                    image.RotateFlip(flipType);
                    // 在保存前拷贝exif信息
                    if (Global.Settings.GetBool(SettingKey.MaintainExifInfo))
                    {
                        Exif.Copy(orgImage, image);
                    }
                    // 需要在覆写前关闭原始图片
                    orgImage.Dispose();
                    orgImage = null;
                    //保存图片
                    //image.Save(photo.PhotoPath, format);
                    photo.Thumbnail = image;
                    image.Dispose();
                    image = null;
                }
            }
            catch
            {
                // 执行清除操作
                if (!(orgImage == null))
                {
                    orgImage.Dispose();
                }
                if (!(image == null))
                {
                    image.Dispose();
                }
                //Global.DisplayError("The photo could not be rotated.", ex);
            }
        }