如题 
是用了bitmap以后出现的, 很费解!求大侠帮忙

解决方案 »

  1.   

    谢二位了 代码是画一个日历
    可能关键的就是这几部分吧 反正没用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));
                }
            }
      

  2.   


    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));
                }
            }
      

  3.   

    在DrawString前设置文字渲染,如果不想有毛刺边缘可以任选一种:'最高清晰度,不同显示模式或许会有些许毛刺        
    G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit'最基本的点阵模式,不会出现毛刺,但字形效果也差
    G.TextRenderingHint = Drawing.Text.TextRenderingHint.SingleBitPerPixel
      

  4.   

    我试过,这样好像不行。我是这样做的//在无提示的情况下使用每个字符的消除锯齿效果标志符号位图来绘制字符。由于采用了 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;