using
System;
using System.Drawing ;
using System.Drawing.Imaging ;
using System.IO;
namespace FaxCast1.Standard.Fax
... {
/**//// <summary>
/// clsImage 的摘要说明。
/// </summary>
public class clsImage
...{
private double curZoom=0.1;//设置放大缩小比例
private Image curImage=null;//处理图片
private PubModule.PublicModule objMyPub=PubModule.PublicModule.GetMe();
private System.Windows.Forms.PictureBox pb=null;
int InitHeight=0;
int InitWidth=0;
public clsImage(Image DealImage)
...{
curImage=DealImage;
InitHeight=curImage.Height;
InitWidth=curImage.Width;
}
//设置放大缩小比例
public double dZoom
...{
set
...{
curZoom=value;
}
get
...{
return curZoom;
}
}
//设置图片存放容器
public System.Windows.Forms.PictureBox pictureBox
...{
set
...{
pb=value;
}
get
...{
return pb;
}
}
//旋转图片,bRight表示是否顺时转
public void Rotate90(bool bRight)
...{
if ( curImage!=null)
...{
try
...{
if ( bRight==true)
curImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
else
curImage.RotateFlip(RotateFlipType.Rotate270FlipNone);
if (pb!=null)
...{
pb.Image =curImage;
pb.SizeMode =System.Windows.Forms.PictureBoxSizeMode.AutoSize;
}
}
catch(Exception ex)
...{
objMyPub.Log("clsImage.Rotate90:"+ ex.Message.ToString(),1);
}
}
}
//放大或者缩小图片#region//放大或者缩小图片
public void ChangeImageSize(bool bSmall)
...{
try
...{
if ( curImage!=null)
...{
int iHeight=0;
int iWidth=0;
if ( bSmall==true)
...{
iHeight=Convert.ToInt16(curImage.Height-InitHeight*curZoom);
iWidth=Convert.ToInt16(curImage.Width- InitWidth*curZoom);
if ( iHeight<0)
iHeight=1;
if ( iWidth<0)
iWidth=1;
}
else
...{
iHeight=Convert.ToInt16(curImage.Height+InitHeight*curZoom);
iWidth=Convert.ToInt16(curImage.Width+ InitWidth*curZoom);
}
curImage=new Bitmap(curImage,iWidth,iHeight);
if (pb!=null)
...{
pb.Image =curImage;
pb.SizeMode =System.Windows.Forms.PictureBoxSizeMode.AutoSize;
}
}
}
catch(Exception ex)
...{
objMyPub.Log("ChangeImageSize:"+ ex.Message.ToString(),1);
}
}
#endregion
public void FillPictureBox()
...{
try
...{
if ( curImage!=null && pb!=null)
...{
pb.Image=curImage;
pb.SizeMode=System.Windows.Forms.PictureBoxSizeMode.AutoSize ;
}
}
catch(Exception ex)
...{
objMyPub.Log("FillPictureBox:"+ ex.Message.ToString(),1);
}
}
public void SaveImageFile(ref string strPath)
...{
if (curImage==null)
return ;
try
...{
if ( strPath.Length <1)
strPath=@"c:";
strPath=strPath+System.DateTime.Now.ToString("yyyy-MM-dd HH_mm_ss")+".tif";
curImage.Save(strPath);
}
catch(Exception ex)
...{
objMyPub.Log("SaveImageFile:"+ ex.Message.ToString(),1);
return ;
}
}
//取得传真文件的总页数
public int GetTifTotalPage()
...{
try
...{
Guid gd=(Guid)curImage.FrameDimensionsList.GetValue(0);
FrameDimension frd=new FrameDimension(gd);
int iTotalPage = curImage.GetFrameCount(frd);
return iTotalPage;
}
catch(Exception ex)
...{
objMyPub.Log(ex.Message.ToString(),1);
return 0;
}
}
//取得指定页内容
public Image GetCurrentPage(int iPageNum)
...{
try
...{
Image TempImage=curImage;
Guid gd=(Guid)TempImage.FrameDimensionsList.GetValue(0);
FrameDimension frd=new FrameDimension(gd);
int iTotalPage = TempImage.GetFrameCount(frd);
TempImage.SelectActiveFrame(frd,iPageNum);
return TempImage;
}
catch(Exception ex)
...{
objMyPub.Log(ex.Message.ToString(),1);
return null;
}
}
}
}
using System.Drawing ;
using System.Drawing.Imaging ;
using System.IO;
namespace FaxCast1.Standard.Fax
... {
/**//// <summary>
/// clsImage 的摘要说明。
/// </summary>
public class clsImage
...{
private double curZoom=0.1;//设置放大缩小比例
private Image curImage=null;//处理图片
private PubModule.PublicModule objMyPub=PubModule.PublicModule.GetMe();
private System.Windows.Forms.PictureBox pb=null;
int InitHeight=0;
int InitWidth=0;
public clsImage(Image DealImage)
...{
curImage=DealImage;
InitHeight=curImage.Height;
InitWidth=curImage.Width;
}
//设置放大缩小比例
public double dZoom
...{
set
...{
curZoom=value;
}
get
...{
return curZoom;
}
}
//设置图片存放容器
public System.Windows.Forms.PictureBox pictureBox
...{
set
...{
pb=value;
}
get
...{
return pb;
}
}
//旋转图片,bRight表示是否顺时转
public void Rotate90(bool bRight)
...{
if ( curImage!=null)
...{
try
...{
if ( bRight==true)
curImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
else
curImage.RotateFlip(RotateFlipType.Rotate270FlipNone);
if (pb!=null)
...{
pb.Image =curImage;
pb.SizeMode =System.Windows.Forms.PictureBoxSizeMode.AutoSize;
}
}
catch(Exception ex)
...{
objMyPub.Log("clsImage.Rotate90:"+ ex.Message.ToString(),1);
}
}
}
//放大或者缩小图片#region//放大或者缩小图片
public void ChangeImageSize(bool bSmall)
...{
try
...{
if ( curImage!=null)
...{
int iHeight=0;
int iWidth=0;
if ( bSmall==true)
...{
iHeight=Convert.ToInt16(curImage.Height-InitHeight*curZoom);
iWidth=Convert.ToInt16(curImage.Width- InitWidth*curZoom);
if ( iHeight<0)
iHeight=1;
if ( iWidth<0)
iWidth=1;
}
else
...{
iHeight=Convert.ToInt16(curImage.Height+InitHeight*curZoom);
iWidth=Convert.ToInt16(curImage.Width+ InitWidth*curZoom);
}
curImage=new Bitmap(curImage,iWidth,iHeight);
if (pb!=null)
...{
pb.Image =curImage;
pb.SizeMode =System.Windows.Forms.PictureBoxSizeMode.AutoSize;
}
}
}
catch(Exception ex)
...{
objMyPub.Log("ChangeImageSize:"+ ex.Message.ToString(),1);
}
}
#endregion
public void FillPictureBox()
...{
try
...{
if ( curImage!=null && pb!=null)
...{
pb.Image=curImage;
pb.SizeMode=System.Windows.Forms.PictureBoxSizeMode.AutoSize ;
}
}
catch(Exception ex)
...{
objMyPub.Log("FillPictureBox:"+ ex.Message.ToString(),1);
}
}
public void SaveImageFile(ref string strPath)
...{
if (curImage==null)
return ;
try
...{
if ( strPath.Length <1)
strPath=@"c:";
strPath=strPath+System.DateTime.Now.ToString("yyyy-MM-dd HH_mm_ss")+".tif";
curImage.Save(strPath);
}
catch(Exception ex)
...{
objMyPub.Log("SaveImageFile:"+ ex.Message.ToString(),1);
return ;
}
}
//取得传真文件的总页数
public int GetTifTotalPage()
...{
try
...{
Guid gd=(Guid)curImage.FrameDimensionsList.GetValue(0);
FrameDimension frd=new FrameDimension(gd);
int iTotalPage = curImage.GetFrameCount(frd);
return iTotalPage;
}
catch(Exception ex)
...{
objMyPub.Log(ex.Message.ToString(),1);
return 0;
}
}
//取得指定页内容
public Image GetCurrentPage(int iPageNum)
...{
try
...{
Image TempImage=curImage;
Guid gd=(Guid)TempImage.FrameDimensionsList.GetValue(0);
FrameDimension frd=new FrameDimension(gd);
int iTotalPage = TempImage.GetFrameCount(frd);
TempImage.SelectActiveFrame(frd,iPageNum);
return TempImage;
}
catch(Exception ex)
...{
objMyPub.Log(ex.Message.ToString(),1);
return null;
}
}
}
}