drawString 出现黑边 怎么解决 如题 是用了bitmap以后出现的, 很费解!求大侠帮忙 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 谢二位了 代码是画一个日历可能关键的就是这几部分吧 反正没用bimap的时候一点问题都没有 用了以后字就有边了 private void drawPicture(Graphics aGraphics) { bool today = false; int y = Convert.ToInt32(t.Year); int m = Convert.ToInt32(t.Month); StringFormat drawFormat = new StringFormat(); drawFormat.FormatFlags = StringFormatFlags.DirectionVertical; int first = 0; GraphicsPath firstPath = new GraphicsPath(); Point[] firstArr = new Point[4]; firstArr[0] = new Point(20, 10); firstArr[1] = new Point(20 + with * 7, 10); firstArr[2] = new Point(20 + with * 7, 10 + 30); firstArr[3] = new Point(20, 10 + 30); firstPath.AddLines(firstArr); aGraphics.FillPath(Brushes.LightBlue, firstPath); Point[] pntArr = new Point[4]; GraphicsPath secondPath = new GraphicsPath(); pntArr[0] = new Point(20 + with * 5, 10 + 30); pntArr[1] = new Point(20 + with * 7, 10 + 30); pntArr[2] = new Point(20 + with * 7, 10 + 30 + height * 6); pntArr[3] = new Point(20 + with * 5, 10 + 30 + height * 6); secondPath.AddLines(pntArr); aGraphics.FillPath(Brushes.AliceBlue, secondPath); if (count > 0) { first = findFirstDayCrossForwardOneMonth(ref m, ref y); } else if (count < 0) { first = findFirstDayCrossBackwardOneMonth(ref m, ref y); } else { first = findFirstDayOfCurrentMonth(); today = true; } drawAssignmentsOrTests(first, m, y, aGraphics); //draw assginments and tests aGraphics.DrawString(y.ToString(), textMonth, new SolidBrush(Color.AliceBlue), new PointF(20 + with + 10, 10 + 35));//draw year aGraphics.DrawString(getMonth(m), textMonth, new SolidBrush(Color.White), new PointF(20 + with * 6 + 10, 10 + 20), drawFormat); //draw month drawTable(aGraphics); //draw table drawMonth(first, getTotalDaysOfMonth(m, y), aGraphics); if (today == true) { drawToday(first, aGraphics); } aGraphics.Dispose(); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); bmp = new Bitmap(1100, 600); Graphics g = Graphics.FromImage(bmp); drawPicture(g); CreateGraphics().DrawImage(bmp, 0, 0); }private void drawTable(Graphics g) { g.DrawLine(Pens.Black, new Point(20, 10), new Point(20 + with * 7, 10)); g.DrawLine(Pens.Black, new Point(20, 10 + 30), new Point(20 + with * 7, 10 + 30)); for (int i = 1; i <= 6; i++) //row { g.DrawLine(Pens.Black, new Point(20, 10 + 30 + height * i), new Point(20 + with * 7, 10 + 30 + height * i)); } for (int i = 0; i < 8; i++) //column { g.DrawLine(Pens.Black, new Point(20 + with * i, 10), new Point(20 + with * i, 10 + 30 + height * 6)); } for (int i = 0; i < 7; i++) //day { g.DrawString(day[i], head, new SolidBrush(Color.White), new PointF(20 + 20 + with * i, 15)); } } private void drawPicture(Graphics aGraphics) { bool today = false; int y = Convert.ToInt32(t.Year); int m = Convert.ToInt32(t.Month); StringFormat drawFormat = new StringFormat(); drawFormat.FormatFlags = StringFormatFlags.DirectionVertical; int first = 0; GraphicsPath firstPath = new GraphicsPath(); Point[] firstArr = new Point[4]; firstArr[0] = new Point(20, 10); firstArr[1] = new Point(20 + with * 7, 10); firstArr[2] = new Point(20 + with * 7, 10 + 30); firstArr[3] = new Point(20, 10 + 30); firstPath.AddLines(firstArr); aGraphics.FillPath(Brushes.LightBlue, firstPath); Point[] pntArr = new Point[4]; GraphicsPath secondPath = new GraphicsPath(); pntArr[0] = new Point(20 + with * 5, 10 + 30); pntArr[1] = new Point(20 + with * 7, 10 + 30); pntArr[2] = new Point(20 + with * 7, 10 + 30 + height * 6); pntArr[3] = new Point(20 + with * 5, 10 + 30 + height * 6); secondPath.AddLines(pntArr); aGraphics.FillPath(Brushes.AliceBlue, secondPath); if (count > 0) { first = findFirstDayCrossForwardOneMonth(ref m, ref y); } else if (count < 0) { first = findFirstDayCrossBackwardOneMonth(ref m, ref y); } else { first = findFirstDayOfCurrentMonth(); today = true; } drawAssignmentsOrTests(first, m, y, aGraphics); //draw assginments and tests aGraphics.DrawString(y.ToString(), textMonth, new SolidBrush(Color.AliceBlue), new PointF(20 + with + 10, 10 + 35));//draw year aGraphics.DrawString(getMonth(m), textMonth, new SolidBrush(Color.White), new PointF(20 + with * 6 + 10, 10 + 20), drawFormat); //draw month drawTable(aGraphics); //draw table drawMonth(first, getTotalDaysOfMonth(m, y), aGraphics); if (today == true) { drawToday(first, aGraphics); } aGraphics.Dispose(); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); bmp = new Bitmap(1100, 600); Graphics g = Graphics.FromImage(bmp); drawPicture(g); CreateGraphics().DrawImage(bmp, 0, 0); }private void drawTable(Graphics g) { g.DrawLine(Pens.Black, new Point(20, 10), new Point(20 + with * 7, 10)); g.DrawLine(Pens.Black, new Point(20, 10 + 30), new Point(20 + with * 7, 10 + 30)); for (int i = 1; i <= 6; i++) //row { g.DrawLine(Pens.Black, new Point(20, 10 + 30 + height * i), new Point(20 + with * 7, 10 + 30 + height * i)); } for (int i = 0; i < 8; i++) //column { g.DrawLine(Pens.Black, new Point(20 + with * i, 10), new Point(20 + with * i, 10 + 30 + height * 6)); } for (int i = 0; i < 7; i++) //day { g.DrawString(day[i], head, new SolidBrush(Color.White), new PointF(20 + 20 + with * i, 15)); } } 在DrawString前设置文字渲染,如果不想有毛刺边缘可以任选一种:'最高清晰度,不同显示模式或许会有些许毛刺 G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit'最基本的点阵模式,不会出现毛刺,但字形效果也差G.TextRenderingHint = Drawing.Text.TextRenderingHint.SingleBitPerPixel 我试过,这样好像不行。我是这样做的//在无提示的情况下使用每个字符的消除锯齿效果标志符号位图来绘制字符。由于采用了 AntiAlias,质量会得到改善。由于关闭了提示,主干宽度差可能会比较明显g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;//画到Bitmap上g.DrawString("asd", new Font( "宋体 ", 70f),new SolidBrush(Color.White),0,0);//将合成后的bitmap赋给控件的image来显示。picTime_bar.BackgroundImage = bgTimeBar; 如何判断dll是否注册到GAC上去了? (winform)C#2008中如何写app.config文件?? 紧急求问:WinForm界面的拖动 c#中使用CreateDIBSection造成内存泄露的问题。 请教一个登陆的问题急! 百分求一个所见即所得的html编辑控件 关于Null Object模式 怎样用Directx实现在屏幕上显示随机字符的效果?急!! Listview 问题求解 c#委托与事件+调用list<>的回调问题。 100分求助devExpress8.1打包 【WinForm问题】关于WebBrowser控件的一个问题..谢谢关注
可能关键的就是这几部分吧 反正没用bimap的时候一点问题都没有 用了以后字就有边了 private void drawPicture(Graphics aGraphics)
{
bool today = false;
int y = Convert.ToInt32(t.Year);
int m = Convert.ToInt32(t.Month);
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
int first = 0;
GraphicsPath firstPath = new GraphicsPath();
Point[] firstArr = new Point[4];
firstArr[0] = new Point(20, 10);
firstArr[1] = new Point(20 + with * 7, 10);
firstArr[2] = new Point(20 + with * 7, 10 + 30);
firstArr[3] = new Point(20, 10 + 30);
firstPath.AddLines(firstArr);
aGraphics.FillPath(Brushes.LightBlue, firstPath);
Point[] pntArr = new Point[4];
GraphicsPath secondPath = new GraphicsPath();
pntArr[0] = new Point(20 + with * 5, 10 + 30);
pntArr[1] = new Point(20 + with * 7, 10 + 30);
pntArr[2] = new Point(20 + with * 7, 10 + 30 + height * 6);
pntArr[3] = new Point(20 + with * 5, 10 + 30 + height * 6);
secondPath.AddLines(pntArr);
aGraphics.FillPath(Brushes.AliceBlue, secondPath); if (count > 0)
{
first = findFirstDayCrossForwardOneMonth(ref m, ref y);
}
else if (count < 0)
{
first = findFirstDayCrossBackwardOneMonth(ref m, ref y);
}
else
{
first = findFirstDayOfCurrentMonth();
today = true;
} drawAssignmentsOrTests(first, m, y, aGraphics); //draw assginments and tests
aGraphics.DrawString(y.ToString(), textMonth, new SolidBrush(Color.AliceBlue), new PointF(20 + with + 10, 10 + 35));//draw year
aGraphics.DrawString(getMonth(m), textMonth, new SolidBrush(Color.White), new PointF(20 + with * 6 + 10, 10 + 20), drawFormat); //draw month
drawTable(aGraphics); //draw table
drawMonth(first, getTotalDaysOfMonth(m, y), aGraphics);
if (today == true)
{
drawToday(first, aGraphics);
}
aGraphics.Dispose();
} protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
bmp = new Bitmap(1100, 600);
Graphics g = Graphics.FromImage(bmp);
drawPicture(g);
CreateGraphics().DrawImage(bmp, 0, 0);
}
private void drawTable(Graphics g)
{
g.DrawLine(Pens.Black, new Point(20, 10), new Point(20 + with * 7, 10));
g.DrawLine(Pens.Black, new Point(20, 10 + 30), new Point(20 + with * 7, 10 + 30));
for (int i = 1; i <= 6; i++) //row
{
g.DrawLine(Pens.Black, new Point(20, 10 + 30 + height * i), new Point(20 + with * 7, 10 + 30 + height * i));
}
for (int i = 0; i < 8; i++) //column
{
g.DrawLine(Pens.Black, new Point(20 + with * i, 10), new Point(20 + with * i, 10 + 30 + height * 6));
}
for (int i = 0; i < 7; i++) //day
{
g.DrawString(day[i], head, new SolidBrush(Color.White), new PointF(20 + 20 + with * i, 15));
}
}
private void drawPicture(Graphics aGraphics)
{
bool today = false;
int y = Convert.ToInt32(t.Year);
int m = Convert.ToInt32(t.Month);
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
int first = 0;
GraphicsPath firstPath = new GraphicsPath();
Point[] firstArr = new Point[4];
firstArr[0] = new Point(20, 10);
firstArr[1] = new Point(20 + with * 7, 10);
firstArr[2] = new Point(20 + with * 7, 10 + 30);
firstArr[3] = new Point(20, 10 + 30);
firstPath.AddLines(firstArr);
aGraphics.FillPath(Brushes.LightBlue, firstPath);
Point[] pntArr = new Point[4];
GraphicsPath secondPath = new GraphicsPath();
pntArr[0] = new Point(20 + with * 5, 10 + 30);
pntArr[1] = new Point(20 + with * 7, 10 + 30);
pntArr[2] = new Point(20 + with * 7, 10 + 30 + height * 6);
pntArr[3] = new Point(20 + with * 5, 10 + 30 + height * 6);
secondPath.AddLines(pntArr);
aGraphics.FillPath(Brushes.AliceBlue, secondPath); if (count > 0)
{
first = findFirstDayCrossForwardOneMonth(ref m, ref y);
}
else if (count < 0)
{
first = findFirstDayCrossBackwardOneMonth(ref m, ref y);
}
else
{
first = findFirstDayOfCurrentMonth();
today = true;
} drawAssignmentsOrTests(first, m, y, aGraphics); //draw assginments and tests
aGraphics.DrawString(y.ToString(), textMonth, new SolidBrush(Color.AliceBlue), new PointF(20 + with + 10, 10 + 35));//draw year
aGraphics.DrawString(getMonth(m), textMonth, new SolidBrush(Color.White), new PointF(20 + with * 6 + 10, 10 + 20), drawFormat); //draw month
drawTable(aGraphics); //draw table
drawMonth(first, getTotalDaysOfMonth(m, y), aGraphics);
if (today == true)
{
drawToday(first, aGraphics);
}
aGraphics.Dispose();
} protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
bmp = new Bitmap(1100, 600);
Graphics g = Graphics.FromImage(bmp);
drawPicture(g);
CreateGraphics().DrawImage(bmp, 0, 0);
}
private void drawTable(Graphics g)
{
g.DrawLine(Pens.Black, new Point(20, 10), new Point(20 + with * 7, 10));
g.DrawLine(Pens.Black, new Point(20, 10 + 30), new Point(20 + with * 7, 10 + 30));
for (int i = 1; i <= 6; i++) //row
{
g.DrawLine(Pens.Black, new Point(20, 10 + 30 + height * i), new Point(20 + with * 7, 10 + 30 + height * i));
}
for (int i = 0; i < 8; i++) //column
{
g.DrawLine(Pens.Black, new Point(20 + with * i, 10), new Point(20 + with * i, 10 + 30 + height * 6));
}
for (int i = 0; i < 7; i++) //day
{
g.DrawString(day[i], head, new SolidBrush(Color.White), new PointF(20 + 20 + with * i, 15));
}
}
G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit'最基本的点阵模式,不会出现毛刺,但字形效果也差
G.TextRenderingHint = Drawing.Text.TextRenderingHint.SingleBitPerPixel
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;//画到Bitmap上
g.DrawString("asd", new Font( "宋体 ", 70f),new SolidBrush(Color.White),0,0);//将合成后的bitmap赋给控件的image来显示。
picTime_bar.BackgroundImage = bgTimeBar;