读书人

GDI画字符串 画不出来解决办法

发布时间: 2013-08-06 16:47:25 作者: rapoo

GDI画字符串 画不出来

private void button1_Click(object sender, EventArgs e)
{
Bitmap bm = new Bitmap(200, 200);
Graphics g = Graphics.FromImage(bm);
g.Clear(Color.Black);
g.DrawString("asdwqeqr", new Font("宋体", 14), new SolidBrush(Color.Blue), 20, 10);
}

为什么那个字符串画不出来啊 gdi Bitmap
[解决办法]
解决啥,你只是把文字绘制在bm上, 但你没有设置任何组件的背景为bm,显示到哪里都没写
[解决办法]
你那个bitmap在内存里面,并没有在界面上显示出来
你可以用picturebox.Image = bm

[解决办法]
引用:
Quote: 引用:

Quote: 引用:

那个控件也是画的 而且有一个bitmap在上面显示了 在加一个那块区域就一直闪 那块区域是刷新的

如果控件你也重绘了,那你要用那个控件的Graphics.DrawImage(bm...)
把你生成的图再画到那个控件上

            if ((0 != m_stConfig.rectScreenShow2.Width) 
[解决办法]
(0 != m_stConfig.rectScreenShow2.Height))
{
Bitmap bmpBack2 = bmpBack.Clone(m_stConfig.rectScreenShow2, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
m_LabelShow2.BackgroundImage = bmpBack2;
}

这是那些代码 m_LabelShow2是绘制 它找不到Graphics.DrawImage这个方法啊



Graphics要从某控件创建,比如当前窗体就可以这样this.CreateGraphics().DrawImage(...);

Control.CreateGraphics();

读书人网 >C#

热点推荐