书签 分享 收藏 举报 版权申诉 / 20

类型C#图片上传加水印自动生成缩略图源代码.docx

  • 文档编号:30559343
  • 上传时间:2023-08-16
  • 格式:DOCX
  • 页数:20
  • 大小:21.69KB

>纯文本方式>拷贝到裁剪板>打印

1.using System;  

2.using System.Data;  

3.using System.Data.SqlClient;  

4.using System.Configuration;  

5.using System.Web;  

6.using System.Web.Security;  

7.using System.Web.UI;  

8.using System.Web.UI.WebControls;  

9.using System.Web.UI.WebControls.WebParts;  

10.using System.Web.UI.HtmlControls;  

11.using System.Text;  

12.using System.Text.RegularExpressions;  

13.using System.Drawing;  

14.using System.Drawing.Imaging;  

15.using System.Collections;  

16.using System.ComponentModel;  

17.namespace Legalsoft.Images  

18.{  

19.    /// 

  

20.    /// News 的摘要说明  

21.    /// 

  

22.    public class XImage  

23.    {  

24.        public Color tBackground;  

25.        public Color tBorder;  

26.        public Color tShadow;  

27.        public int tQuality;  

28.        public string markPosition;  

29.        /// 

  

30.        /// 图片参数预定义  

31.        /// 

  

32.        static Hashtable htmimes = new Hashtable();  

33.        internal readonly string AllowExt = ".jpe|.jpeg|.jpg|.png|.tif|.tiff|.bmp|.gif";  

34.        public XImage()  

35.        {  

36.            tBackground = Color.Transparent;  

37.            tBorder = Color.Transparent;  

38.            tShadow = Color.Transparent;  

39.            tQuality = 100;  

40.            markPosition = "左下角"; 

41.            #region 图片类型预定义  

42.            htmimes[".jpe"]="image/jpeg";  

43.            htmimes[".jpeg"] = "image/jpeg";  

44.            htmimes[".jpg"] = "image/jpeg";  

45.            htmimes[".png"] = "image/png";  

46.            htmimes[".tif"] = "image/tiff";  

47.            htmimes[".tiff"] = "image/tiff";  

48.            htmimes[".bmp"] = "image/bmp";  

49.            htmimes[".gif"] = "image/gif"; 

50.            #endregion   

51.        } 

52.        #region 下载指定URL图片并保存  

53.        /// 

  

54.        /// 下载指定URL的文件并保存到指定目录  

55.        /// 

  

56.        ///   

57.        public void DownloadImage(string strUrl, string file)  

58.        {  

59.            System.Net.WebClient wc = new System.Net.WebClient();  

60.            wc.DownloadFile(strUrl, file);  

61.        } 

62.        #endregion 

63.        #region C#自动生成缩略图  

64.        /// 

  

65.        /// 按给定名字确定颜色  

66.        /// 

  

67.        ///   

68.        ///   

69.        public Color ToColor(string name)  

70.        {  

71.            if (name == "白色") return Color.White;  

72.            if (name == "红色") return Color.Red;  

73.            if (name == "蓝色") return Color.Blue;  

74.            if (name == "绿色") return Color.Green;  

75.            if (name == "黑色") return Color.Black;  

76.            if (name == "灰色") return Color.DarkGray;  

77.            if (name == "黄色") return Color.Yellow;  

78.            if (name == "紫色") return Color.Cyan;  

79.            if (name == "无色") return Color.Transparent;  

80.            return Color.Transparent;  

81.        }  

82.        /// 

  

83.        /// 按名字设置各种颜色,可以自行扩充:

)  

84.        /// 

  

85.        ///   

86.        ///   

87.        public int ToQuality(string name)  

88.        {  

89.            return Int32.Parse(name.Replace("%", ""));  

90.        }  

91.        /// 

   

92.        /// 获取图像编码解码器的所有相关信息   

93.        /// 

   

94.        /// 包含编码解码器的多用途网际邮件扩充协议 (MIME) 类型的字符串   

95.        /// 返回图像编码解码器的所有相关信息   

96.        private static ImageCodecInfo GetCodecInfo(string mimeType)  

97.        { 

配套讲稿:

如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

特殊限制:

部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

关 键  词:
C# 图片 上传 水印 自动 生成 缩略图 源代码
提示  冰豆网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文
本文标题:C#图片上传加水印自动生成缩略图源代码.docx
链接地址:https://www.bdocx.com/doc/30559343.html
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2008-2022 冰点文档网站版权所有

经营许可证编号:鄂ICP备2022015515号-1

收起
展开