how do i add text to image in c# or vb.net

后端 未结 1 505
夕颜
夕颜 2020-12-10 15:59

HELLO,

am an average visual studio programmer, i need a function or routine to add text to the button of an image not on it like i showed in the image

相关标签:
1条回答
  • 2020-12-10 16:39
    • Create a bitmap with the new size you want

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

    • Write the text you want onto the 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");
    
    0 讨论(0)
提交回复
热议问题