Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

how to convert text to image in c#

I need to convert a string text to image (eg:gif), rotate the image (90 or 270 degrees, etc) and save it to disk. Does anyone can help me? Sample code in C#?
Tks in advance
Leonel
0
leorocha
Asked:
leorocha
  • 2
1 Solution
 
Kusala WijayasenaSoftware EngineerCommented:
Try this:

string text = "Hello World";

Bitmap objBitmap = new Bitmap(200, 200);
Graphics objGraphics = Graphics.FromImage(objBitmap);

Font objFont = new Font("Arial", 16f);

SolidBrush objBrushForeColor = new SolidBrush(Color.Black);
SolidBrush objBrushBackColor = new SolidBrush(Color.White);

objGraphics.FillRectangle(objBrushBackColor, 0, 0, Width, Height);
objGraphics.RotateTransform(45f); //Rotate Text

objGraphics.DrawString(text, objFont, objBrushForeColor, 40f, 10f);

objBitmap.Save("test.gif", ImageFormat.Gif);

Open in new window


-Kusala
0
 
leorochaAuthor Commented:
need this?:
using System.Drawing;
using System.Drawing.Imaging;
0
 
Kusala WijayasenaSoftware EngineerCommented:
yes

-Kusala
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now