AspJpeg用户手册 第四章02

| 分类: 外文翻译 订阅所有外文翻译的日志

4.7 代码样例Code Sample

下面代码样例通过对一张图像应用多种交加起来的转换演示了上面提到的大部分特效。文件04_params.asp/aspx包含了一个内含勾选框和单选钮的Form,控制图片的视觉效果。文件script 04_process.asp/aspx 包含着The following code sample demonstrates most of the above mentioned features by interactively applying various transformations to an image. The file 04_params.asp/aspx contains a form with checkboxes and radio buttons controlling the visual appearance of the image. This file invokes the script 04_process.asp/aspx which contains the actual image modification routine shown below.

VB Script:

<%
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.Open Server.MapPath("clock.jpg")
Jpeg.Width = Jpeg.OriginalWidth * .8
Jpeg.Height = Jpeg.OriginalHeight * .8

If Request("Grayscale") = "1" Then
    Jpeg.Grayscale 1
End If

If Request("Sharpen") = "1" Then
    Jpeg.Sharpen 1, 250
End If

If Request("Horflip") = "1" Then
    Jpeg.FlipH
End If

If Request("Verflip") = "1" Then
    Jpeg.FlipV
End If

Jpeg.Quality = Request("Quality")
Jpeg.Interpolation = Request("Interpolation")

If Request("Crop") = 1 Then
    Jpeg.Crop 30, 30, 470, 320
End If

Jpeg.SendBinary
%>

C#:

<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="ASPJPEGLib" %>
<%@ Page aspCompat="True" Language="C#" Debug="true" %>
<script runat="server" LANGUAGE="C#">

void Page_Load(Object Source, EventArgs E)
{
ASPJPEGLib.IASPJpeg objJpeg;
objJpeg = new ASPJPEGLib.ASPJpeg();

objJpeg.Open( Server.MapPath("clock.jpg") );

objJpeg.Width = (int)(objJpeg.OriginalWidth * 0.8);
objJpeg.Height = (int)(objJpeg.OriginalHeight * 0.8);

if( Request["Grayscale"] == "1" )
objJpeg.Grayscale( 1 );

if( Request["Sharpen"] == "1" )
objJpeg.Sharpen( 1, 250 );

if( Request["Horflip"] == "1" )
objJpeg.FlipH();

if( Request["Verflip"] == "1" )
objJpeg.FlipV();

objJpeg.Quality = int.Parse(Request["Quality"]);

objJpeg.Interpolation = int.Parse(Request["Interpolation"]);

if( Request["Crop"] == "1" )
objJpeg.Crop( 30, 30, 470, 320 );

objJpeg.SendBinary(Missing.Value);
}
</script>

点击下例链接来运行这些样例代码:Click the links below to run this code sample:

http://localhost/aspjpeg/manual_04/04_params.asp

http://localhost/aspjpeg/manual_04/04_params.aspx




评论: 0 | 引用: 0 | 查看次数: 3036
发表评论
本站不欢迎游客针对博客文章发表评论,留言请点此