ASP组件AspJpeg(加水印)生成缩略图等使用方法

2019-01-13 02:06:43于海丽

//set a Font object to Arial (i)pt, Bold
//crFont = new Font("arial", sizes[i], FontStyle.Bold);
crFont = new Font("arial",sizes[i],FontStyle.Bold);
//Measure the Copyright string in this Font
crSize = grPhoto.MeasureString(FontString, crFont);
if((ushort)crSize.Width < (ushort)phWidth)
break;
}
//Since all photographs will have varying heights, determine a
//position 5% from the bottom of the image
int yPixlesFromBottom = (int)(phHeight *.05);
//Now that we have a point size use the Copyrights string height
//to determine a y-coordinate to draw the string of the photograph
float yPosFromBottom = ((phHeight - yPixlesFromBottom)-(crSize.Height/2));
//Determine its x-coordinate by calculating the center of the width of the image
float xCenterOfImg = (phWidth/2);
//Define the text layout by setting the text alignment to centered
StringFormat StrFormat = new StringFormat();
StrFormat.Alignment = StringAlignment.Center;
//define a Brush which is semi trasparent black (Alpha set to 153)
SolidBrush semiTransBrush2 = new SolidBrush(Color.FromArgb(153, 0, 0, 0));
//Draw the Copyright string
grPhoto.DrawString(FontString, //string of text
crFont, //font
semiTransBrush2, //Brush
new PointF(xCenterOfImg+1,yPosFromBottom+1), //Position
StrFormat);
//define a Brush which is semi trasparent white (Alpha set to 153)
SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(153, 255, 255, 255));
//Draw the Copyright string a second time to create a shadow effect
//Make sure to move this text 1 pixel to the right and down 1 pixel
grPhoto.DrawString(FontString, //string of text
crFont, //font
semiTransBrush, //Brush
new PointF(xCenterOfImg,yPosFromBottom), //Position
StrFormat);
imgPhoto = bmPhoto;
grPhoto.Dispose();
//save new image to file system.
imgPhoto.Save(WorkingDirectory + ImageName + "_finally.jpg", ImageFormat.Jpeg);
imgPhoto.Dispose();
//Text alignment
}

您可能感兴趣的文章:

利用ASPUPLOAD,ASPJPEG实现图片上传自动生成缩略图及加上水印Asp无组件生成缩略图的代码ASP保存远程图片到本地 同时取得第一张图片并创建缩略图的代码ASP.Net 上传图片并生成高清晰缩略图asp.net 自定义控件实现无刷新上传图片,立即显示缩略图,保存图片缩略图Asp.Net平台下的图片在线裁剪功能的实现代码(源码打包)asp.net 图片超过指定大小后等比例压缩图片的方法ASP.NET简单好用功能齐全图片上传工具类(水印、缩略图、裁剪等)ASP固定比例裁剪缩略图的方法