博文

.net生成图片的缩略图的2种方法(2008-08-23 09:49:00)

摘要:.net生成图片的缩略图的2种方法 开发者在线 Builder.com.cn 更新时间:2008-02-02作者:abandonship 来源:CSDN 本文关键词: 缩略图 .net  实现方法有2个方式:  1. 使用Image的GetThumbnailImage 方法直接生成压缩图片,大概大概如此:    file://设置 原图片 对象的 EncoderParameters 对象,设置清晰度
   ImageCodecInfo ici = GetCodecInfo((string)htmimes[mFileExtName]);
   EncoderParameters parameters = new EncoderParameters(1);
   parameters.Param[0] = new EncoderParameter(Encoder.Quality,lngDefinition);    System.Drawing.Image.GetThumbnailImageAbort myCallback =new    System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
   System.Drawing.Image myThumbnail = image.GetThumbnailImage(intNewWidth, intNewHeight,  myCallback, IntPtr.Zero);
  myThumbnail.Save(txtNewPath, ici, parameters);  2. 使用Graphics 重新绘制图象    ImageCodecInfo ici = GetCodecInfo((string)htmimes[mFileExtName]);
   EncoderParameters parameters = new EncoderParameters(1);......

阅读全文(1492) | 评论:0

正则表达式的几个有用的例子(2008-08-18 20:15:00)

摘要: Expression ISBN(-1(?:(0)|3))?:?\x20+(?(1)(?(2)(?:(?=.{13}$)\d{1,5}([ -])\d{1,7}\3\d{1,6}\3(?:\d|x)$)|(?:(?=.{17}$)97(?:8|9)([ -])\d{1,5}\4\d{1,7}\4\d{1,6}\4\d$))|(?(.{13}$)(?:\d{1,5}([ -])\d{1,7}\5\d{1,6}\5(?:\d|x)$)|(?:(?=.{17}$)97(?:8|9)([ -])\d{1,5}\6\d{1,7}\6\d{1,6}\6\d$))) Description This regex match both the old 10 digit ISBNs and the new 13 digit ISBNs. The ISBN number must be prefixed by the literal text "ISBN:" or "ISBN-10:" or "ISBN-13:". The colon is optional. Naturally an ISBN prefixed by "ISBN-10" must be a 10 digit ISBN. One prefixed by "ISBN-13" must be 13 digits. If prefixed only by "ISBN:" it can be either 10 or 13 digits. This does not evaluate whether the check digit is valid for the given ISBN. The structure of an ISBN is discribed here http://www.isbn.org/standards/home/isbn/international/html/usm4.htm (this is for 10 digit) Matches ISBN-13: 978-1-4028-9462-6 Non-Matches ISBN: 1284233-2-1-1   Title Test Details Validate ......

阅读全文(1794) | 评论:0

日期的正则表达式-有关闰年(2008-08-17 18:38:00)

摘要: Expression (((0[13578]|10|12)([-./])(0[1-9]|[12][0-9]|3[01])([-./])(\d{4}))|((0[469]|11)([-./])([0][1-9]|[12][0-9]|30)([-./])(\d{4}))|((2)([-./])(0[1-9]|1[0-9]|2[0-8])([-./])(\d{4}))|((2)(\.|-|\/)(29)([-./])([02468][048]00))|((2)([-./])(29)([-./])([13579][26]00))|((2)([-./])(29)([-./])([0-9][0-9][0][48]))|((2)([-./])(29)([-./])([0-9][0-9][2468][048]))|((2)([-./])(29)([-./])([0-9][0-9][13579][26]))) Description My meager attempt at a date validator with leap years using a strict mm/dd/yyyy format. Matches 02/29/2084 | 01/31/2000 | 11/30/2000 Non-Matches 02/29/2083 | 11/31/2000 | 01/32/2000   Expression ^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$ Description Thi......

阅读全文(2293) | 评论:0

日期正则表达式(2008-08-17 18:26:00)

