public static string DrawImage(string WorkDirectory, string oldImage, string WaterMarkImage, string waterMarkText, int XCoord, int YCoord, string NewImageName)
{
MemoryStream msNew = new MemoryStream();
MemoryStream msOut = new MemoryStream();
Bitmap bmp = new Bitmap(WorkDirectory + "\\" + oldImage);
Bitmap bmpWm = new Bitmap(WorkDirectory + "\\" + WaterMarkImage);
Bitmap bmpTemp = new Bitmap(bmp);
Graphics canvas = Graphics.FromImage(bmpTemp);
bmp.Dispose();
try
{
using (Graphics gr = Graphics.FromImage(bmpTemp))
{
gr.DrawImage(bmpWm, new Rectangle(XCoord, YCoord, bmpWm.Width, bmpWm.Height), 0, 0, bmpWm.Width, bmpWm.Height, GraphicsUnit.Pixel);
}
}
catch(Exception ex)
{
string errorMessage = "Error occurred during submission.";
return errorMessage;
}
bmpTemp.Save(WorkDirectory + "\\" + NewImageName, ImageFormat.Png);
bmpTemp.Dispose();
return WorkDirectory + "\\" + NewImageName;
}
嗨,此代码在本地服务器上运行良好,当将此代码放在实时服务器上时,我收到错误“GDI+ 中发生一般错误”。那么如何解决这个错误。