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
展开
 我来答
freeeeeewind
2014-11-25 · TA获得超过1万个赞
知道大有可为答主
回答量:3227
采纳率:94%
帮助的人:1312万
展开全部
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
    ……
    if (IsLoadBmp)
    {
        ……
    }
}

IsLoadBmp为true吗?如果为false,picitureBox1.Refresh()就没有用!

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式