PDA

View Full Version : سوال: نوشتن متن روی عکس و ذخیره آن



yosef_ghobadi
سه شنبه 31 شهریور 1394, 09:50 صبح
سلام به اساتید
چطور میشه متنی رو که در برنامه روی عکس نوشتم با عکس تلفیق بشه و ذخیره کنم؟

drsina
سه شنبه 31 شهریور 1394, 10:54 صبح
string firstText = "Hello";string secondText = "World";


PointF firstLocation = new PointF(10f, 10f);
PointF secondLocation = new PointF(10f, 50f);


string imageFilePath = @"path\picture.bmp"
Bitmap bitmap = (Bitmap)Image.FromFile(imageFilePath);//load the image file


using(Graphics graphics = Graphics.FromImage(bitmap))
{
using (Font arialFont = new Font("Arial", 10))
{
graphics.DrawString(firstText, arialFont, Brushes.Blue, firstLocation);
graphics.DrawString(secondText, arialFont, Brushes.Red, secondLocation);
}
}


bitmap.Save(imageFilePath);//save the image file