tags:

views:

75

answers:

2

Hi

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

A: 

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.

VinayC
+1  A: 

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);
Peter
I think jpg or png codecs are more appropriate for the web instead of bmp.
Zafer
@Zafer: right! my bad :-) Changed the output format to png
Peter