摘要: Title Test Details Date With Slashes Expression ^\d{1,2}\/\d{1,2}\/\d{4}$ Description This regular expressions matches dates of the form XX/XX/YYYY where XX can be 1 or 2 digits long and YYYY is always 4 digits long. Matches 4/1/2001 | 12/12/2001 | 55/5/3434 Non-Matches 1/1/01 | 12 Jan 01 | 1-1-2001   Expression (^|\s|\()((([1-9]){1}|([0][1-9]){1}|([1][012]){1}){1}[\/-]((2[0-9]){1}|(3[01]){1}|([01][1-9]){1}|([1-9]){1}){1}[\/-](((19|20)([0-9][0-9]){1}|([0-9][0-9]){1})){1}(([\s|\)|:])|(^|\s|\()((([0-9]){1}|([0][1-9]){1}|([1][012]){1}){1}[\/-](([11-31]){1}|([01][1-9]){1}|([1-9]){1}){1}[\/-](((19|20)([0-9][0-9]){1}|([0-9][0-9]){1})){1}(([\s|\)|:|$|\>])){1}){1}){1}){1} Description Will match the following date formats: Preceded by a Space, Left-parentheses, or at the beginning of a line. Followed by a Space, Right-parentheses, or Colon(:), word boundary or End of line. Can have / or - as separator. Accepts 2 digit year 00-99 or ......

阅读全文(2624) | 评论:0

正则表达式举例-关于数字的(2008-08-17 18:05:00)

摘要: Expression ^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$ Description Tests for valid HTML hexadecimal color codes. The # symbol is optional. And it will except either the 3 digit form for the 216 Web safe colors, or the full 6 digit form. I am use it on my site to allow users to customize the site's colors. Matches #00ccff | #039 | ffffcc Non-Matches blue | 0x000000 | #ff000   Expression \b(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5])\b Description Most Concise RegExp for matching Decimal IPs. If nothing else, it'll make your code easier to read. (And I know that \d?\d is \d{1,2} but that's 2 extra characters.) --Update: darkone noticed 8 characters could be shaved down. I've edited it to reflect this. Thanks, darkone! Matches 217.6.9.89 | 0.0.0.0 | 255.255.255.255 Non-Matches 256.0.0.0 | 0978.3.3.3 | 65.4t.54.3 Expression ^\d*\.?((25)|(50)|(5)|(75)|(0)|(00))?$ Description This is......

阅读全文(2303) | 评论:0

上篇文章的补充(2008-08-17 17:39:00)

