I'm using the following code (credit to Dolph Larson) to take a pre-made image file in bitmap format on an ASP.net server, draw a string on it and save it to file on the server. In the original code, he dumps the bitmap to the OutputStream, but I'd like to dump it instead to a file.
The version of code below successfully creates the new file, but when I open it, the string does not appear drawn on the image in the new file. I imagine I am missing a step -- when I use bitMapImage.Save("bitmaptest.jpg", ImageFormat.Jpeg) am I just re-saving the original instead of the modified version?
Here is the code:
//Load the Image to be written on.
Bitmap bitMapImage = new
System.Drawing.Bitmap(Server.MapPath("generic.jpg"));
Graphics graphicImage = Graphics.FromImage(bitMapImage);
graphicImage.SmoothingMode = SmoothingMode.AntiAlias;
graphicImage.DrawString("testing 1 2 3",
new Font("Arial", 20, FontStyle.Bold),
SystemBrushes.WindowText, new Point(0, 0));
Response.ContentType = "image/jpeg";
bitMapImage.Save("bitmaptest.jpg", ImageFormat.Jpeg);
graphicImage.Dispose();
bitMapImage.Dispose();
Thanks in advance!