动态网站制作指南
[  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
电脑书籍下载:程序设计书籍 | 数据库教程书籍 | 平面与多媒体书籍 | 网络通讯书籍 | 系统管理书籍 | 网络安全书籍 | 认证考试书籍
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP.NET技巧
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ ASP.NET技巧 ]的信息



本月文章推荐
.在ASP.NET中上传图片并生成缩略图.
.ASP.NET中使用Apache log4net .
.如何于DataGridView控件中以跨数.
.实现在页面中单击按钮关闭页面.
.理解IIS7的用户和组.
.URL编码处理.
.利用WWF进行ASP.NET程序开发 .
.如何在上传的图片上写字.
.asp.net1.1和asp.net 2.0共存 .
.DataGridView 的分页处理.
.自动处理过长字符串显示的Web控件.
.将以前写的SQL2分查找法通用分页.
.利用Cache、Timer(ATLAS)控制用户.
.一个关于session使用的讨论.
..NET 应用程序的性能提升应用技巧.
.如何在调用线程的时候传递参数.
.File.Delete不能删除文件的问题.
.ASP.NET2.0中的AccessDataSource.
.请求网址并解析返回的html.
.ASP.NET 2.0角色及成员管理 .

封装的一些实现图片水印与图片自动结合缩放的类

文章类别:ASP.NET技巧 | 发表日期:2007-1-10 |


  1using System;
  2using System.Data;
  3using System.Configuration;
  4using System.Web;
  5using System.Web.Security;
  6using System.Web.UI;
  7using System.Web.UI.WebControls;
  8using System.Web.UI.WebControls.WebParts;
  9using System.Web.UI.HtmlControls;
 10using System.Drawing;
 11namespace WebHelper
 12{
 13
 14    /**//// <summary>
 15    /// ImageHelper 的摘要说明
 16    /// </summary>
 17    public class ImageHelper
 18    {
 19        public ImageHelper()
 20        {
 21            //
 22            // TODO: 在此处添加构造函数逻辑
 23            //
 24        }
 25        Image水印#region Image水印
 26        /**//// <summary>
 27        /// 写入图像水印
 28        /// </summary>
 29        /// <param name="str">水印字符串</param>
 30        /// <param name="filePath">原图片位置</param>
 31        /// <param name="savePath">水印加入后的位置</param>
 32        /// <returns></returns>
 33        public  string CreateBackImage(System.Web.UI.Page pageCurrent, string str, string filePath, string savePath, int x, int y)
 34        {
 35            System.Drawing.Image img = System.Drawing.Image.FromFile(pageCurrent.MapPath(filePath));
 36            //创建图片
 37            Graphics graphics = Graphics.FromImage(img);
 38            //指定要绘制的面积
 39            graphics.DrawImage(img, 0, 0, img.Width, img.Height);
 40            //定义字段和画笔
 41            Font font = new Font("黑体", 16);
 42            Brush brush = new SolidBrush(Color.Yellow);
 43            graphics.DrawString(str, font, brush, x, y);
 44            //保存并输出图片
 45            img.Save(pageCurrent.MapPath(savePath), System.Drawing.Imaging.ImageFormat.Jpeg);
 46            return savePath;
 47
 48        }
 49        #endregion
 50        Image自动缩小#region Image自动缩小
 51        /**//// <summary>
 52        /// 缩小图片到指定的大小
 53        /// </summary>
 54        /// <param name="strOldPic">
 55        /// 原图片的位置
 56        /// </param>
 57        /// <param name="strNewPic">
 58        /// 缩小后的图片位置
 59        /// </param>
 60        /// <param name="intWidth">
 61        /// 宽度
 62        /// </param>
 63        /// <param name="intHeight">
 64        /// 高度
 65        /// </param>
 66        public void SmallPic(string strOldPic, string strNewPic, int intWidth, int intHeight)
 67        {
 68
 69            System.Drawing.Bitmap objPic, objNewPic;
 70            try
 71            {
 72                objPic = new System.Drawing.Bitmap(strOldPic);
 73                objNewPic = new System.Drawing.Bitmap(objPic, intWidth, intHeight);
 74                objNewPic.Save(strNewPic);
 75
 76            }
 77            catch (Exception exp) { throw exp; }
 78            finally
 79            {
 80                objPic = null;
 81                objNewPic = null;
 82            }
 83        }
 84
 85        public void SmallPic(string strOldPic, string strNewPic, int intWidth)
 86        {
 87
 88            System.Drawing.Bitmap objPic, objNewPic;
 89            try
 90            {
 91                objPic = new System.Drawing.Bitmap(strOldPic);
 92                int intHeight = Convert.ToInt32(((intWidth * 1.0) / (objPic.Width * 1.0)) * objPic.Height);
 93                objNewPic = new System.Drawing.Bitmap(objPic, intWidth, intHeight);
 94                objNewPic.Save(strNewPic, objPic.RawFormat);
 95
 96            }
 97            catch (Exception exp) { throw exp; }
 98            finally
 99            {
100                objPic = null;
101                objNewPic = null;
102            }
103        }
104
105        //public void SmallPic(string strOldPic, string strNewPic, int intHeight)
106        //{
107
108        //    System.Drawing.Bitmap objPic, objNewPic;
109        //    try
110        //    {
111        //        objPic = new System.Drawing.Bitmap(strOldPic);
112        //        int intWidth = Convert.ToInt32(((intHeight * 1.0) / objPic.Height) * objPic.Width);
113        //        objNewPic = new System.Drawing.Bitmap(objPic, intWidth, intHeight);
114        //        objNewPic.Save(strNewPic, objPic.RawFormat);
115
116        //    }
117        //    catch (Exception exp) { throw exp; }
118        //    finally
119        //    {
120        //        objPic = null;
121        //        objNewPic = null;
122        //    }
123        //}
124        #endregion
125
126    }
127}