摘要:The vertical bar provides alternation in the whole group: ([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*) It would be easier to read like this; ( [0-9]*\.?[0-9]+ | [0-9]+\.?[0-9]* ) Get the idea? Title: What is the porpouse of this part ?
Name: CV
Date: 10/24/2003 3:06:44 PM
Comment:
What is the porpouse of this part ? [0-9]+|[0-9]+ Can't it do the same with just [0-9]+ ? What is the difference ? ......

阅读全文(1257) | 评论:0

一个可以匹配整数、浮点数的正则表达式(2008-08-17 17:37:00)

摘要:^[+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?$ Description A regular expression that matches numbers. Integers or decimal numbers with or without the exponential form. Matches 23 | -17.e23 | +.23e+2 Non-Matches +.e2 | 23.17.5 | 10e2.0......

阅读全文(2321) | 评论:0

正则表达式基本语法列表(.NET)(2008-08-17 17:33:00)

摘要: Metacharacters Defined MChar Definition ^ Start of a string. $ End of a string. . Any character (except \n newline) | Alternation. {...} Explicit quantifier notation. [...] Explicit set of characters to match. (...) Logical grouping of part of an expression. * 0 or more of previous expression. + 1 or more of previous expression. ? 0 or 1 of previous expression; also forces minimal matching when an expression might match several strings within a search string. \ Preceding one of the above, it makes it a literal instead of a special character. Preceding a special matching character, see below. Metacharacter Examples Pattern Sample Matches ^abc abc, abcdefg, abc123, ... abc$ abc, endsinabc, 123abc, ... a.c abc, aac, acc, adc, aec, ... bill|ted ted, bill ab{2}c abbc a[bB]c abc, aBc (abc){2} abcabc ab*c ac, abc, abbc, abbbc, ... ab+c abc, abbc, abbbc, ... ab?c ac, abc a\......

阅读全文(2078) | 评论:0

字符,字节和编码(2008-08-17 17:23:00)

摘要:字符,字节和编码 [原创文章,转载请保留或注明出处:http://www.regexlab.com/zh/encoding.htm] 级别:中级 摘要:本文介绍了字符与编码的发展过程,相关概念的正确理解。举例说明了一些实际应用中,编码的实现方法。然后,本文讲述了通常对字符与编码的几种误解,由于这些误解而导致乱码产生的原因,以及消除乱码的办法。本文的内容涵盖了“中文问题”,“乱码问题”。 掌握编码问题的关键是正确地理解相关概念,编码所涉及的技术其实是很简单的。因此,阅读本文时需要慢读多想,多思考。 引言 “字符与编码”是一个被经常讨论的话题。即使这样,时常出现的乱码仍然困扰着大家。虽然我们有很多的办法可以用来消除乱码,但我们并不一定理解这些办法的内在原理。而有的乱码产生的原因,实际上由于底层代码本身有问题所导致的。因此,不仅是初学者会对字符编码感到模糊,有的底层开发人员同样对字符编码缺乏准确的理解。 回页首 1. 编码问题的由来,相关概念的理解 1.1 字符与编码的发展 从计算机对多国语言的支持角度看,大致可以分为三个阶段:   系统内码 说明 系统 阶段一 ASCII 计算机刚开始只支持英语,其它语言不能够在计算机上存储和显示。 英文 DOS 阶段二 ANSI编码
(本地化) 为使计算机支持更多语言,通常使用 0x80~0xFF 范围的 2 个字节来表示 1 个字符。比如:汉字 '中' 在中文操作系统中,使用 [0xD6,0xD0] 这两个字节存储。

不同的国家和地区制定了不同的标准,由此产生了 GB2312, BIG5, JIS 等各自的编码标准。这些使用 2 个字节来代表一个字符的各种汉字延伸编码方式,称为 ANSI 编码。在简体中文系统下,ANSI 编码代表 GB2312 编码,在日文操作系统下,ANSI 编码代表 JIS 编码。

不同 ANSI 编码之间互不兼容,当信息在国际间交流时,无法将属于两种语言的文字,存储在同一段 ANSI 编码的文本中。 中文 DOS,中文 Windows 95/98,日文 Windows 95/98 阶段三 UNICODE
(国际化) 为了使国际间信息交......

阅读全文(1730) | 评论:0

正则表达式话题(2008-08-17 17:20:00)

摘要:[原创文章,转载请保留或注明出处:http://www.regexlab.com/zh/regtopic.htm] 引言 本文将逐步讨论一些正则表达式的使用话题。本文为本站基础篇之后的扩展,在阅读本文之前,建议先阅读正则表达式参考文档一文。 1. 表达式的递归匹配 有时候,我们需要用正则表达式来分析一个计算式中的括号配对情况。比如,使用表达式 "\( [^)]* \)" 或者 "\( .*? \)" 可以匹配一对小括号。但是如果括号 内还嵌有一层括号的话 ,如 "( ( ) )",则这种写法将不能够匹配正确,得到的结果是 "( ( )" 。类似情况的还有 HTML 中支持嵌套的标签如 "<font> </font>" 等。本节将要讨论的是,想办法把有嵌套的的成对括号或者成对标签匹配出来。 匹配未知层次的嵌套: 有的正则表达式引擎,专门针对这种嵌套提供了支持。并且在栈空间允许的情况下,能够支持任意未知层次的嵌套:比如 Perl,PHP,GRETA 等。在 PHP 和 GRETA 中,表达式中使用 "(?R)" 来表示嵌套部分。 匹配嵌套了未知层次的 "小括号对" 的表达式写法如下:"\(  ([^()]  |  (?R))*  \)"。     [Perl 和 PHP 的示例代码] 匹配有限层次的嵌套: 对于不支持嵌套的正则表达式引擎,只能通过一定的办法来匹配有限层次的嵌套。思路如下: 第一步,写一个不能支持嵌套的表达式:"\( [^()]* \)","<font>((?!</?font>).)*</font>"。 这两个表达式在匹配有嵌套的文本时,只匹配最内层。 第二步,写一个可匹配嵌套一层的表达式:"\( ([^()] | \( [^()]* \))* \)"。这个表达式在匹配嵌套层数大于一时,只能匹配最里面的两层,同时,这个表达式也能匹配没有嵌套的文本或者嵌套的最里层。 匹配嵌套一层的 "<font>" 标签,表达式为:"<font>((?!</?font>).|(<font>((?!</?font>).)*</font>))*&......

阅读全文(1155) | 评论:0