62,268
社区成员
发帖
与我相关
我的任务
分享 if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(Server.MapPath(@"~/upLoad/") + FileUpload1.FileName);
string path = Server.MapPath(@"~/upLoad/") + FileUpload1.FileName;
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
Graphics g = Graphics.FromImage(image);
//g.DrawImage(image, 0,0, image.Width, image.Height);
Font f = new Font("Verdana",12);
Brush b = new SolidBrush(Color.Orange);
string addText = "http://www.750sidecar.com/";
g.SmoothingMode = SmoothingMode.AntiAlias;
g.DrawString(addText,new Font("宋体",12),Brushes.Red,10,image.Height-100);
g.Dispose();
// string newPath = Server.MapPath(".") + "/UploadFile/" + fileName + "_new" + extension;
string path1 = Server.MapPath(@"~/upLoad/" + "new" + FileUpload1.FileName);
image.Save(path1);
image.Dispose();
string bigImgName = "new" + FileUpload1.FileName;
//int result = dfd.setbigImgUrl("new"+FileUpload1.FileName,int.Parse(HiddenField1.Value));
string imgType = FileUpload1.PostedFile.ContentType;
string imgLength = FileUpload1.PostedFile.ContentLength.ToString();
} //-------------------------------------------------------
//字体大小放在一个数组中,最大字体为32.
//感觉用处不大,可以自己再修改这里
//-------------------------------------------------------
int[] sizes = new int[] { 8, 7, 6, 5, 4 };
Font crFont = null;
SizeF crSize = new SizeF();
//循环测试数组中所定义的字体大小是否适合版权信息,如果合适就使用此种字体大小
for (int i = 0; i < 5; i++)
{
//设置字体类型,可以单独提出,作为参数
crFont = new Font("宋体", 13, FontStyle.Bold);
//测量此种字体大小
crSize = grPhoto.MeasureString(Copyright, crFont);
if ((ushort)crSize.Width < (ushort)phWidth)
break;
}//获得图片大小
public void pic_size(string sourcepath)
{
//从文件取得图片对象
System.Drawing.Image image = System.Drawing.Image.FromFile(sourcepath);
wt = image.Width;
ht = image.Height;
}