Reputation: 5802
I am looking for a solution\software that I can use in order to render buttons in real time. That is, I have an image and text, and I want them to be an image altogether in realtime.
Thank you
Upvotes: 2
Views: 630
Reputation: 14518
You can dynamically create an image based on text using the System.Drawing namespace.
private Bitmap CreateBitmapImage(string imageText, string imageUrl)
{
Bitmap myBitmap = new Bitmap(imageUrl);
Graphics g = Graphics.FromImage(myBitmap);
g.DrawString(imageText, new Font("Tahoma", 40), Brushes.White, new PointF(0, 0));
return (objBmpImage);
}
Once you have the Bitmap object in memory you can save it to the disk and call it's location from the web.
Bitmap bmp = CreateBitmapImage("my picture", @"C:\myBasePic.bmp");
bmp.Save(@"C:\bla.png", System.Drawing.Imaging.ImageFormat.png);
Upvotes: 1
Reputation: 49215
It would be good if you can specify why such requirement is there. One of such scenario that I had encountered was need of image buttons with different text (round corners with shaded background) - this can easily be achieved using CSS. If you really want to combine an image and text together then you can do that at server side (using say System.Drawing types) and serve the combined image over a handler/web-service.
Upvotes: 0