private void RotateDocument(int angle)
{
ImageViewer imageViewer=null;
if(combineParameter.isCombineStatus)
{
if(combineParameter.selectedIndex>=0)
{
imageViewer = (ImageViewer)CombineTableLayoutPanel.Controls[combineParameter.selectedIndex];
}
}
else
{
int viewCount = tableLayoutPanelColumnCount * tableLayoutPanelRowCount;
int index = 0;
if(viewCount>1)
{
index = CurrentPageIndex % viewCount;
}
imageViewer = (ImageViewer)tableLayoutPanel.Controls[index];
}
if (/*imageViewer2*/imageViewer.Image == null) return;
// RotateCommand rotateCommand = new RotateCommand(angle * 100, RotateCommandFlags.Resize, new RasterColor(255, 255, 255));
try
{
using (WaitCursor waitCursor = new WaitCursor())
{
//缓存图片处理
_cacheNumber = CurrentPageIndex;
if (_cacheImageList.Count < 6)
{
_cacheImageList.Add(imageViewer.Image.Clone());
}
else
{
_cacheImageList.RemoveAt(1);
_cacheImageList.Add(imageViewer.Image.Clone());
}
ImageProcessing imageProcessing = new ImageProcessing();
imageProcessing.RotateDocument(angle, imageViewer.Image);
//rotateCommand.Run(imageViewer2.Image);
//_ocrPage.SetRasterImage(imageViewer2.Image);
string filename = _tempFilePath + (CurrentPageIndex + 1).ToString() + ".tif";
_codecs.Save(imageViewer.Image, filename, RasterImageFormat.CcittGroup4, 1);
}
}
catch (Exception)
{
MessageBox.Show("系统出错");
}
finally
{
UpdateOneThumbnail();
//UpdateLeftPanle();
}
}
|