Hi,
How can I write a text over a image, defining the position of the text...
Like I have a picture of a man holding a whiteboard and inside it I want to write "Enter"...
I have the coordinates already...
Thanks
Hi,
How can I write a text over a image, defining the position of the text...
Like I have a picture of a man holding a whiteboard and inside it I want to write "Enter"...
I have the coordinates already...
Thanks
Write text over images...
Mike Culver
sachin kumar rana
OK,
That's solve my problem but I got this error "A Graphics object cannot be created from an image that has an indexed pixel format"
Abbbbbs
Graphics Manipulation primiarly starts from the Graphics object.
void WriteText(String input, String output, String text, Int32 x, Int32 y){
Bitmap TmpBitmap = new Bitmap(input); Graphics TmpGraphics = Graphics.FromImage(TmpBitmap);TmpGraphics.DrawString(text,
new Font("Arial", 23.0f, GraphicsUnit.Pixel), new SolidBrush(Color.Red), x, y);TmpBitmap.Save(output);
TmpBitmap.Dispose();
}
Shady9399
Hemant Hindlekar
Depending upon how it's going to be spit out.
For example let's suppose you have a .aspx page that spits out an image such as
<img src="DisplayImageWithText.aspx text=I+got+pwnt" />
In this case you would [retty much do the same exact code except this time we take advantage of one of the Save overload methods which allows us to save directly to a Stream.
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Bitmap TmpImage = WriteText(Server.MapPath("~/yikersceilingcat10sy.jpg"), Request.QueryString["Text"], 20, 20);
TmpImage.Save(Response.OutputStream, ImageFormat.Jpeg);
Response.End();
}Bitmap WriteText(String input, String text, Int32 x, Int32 y)
{
Bitmap TmpBitmap = new Bitmap(input);
Graphics TmpGraphics = Graphics.FromImage(TmpBitmap);
TmpGraphics.DrawString(text, new Font("Arial", 63.0f, GraphicsUnit.Pixel), new SolidBrush(Color.Red), x, y);
// TmpBitmap.Save(output);
// TmpBitmap.Dispose();
return TmpBitmap;}
If the image is not going to change then you would just save it to your image directory and let other web pages access it like any normal image.
Hope this helps.
sigol
I don't need to save the image but print it on an aspx page...How do I write this image to a page...
Let's supose that the image path is "C:\temp\foto.jpg"
GordonMoll
I'm opening a Gif....I changed the format also...but didn't worked...I think that's beacuse of the transparent background....
Is there a way to solve it...
FassaBortolo
I think it's solve, but how can I create a gif with transparent background with the size to fit the string, print a string on it without save to disk
That's the final solution that I want... =)
Thanks
Mukesh Dua
Simon Heffer
I have noticed that when I save the image, the image size is reduced by about 1/3rd. So I guess the output image would be distorted.
How to write to text without changing the resolution of the original image Any ideas
Thanks
Srini
sl5