
10-20-2003, 04:06 AM
|
Newcomer
|
|
Join Date: Oct 2003
Posts: 2
|
|
Write Text into Jpeg image
Hello!
Got an error for running the below coding "A Generic Error Occured in GDI+", what's wrong?
private void button2_Click(object sender, System.EventArgs e)
{
Image newImage = Image.FromFile("sample.jpg");
String drawString = "Sample Text";
Font drawFont = new Font("Arial", 16);
SolidBrush drawBrush = new SolidBrush(Color.Black);
float x = 150.0F;
float y = 50.0F;
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
Graphics g=Graphics.FromImage(newImage);
g.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
newImage.Save("sample.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
}
Please give me reply asap. Thanks!
fm Softair
|
|