VS环境下C# picturebox打开TIF文件,如何才能避免内存不足而出错。。。。?
VS2005环境下C#picturebox打开TIF文件,如何才能避免内存不足而出错。。。。?...
VS2005环境下C# picturebox打开TIF文件,如何才能避免内存不足而出错。。。。?
展开
2011-04-20
展开全部
ging;
public Image MyImage;
public FrameDimension MyGuid;
public static int MyPos=0;
private void button3_Click(object sender, EventArgs e)
{//浏览图像
OpenFileDialog MyDlg=new OpenFileDialog();
MyDlg.Filter = "所有TIFF图像文件(*.tiff)|*.tiff";
MyDlg.Multiselect = false;
if (MyDlg.ShowDialog() ==DialogResult.OK)
{
String MyFileName=MyDlg.FileName;
MyImage=Image.FromFile(MyFileName);
MyPos=0;
MyGuid=FrameDimension.Page;
MyImage.SelectActiveFrame(MyGuid,MyPos);
pictureBox1.Image=MyImage;
}
}
private void button4_Click(object sender, EventArgs e)
{//上一图像
try
{
MyPos = MyPos - 1;
MyImage.SelectActiveFrame(MyGuid, MyPos);
pictureBox1.Image = MyImage;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button5_Click(object sender, EventArgs e)
{//下一图像
try
{
MyPos=MyPos+1;
MyImage.SelectActiveFrame(MyGuid,MyPos);
pictureBox1.Image=MyImage;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
这是核心代码,经过调试的,保证正确 VS2005下
另外,虚机团上产品团购,超级便宜
public Image MyImage;
public FrameDimension MyGuid;
public static int MyPos=0;
private void button3_Click(object sender, EventArgs e)
{//浏览图像
OpenFileDialog MyDlg=new OpenFileDialog();
MyDlg.Filter = "所有TIFF图像文件(*.tiff)|*.tiff";
MyDlg.Multiselect = false;
if (MyDlg.ShowDialog() ==DialogResult.OK)
{
String MyFileName=MyDlg.FileName;
MyImage=Image.FromFile(MyFileName);
MyPos=0;
MyGuid=FrameDimension.Page;
MyImage.SelectActiveFrame(MyGuid,MyPos);
pictureBox1.Image=MyImage;
}
}
private void button4_Click(object sender, EventArgs e)
{//上一图像
try
{
MyPos = MyPos - 1;
MyImage.SelectActiveFrame(MyGuid, MyPos);
pictureBox1.Image = MyImage;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button5_Click(object sender, EventArgs e)
{//下一图像
try
{
MyPos=MyPos+1;
MyImage.SelectActiveFrame(MyGuid,MyPos);
pictureBox1.Image=MyImage;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
这是核心代码,经过调试的,保证正确 VS2005下
另外,虚机团上产品团购,超级便宜
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询