string STR="hello";
Graphics g=Graphics. FromImage (new Bitmap (1, 1));
The Font Font=new Font (" tahoma ", 9);
SizeF SizeF=g. easureString (STR, the font);//measure the font height and width of the
Brush Brush;//brush, color
Brush=Brushes. Lime;
PointF pf=new PointF (0, 0);
Bitmap img=new Bitmap (Convert ToInt32 (sizeF. Width), Convert the ToInt32 (sizeF. Height));
G=Graphics. FromImage (img);
G.D rawString (STR, the font, brush, pf);
//output images
MemoryStream ms=new MemoryStream ();
Img. Save (ms, System. Drawing. Imaging. ImageFormat. Gif);
The Response. BinaryWrite (Ms. ToArray ());
Somebody gave me a C code to solve, but the out background will still be some larger than words, excuse me each ace to have what way to deal with this problem?
CodePudding user response:
The only based on pixel judgment after finished cutting,Because different text size is different, you use a few words did not fill, so big is not equal to all the othercharacters in a word,