Home > Software engineering >  Vb.net mapping problem
Vb.net mapping problem

Time:10-25

I want to draw a text into images, font, font size, words are dynamically, the final mapping requirement is background must be the same as the previous word is big! you are the first to get to the text segment width and then draw the background image, then the text then plotted on a background image synthesis a picture?
 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,
  • Related