我的图像以拉伸到原始尺寸的3倍的形式显示 我想在图像上写文字,而不是文本被拉伸 这是可能的,如果是的话,怎么样?
我尝试过(在刷新方法中):
//On Form //my Bitmap
ImageDisplay.Image = IntensityBMP;
Graphics g = Graphics.FromImage(ImageDisplay.Image);
g.DrawString("MyText", new Font("Tahoma", 8), Brushes.White, etc);
and
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawString("MyText", new Font("Tahoma", 8), etc);
base.OnPaint(e);
}
两者都在预拉伸图像上绘制文本,导致像素化,文本过大。
答案 0 :(得分:2)
您需要在PictureBox渲染图像后绘制文本。
或者:
myForm.pictureBox1.Paint += PictureBoxPaintEvent;
private void PictureBoxPaintEvent(object sender, PaintEventArgs e)
{
e.Graphics.DrawString("MyText", myFont, ....);
}
OR
创建PictureBox
派生类并覆盖Paint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString("MyText", new Font("Tahoma", 8), etc);
}