C# picturebox的paint方法调用(代码如下)
privatevoidbutton1_Click(objectsender,EventArgse){stringfilename="";OpenFileDialogdlg...
private void button1_Click(object sender, EventArgs e)
{
string filename = "";
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "Tiff文件|*.tif|Erdas img文件|*.img|Bmp文件|*.bmp|jpeg文件|*.jpg|所有文件|*.*";
if (dlg.ShowDialog() == DialogResult.OK)
{
filename = dlg.FileName;
}
Rectangle pictureRect = new Rectangle();
pictureRect.X = 0;
pictureRect.Y = 0;
pictureRect.Width = this.pictureBox1.Width;
pictureRect.Height = this.pictureBox1.Height;
int[] disband = { 1, 2, 3 };
Bitmap bitmap = GetImage(pictureRect, disband); //遥感影像构建位图
bmp = bitmap; //将位图传递给PictureBox控件进行显示
pictureBox1.Refresh();
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
if (IsLoadBmp)
{
Rectangle rect = new Rectangle(0, 0, pictureBox1 .Width , pictureBox1 .Height );
int[] bandlist = { 1, 2, 3 };
bmp = GetImage(rect, bandlist);
g.InterpolationMode = InterpolationMode.NearestNeighbor;
g.FillRectangle(Brushes.Red, pictureBox1.ClientRectangle);
g.DrawImage(bmp, 0, 0);
}
}
refresh方法无法触发paint 展开
{
string filename = "";
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "Tiff文件|*.tif|Erdas img文件|*.img|Bmp文件|*.bmp|jpeg文件|*.jpg|所有文件|*.*";
if (dlg.ShowDialog() == DialogResult.OK)
{
filename = dlg.FileName;
}
Rectangle pictureRect = new Rectangle();
pictureRect.X = 0;
pictureRect.Y = 0;
pictureRect.Width = this.pictureBox1.Width;
pictureRect.Height = this.pictureBox1.Height;
int[] disband = { 1, 2, 3 };
Bitmap bitmap = GetImage(pictureRect, disband); //遥感影像构建位图
bmp = bitmap; //将位图传递给PictureBox控件进行显示
pictureBox1.Refresh();
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
if (IsLoadBmp)
{
Rectangle rect = new Rectangle(0, 0, pictureBox1 .Width , pictureBox1 .Height );
int[] bandlist = { 1, 2, 3 };
bmp = GetImage(rect, bandlist);
g.InterpolationMode = InterpolationMode.NearestNeighbor;
g.FillRectangle(Brushes.Red, pictureBox1.ClientRectangle);
g.DrawImage(bmp, 0, 0);
}
}
refresh方法无法触发paint 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询