文章来源:http://www.itnose.net/detail/6038691.html
更多文章:http://www.itnose.net/type/40.html
为freetextbox1.6.5上传图片加上水印
Graphics的DrawImage方法,定义了多种原型,可以在制定位置绘制指定Image对象。利用此方法可以在图片对象上再绘制一个水印图片。结合FreeTextBox方便的图片上传功能,可以实现一个适合图片新闻较多的新闻系统。以下WaterMark方法所带参数为文件流,原始图片名称,水印图片名称,图片保存路径等,对应注释理解代码应该没有多大问题。
-----------------------------------------------------------------
public void WaterMark(Stream inputStream, string fileName, string
markName, string picPath)
{
string WorkingDirectory =
HttpContext.Current.Request.PhysicalApplicationPath + "\\" + picPath;
Stream PhotoStream = inputStream;
string WatermarkName = markName;
string PhotoFinalName = fileName;
//create a image object containing the photograph to watermark
System.Drawing.Image imgPhoto = System.Drawing.Image.FromStream(PhotoStream);
int phWidth = imgPhoto.Width;
int phHeight = imgPhoto.Height;
//create a image object containing the watermark
System.Drawing.Image imgWatermark = new Bitmap(WorkingDirectory + "\\" + WatermarkName);
int wmWidth = imgWatermark.Width;
int wmHeight = imgWatermark.Height;
//Create a Bitmap
Bitmap bmWatermark = new Bitmap(PhotoStream);
bmWatermark.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);
//Load this Bitmap into a new Graphic Object
Graphics grWatermark = Graphics.FromImage(bmWatermark);
ImageAttributes imageAttributes = new ImageAttributes();
//This color manipulation is used to change the opacity of the
//watermark. This is done by applying a 5x5 matrix that contains the
//coordinates for the RGBA space. By setting the 3rd row and 3rd column
//to 0.3f we achive a level of opacity
float[][] colorMatrixElements = {
new float[] {1.0f, 0.0f, 0.0f, 0.0f, 0.0f},
new float[] {0.0f, 1.0f, 0.0f, 0.0f, 0.0f},
new float[] {0.0f, 0.0f, 1.0f, 0.0f, 0.0f},
new float[] {0.0f, 0.0f, 0.0f, 0.3f, 0.0f},
new float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}};
ColorMatrix wmColorMatrix = new ColorMatrix(colorMatrixElements);
imageAttributes.SetColorMatrix(wmColorMatrix, ColorMatrixFlag.Default,
ColorAdjustType.Bitmap);
//For this example we will place the watermark in the upper right
//hand corner of the photograph. offset down 10 pixels and to the
//left 10 pixles
int xPosOfWm = ((phWidth - wmWidth)-10);
int yPosOfWm = 10;
grWatermark.DrawImage(imgWatermark,
new Rectangle(xPosOfWm,yPosOfWm,wmWidth,wmHeight), //Set the detination Position
0, // x-coordinate of the portion of the source image to draw.
相关推荐
FreeTextBox 1.6.5 简体中文版,很好的控件
在freetextbox1.X中为上传图片增加水印,可在ftb.imagegallery.aspx中改写代码.3.x中则......
一个基于 Internet Explorer 中 MSHTML 技术的 ASP.NET 服务器控件,可以轻松地将其嵌入到 Web Forms 中实现 HTML 内容的在线编辑,在新闻发布、博客写作、论坛社区等多种 Web 系统中都会有用途.
FreeTextBox实现上传图片并返回路径给你调用
如何使用freetextbox上传图片,本例子详细的讲述了其使用!
可以本地上传图片的FreeTextBox.网络上的Freetextbox只可以插入网络地址。
配置好适用于asp.net版本,可上传图片,也可对上传图片删除。
freetextbox3.22的上传图片功能.里面有freetextbox空间的dll文件,还有教你怎么实现把图片本地上传到服务器文件并显示出来的方法!看不懂可以找本人!
FreeTextBox_source FreeTextBox
FreeTextBox是一款免费的Asp.net网页编辑器,官方默认为英文版,该版本设置为简体中文版,可以设置文字样式、在线排版、图片上传等(FreeTextBox源码需要单独购买授权),该代码包括了各类应用的演示和实现过程 ...
+ images 目录(这个是你的“图片库”目录,上传的图片都在此) - ftb.colorpicker.aspx - ftb.imagegallery.aspx - ftb.inserttable.aspx - test.aspx (测试) (注:+ 表示目录,- 表示文件;上面 FreeTextBox....
FreeTextBox的使用(C#) FreeTextBox的使用(C#) FreeTextBox的使用(C#)
这里以FreeTextbox为例,简单的演示了文本编辑控件的使用, 也是大部份分页控件使用的一个思路, 希望起到抛砖引玉的作用 主要是因为在教学过程中发现很多同学听完课, 一下记不住那么多的操作步骤,所以我制作了这...
c#基础学习
我对freetextbox 3.1.6进行了修订: 1)图片上传 2)汉化图片上传界面 ftb.imagegallery.aspx 3)可以显示所有图片(默认只能显示2个图片) 4)可以保存为html页面到文件夹htmlpages 开发工具vs2005+sp1,解压后即可...
FreeTextBox 1.6.3 中文版及源码
ASP.NET FreeTextBox 文本编辑控件,编辑控件类似于office软件,内又强大的编辑功能,能让你更好的在网页上编辑文本
FreeTextBox 1.6.3 中文版