Solved

how to convert text to image in c#

Posted on 2011-03-12
3
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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