How to add text to an image in C # or vb.net

Hello,

am the average visual studio programmer, I need a function or subroutine to add text to the image button, not on it, as shown in the image alt text

please ideas

[change]

  • Programming with visual studio 2008, on winxp.
  • The application is a console application.
  • he will run win2000 up
  • I will save the result after adding text to the file
+8
c # text image
source share
1 answer
  • Create a bitmap with the new desired size

  • Copy the original image at the top of the new bitmap

  • Write the text you want in a new bitmap

Something like this: (untested)

var bmp = Bitmap.FromFile("orig.jpg"); var newImage = new Bitmap(bmp.Width, bmp.Height + 50); var gr = Graphics.FromImage(newImage); gr.DrawImageUnscaled(bmp, 0, 0); gr.DrawString("this is the added text", SystemFonts.DefaultFont, Brushes.Black , new RectangleF(0, bmp.Height, bmp.Width, 50)); newImage.Save("newImg.jpg"); 
+15
source share

Source: https://habr.com/ru/post/650642/


All Articles