locked
Convert text to image dynamically RRS feed

  • Question

  • Is there a means by which I can convert text, dynamically (I won't know what the text is until runtime) into an png image? In short, if I get a string, dymanically, like "Stainless Steel," I want to convert it to a png image (black text, white background) at runtime.

    Does anyone know how I might accomplish this in C# ? Thanks

    Thursday, November 21, 2013 3:00 PM

Answers

  • If you're using WinForms then you can create an empty Bitmap object that has the resolution and whatnot you want, create a Graphics object from that, use DrawString to write the text to the graphics and then save it as a PNG.  This is similar to how you generate watermarks in images.

    Michael Taylor
    http://msmvps.com/blogs/p3net

    Thursday, November 21, 2013 3:26 PM