C# C中位图图像上未显示文本

C# C中位图图像上未显示文本,c#,image,text,C#,Image,Text,我似乎无法将我编写的文本显示在我的图像上这是我正在使用的代码 //Creates a bitmap with the path to the current image Bitmap LabelImage = new Bitmap(dtImages.Rows[intCurrentImage]["ImageURL"].ToString()); Graphics graphic = Graphics.FromImage(LabelImage); graphic.DrawString("Hello

我似乎无法将我编写的文本显示在我的图像上这是我正在使用的代码

//Creates a bitmap with the path to the current image
Bitmap LabelImage = new Bitmap(dtImages.Rows[intCurrentImage]["ImageURL"].ToString());

Graphics graphic = Graphics.FromImage(LabelImage);

graphic.DrawString("Hello", new Font("Tahoma",40), Brushes.Azure, new System.Drawing.Point(0,0));

//put Image that I just created and put the text on into an Infragistics UltraPicureBox
picImage.Image = LabelImage

您没有更新原始图像LabelImage,为什么要显示添加到图形对象中的文本

来自MSDN:

从指定的图像创建新图形

重点矿山

添加文本后,需要保存更改:

graphic.Save();
与您的问题无关,您应该将图形对象的创建放在using语句中,以确保正确处理:

using(Graphics graphic = Graphics.FromImage(LabelImage))
{
   // use graphic here
}

您没有更新原始图像LabelImage,为什么要显示添加到图形对象中的文本

来自MSDN:

从指定的图像创建新图形

重点矿山

添加文本后,需要保存更改:

graphic.Save();
与您的问题无关,您应该将图形对象的创建放在using语句中,以确保正确处理:

using(Graphics graphic = Graphics.FromImage(LabelImage))
{
   // use graphic here
}
我刚试过这个

 Bitmap bitmap = new Bitmap("C:\\Untitled.png");
 Graphics g = Graphics.FromImage(bitmap);
 g.DrawString("Hello", new Font("Tahoma", 40), Brushes.Azure, new System.Drawing.Point(0, 0));
 pictureBox1.Image = bitmap;
这对我来说很好。试着挑一支对比鲜明的画笔。

我刚试过这个

 Bitmap bitmap = new Bitmap("C:\\Untitled.png");
 Graphics g = Graphics.FromImage(bitmap);
 g.DrawString("Hello", new Font("Tahoma", 40), Brushes.Azure, new System.Drawing.Point(0, 0));
 pictureBox1.Image = bitmap;
这对我来说很好。试着挑选一支对比鲜明的画笔