http://www.cnblogs.com/chu888chu888/archive/2007/01/09/615803.html


上一篇:DATAGRID分页,增加首页、最后一页(源码) 人气:3585
下一篇:用post方法从网上抓取信息 人气:3012
点击此处浏览全部水印的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-5-20 站长俱乐部新闻发布系统 v5.19
2008-5-20 DotNetTextBox网页编辑器 v3.4.7
2008-5-20 phpMyFAQ v2.5.0 多国语言版
2008-5-20 DreamArticle 文章管理系统 v2.0
2008-5-20 Drupal v7.xdev Build080518
2008-5-20 逐迹内容管理系统AspxNuke v2.0.
2008-5-20 ajax奥运留言本 v1.0
2008-5-20 QQ空间博客全自动挂机互踩好友
2008-5-20 网人采集 v1.2.0
2008-5-7 Windows XP SP3 官方英文版
2008-5-7 Windows XP SP3 官方香港中文版
2008-5-7 Windows XP SP3 官方繁体中文版
2008-5-7 Windows XP SP3 官方简体中文版
2008-4-30 Multiple Unzip Wizard 1.02
2008-4-30 Multiple Unrar Wizard 1.0.0
2008-4-30 WinZip Install/Try/Uninstall a
2008-4-30 ZIP压缩文件修复器WzipFix 2.0
2008-4-30 Pentazip 6.01 Build 189 For Wi
  发表评论
姓 名: 验证码: [ 全部贴吧 ] [ 浏览评论 ]
内 容:
[ 汉字翻译拼音 ] [ 广告代码 ] [ 符号对照表 ] [ 进制转换 ] [ 经典小工具 ] [ 个税计算 ] [ 汉字简繁转换 ] [ 普通单位换算 ] [ 公制单位换算 ]
[ 生辰老黄历 ] [ 国内电话区号 ] [ 国家代码与域名缩写 ] [ 文字加密解密 ] [ 健康查询 ] [ 万年历 ] [ 手机号码查询 ] [ ip搜索 ] [ Google PR查询 ]
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号