Solved

how to convert text to image in c#

Posted on 2011-03-12
3
337 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
Comment Utility
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
Comment Utility
need this?:
using System.Drawing;
using System.Drawing.Imaging;
0
 
LVL 11

Expert Comment

by:Kusala Wijayasena
Comment Utility
yes

-Kusala
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

11 Experts available now in Live!

Get 1:1 Help Now