|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
asp可以使用微软的activeX使得网页功能无比强大,不过安全性也较差,而且是基于的windows服务器,所以性能稳定性也一般上传|上传图片Graphics的DrawImage办法,界说了多种原型,能够在制订地位绘制指定Image工具。使用此办法能够在图片工具上再绘制一个水印图片。分离FreeTextBox便利的图片上传功效,能够完成一个合适图片旧事较多的旧事体系。以下WaterMark办法所带参数为文件流,原始图片称号,水印图片称号,图片保留路径等,对应正文了解代码应当没有多年夜成绩。
-----------------------------------------------------------------
publicvoidWaterMark(StreaminputStream,stringfileName,string
markName,stringpicPath)
{
stringWorkingDirectory=
HttpContext.Current.Request.PhysicalApplicationPath+""+picPath;
StreamPhotoStream=inputStream;
stringWatermarkName=markName;
stringPhotoFinalName=fileName;
//createaimageobjectcontainingthephotographtowatermark
System.Drawing.ImageimgPhoto=System.Drawing.Image.FromStream(PhotoStream);
intphWidth=imgPhoto.Width;
intphHeight=imgPhoto.Height;
//createaimageobjectcontainingthewatermark
System.Drawing.ImageimgWatermark=newBitmap(WorkingDirectory+""+WatermarkName);
intwmWidth=imgWatermark.Width;
intwmHeight=imgWatermark.Height;
//CreateaBitmap
BitmapbmWatermark=newBitmap(PhotoStream);
bmWatermark.SetResolution(imgPhoto.HorizontalResolution,imgPhoto.VerticalResolution);
//LoadthisBitmapintoanewGraphicObject
GraphicsgrWatermark=Graphics.FromImage(bmWatermark);
ImageAttributesimageAttributes=newImageAttributes();
//Thiscolormanipulationisusedtochangetheopacityofthe
//watermark.Thisisdonebyapplyinga5x5matrixthatcontainsthe
//coordinatesfortheRGBAspace.Bysettingthe3rdrowand3rdcolumn
//to0.3fweachivealevelofopacity
float[][]colorMatrixElements={
newfloat[]{1.0f,0.0f,0.0f,0.0f,0.0f},
newfloat[]{0.0f,1.0f,0.0f,0.0f,0.0f},
newfloat[]{0.0f,0.0f,1.0f,0.0f,0.0f},
newfloat[]{0.0f,0.0f,0.0f,0.3f,0.0f},
newfloat[]{0.0f,0.0f,0.0f,0.0f,1.0f}};
ColorMatrixwmColorMatrix=newColorMatrix(colorMatrixElements);
imageAttributes.SetColorMatrix(wmColorMatrix,ColorMatrixFlag.Default,
ColorAdjustType.Bitmap);
//Forthisexamplewewillplacethewatermarkintheupperright
//handcornerofthephotograph.offsetdown10pixelsandtothe
//left10pixles
intxPosOfWm=((phWidth-wmWidth)-10);
intyPosOfWm=10;
grWatermark.DrawImage(imgWatermark,
newRectangle(xPosOfWm,yPosOfWm,wmWidth,wmHeight),//SetthedetinationPosition
0,//x-coordinateoftheportionofthesourceimagetodraw.
0,//y-coordinateoftheportionofthesourceimagetodraw.
wmWidth,//WatermarkWidth
wmHeight,//WatermarkHeight
GraphicsUnit.Pixel,//Unitofmeasurment
imageAttributes);//ImageAttributesObject
//ReplacetheoriginalphotgraphsbitmapwiththenewBitmap
imgPhoto=bmWatermark;
grWatermark.Dispose();
</p>ASP由于使用了COM组件所以它会变的十分强大,但是这样的强大由于WindowsNT系统最初的设计问题而会引发大量的安全问题。只要在这样的组件或是操作中一不注意,哪么外部攻击就可以取得相当高的权限而导致网站瘫痪或者数据丢失; |
|