Solved

how to convert text to image in c#

Posted on 2011-03-12
3
338 Views
Last Modified: 2013-12-17
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
Comment
Question by:leorocha
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
Kusala Wijayasena earned 500 total points
ID: 35117004
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
 

Author Comment

by:leorocha
ID: 35117302
need this?:
using System.Drawing;
using System.Drawing.Imaging;
0
 
LVL 11

Expert Comment

by:Kusala Wijayasena
ID: 35117320
yes

-Kusala
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now