【发布时间】:2014-08-07 04:58:21
【问题描述】:
我有两个图片框:一个在背景中,里面有一个图像(picturebox1),另一个(pic1)我想画一些东西(这个背景应该是透明的。--> pic1.BackColor = Color.Transparent ;)
看起来像这样:
除了字体,一切都很好。为什么它有黑色边框?
我的代码是这样的:
private void InBitmapZeichnen()
{
Graphics g1 = Graphics.FromImage(bmp12);
g1.PageUnit = GraphicsUnit.Pixel;
//g1.InterpolationMode = InterpolationMode.HighQualityBilinear;
Font f = new Font("Verdana", 8f);
Font f1 = new Font("Verdana", 8f);
Font f2 = new Font("Verdana", 10, System.Drawing.FontStyle.Bold);
Brush b = new SolidBrush(Color.YellowGreen);
Brush b1 = new SolidBrush(Color.YellowGreen);
Pen PenRaster = new Pen(Color.Black, 0.1f);
if (mnuRaster.Checked == true)
{
float j = Rohrdurchmesser / (float)(trk.Value + 2);
//g1.SmoothingMode = SmoothingMode.HighSpeed;
for (int i = pic1.Width / (trk.Value + 2); i <= pic1.Width - pic1.Width / (trk.Value + 2); i += pic1.Width / (trk.Value + 2))
{
PointF PRaster1 = new PointF(i, 0);
PointF PRaster2 = new PointF(i, pic1.Bottom);
PointF PRaster3 = new PointF(0, i+4);
PointF PRaster4 = new PointF(pic1.Right, i+4);
g1.DrawString((j).ToString("0") + " mm", f, b, new PointF(i + 5, 5));
g1.DrawString((j).ToString("0") + " mm", f, b, new PointF(5, i + 5));
g1.DrawLine(PenRaster, PRaster1, PRaster2);
g1.DrawLine(PenRaster, PRaster3, PRaster4);
j += Rohrdurchmesser / (float)(trk.Value + 2);
}
}
}
当我为背景色选择一种颜色时,它可以正常工作:
【问题讨论】:
-
我已经编辑了你的标题。请不要包含有关问题标题中使用的语言的信息,除非没有它就没有意义。标签用于此目的。另请参阅"Should questions include “tags” in their titles?",其中的共识是“不,他们不应该
标签: c# image transparency picturebox