易截截图软件、单文件、免安装、纯绿色、仅160KB

ASP.NET(C#)图片上传压缩成缩略图的代码

// 按模版比例生成缩略图(以流的方式获取源文件)
//生成缩略图函数
//顺序参数:源图文件流、缩略图存放地址、模版宽、模版高
//注:缩略图大小控制在模版区域内
public static void MakeSmallImg(System.IO.Stream fromFileStream,string fileSaveUrl,System.Double templateWidth,System.Double templateHeight)
{
//从文件取得图片对象,并使用流中嵌入的颜色管理信息
System.Drawing.Image myImage = System.Drawing.Image.fromStream(fromFileStream,true);
//缩略图宽、高
System.Double newWidth = myImage.Width , newHeight = myImage.Height;
//宽大于模版的横图
if(myImage.Width>myImage.Height || myImage.Width==myImage.Height)
{
if(myImage.Width > templateWidth)
{
//宽按模版,高按比例缩放
newWidth = templateWidth;
newHeight = myImage.Height * (newWidth/myImage.Width);
}
}
//高大于模版的竖图
else
{
if(myImage.Height > templateHeight)
{
//高按模版,宽按比例缩放
newHeight = templateHeight;
newWidth = myImage.Width * (newHeight/myImage.Height);
}
}
//取得图片大小
System.Drawing.Size mySize = new Size((int)newWidth,(int)newHeight);
//新建一个bmp图片
System.Drawing.Image bitmap = new System.Drawing.Bitmap(mySize.Width,mySize.Height);
//新建一个画板
System.Drawing.Graphics g = System.Drawing.Graphics.fromImage(bitmap);
//设置高质量插值法
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
//设置高质量,低速度呈现平滑程度
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//清空一下画布
g.Clear(Color.White);
//在指定位置画图
g.DrawImage(myImage , new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height) ,
new System.Drawing.Rectangle(0, 0, myImage.Width,myImage.Height) ,
System.Drawing.GraphicsUnit.Pixel);
///文字水印
//System.Drawing.Graphics G=System.Drawing.Graphics.fromImage(bitmap);
//System.Drawing.Font f=new Font("宋体",10);
//System.Drawing.Brush b=new SolidBrush(Color.Black);
//G.DrawString("myohmine",f,b,10,10);
//G.Dispose();
///图片水印
//System.Drawing.Image copyImage = System.Drawing.Imag


相关文档:

ASP.NET Response.Redirect 丢失 Session的问题

最近做了一个项目发现 Response.Redirect 后 Session 会丢失,搞了两天终于发现问题所在。
问题代码
Session["xxx"] = xxx;
Response.Redirect("yyy.aspx");

当页面跳转到 yyy.aspx , Session 丢失,访问 Session[“xxx”] 得到 null.
原因:当asp.net 执行 Response.Redirect 时会 ......

ASP.NET 对FileUpLoad验证,上传图片到文件

(1) ASP.NET 的数据验证空件RegularExpressionValidator 实现验证FileUpLoad上传文件的类型
 <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="FileUpload1"
        ErrorMessage="格式不准确,只能(.jpg|.JPG|.gif|.G ......

Asp.net 发送大量邮件超时的解决办法

我们知道在.Net中发送邮件使用的是SmtpClient 类,比如简单的如下:
            SmtpClient client = new SmtpClient(args[0]);
            // Specify the e-mail sender.
     ......

c#和javascript交互

在asp.net开发中,经常会用到后台和前台的交互,就此总结了一点c#和javascript相互操作的方法
1.在后台c#代码中调用jacascript的方法
javascript代码:
<script type="text/javascript" language="javascript">
function test()
{
alert("oec2003");
return false;
}
</s ......

asp、php、asp.net、jsp介绍及优缺点比较


现在主流的网站开发语言无外乎asp、php、asp.net、jsp等。
网页从开始简单的hmtl到复杂的服务语言,走过了10多个年头,各种技术层出不穷,单个的主流技术也在不断翻新的版本,现在分析下各种语言的区别、优势、劣势、开发注意事项!
HTML:当然这是网页最基本的语言,每一个服务器语言都需要它的支持,要学习,这个肯定是开 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号