Public StaticBitmap getpiewithtext (String text, color color, color Fontcolor,font Font) {intSize = A; Bitmap BMP=NewBitmap (size, size); Graphics g=graphics.fromimage (BMP); G.smoothingmode= Smoothingmode.antialias;//make the highest quality of the drawing, anti-aliasingG.interpolationmode =interpolationmode.highqualitybicubic; G.compositingquality=compositingquality.highquality; G.textrenderinghint=Textrenderinghint.cleartypegridfit; G.fillpie (NewSolidBrush (color),NewRectangle (0,0, size-1, Size-1),0, the); G.smoothingmode= Smoothingmode.default; G.interpolationmode =Interpolationmode.default; G.compositingquality=Compositingquality.default;StringFormat StringFormat =NewStringFormat (); Stringformat.alignment=Stringalignment.center; if(text. ToString (). Length = =2{g.drawstring (text). ToString (), Font,NewSolidBrush (FontColor),NewRectangle (0,0, size-1, Size-1), StringFormat); } Elseg.drawstring (text. ToString (), Font,NewSolidBrush (FontColor),NewRectangle (0,0, Size-1, Size-1), StringFormat); returnbmp;}
First use the above code to solve, has not resolved the problem, and later adjusted the size of the plot area to solve the problem, for everyone to refer to.
C # A case of a solution to drawing a font that is not clear