我想在上传后的图片中指定位置贴一张有自己风格的图片,代码如下:
//取原图,这里的file
System.Drawing.Image oldimage = System.Drawing.Image.FromFile(Server.MapPath(file));
int oldWidth = oldimage.Width;
int oldHeight = oldimage.Height;
//取标志图
System.Drawing.Image InImage = System.Drawing.Image.FromFile(Server.MapPath("/MeetLoverWeb/Images/BOTAO.bmp"));
int inWidth = InImage.Width;
int inHeight = InImage.Height;
如果大小合适再做贴图
if(oldWidth > 3*inWidth && oldHeight > 3*inHeight)
{
Graphics g=Graphics.FromImage(oldimage);
try
{
g.DrawImage(InImage,oldWidth - 2*inWidth,oldHeight - 2*inHeight,inWidth,inHeight);
}
catch (Exception ex)
{
g.DrawString(ex.ToString(),new Font("Arial", 8),Brushes.Black,new PointF(0, 0));
}
}
//完成
InImage.Dispose();
oldimage.Dispose();
结果在Try的过程中没有发现错误,图片大小也合适,,就是图片没有被贴上去。
谁知道是什么原因呢?
//取原图,这里的file
System.Drawing.Image oldimage = System.Drawing.Image.FromFile(Server.MapPath(file));
int oldWidth = oldimage.Width;
int oldHeight = oldimage.Height;
//取标志图
System.Drawing.Image InImage = System.Drawing.Image.FromFile(Server.MapPath("/MeetLoverWeb/Images/BOTAO.bmp"));
int inWidth = InImage.Width;
int inHeight = InImage.Height;
如果大小合适再做贴图
if(oldWidth > 3*inWidth && oldHeight > 3*inHeight)
{
Graphics g=Graphics.FromImage(oldimage);
try
{
g.DrawImage(InImage,oldWidth - 2*inWidth,oldHeight - 2*inHeight,inWidth,inHeight);
}
catch (Exception ex)
{
g.DrawString(ex.ToString(),new Font("Arial", 8),Brushes.Black,new PointF(0, 0));
}
}
//完成
InImage.Dispose();
oldimage.Dispose();
结果在Try的过程中没有发现错误,图片大小也合适,,就是图片没有被贴上去。
谁知道是什么原因呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货