你的位置:首页 > 软件开发 > ASP > 实用ASP组件介绍--动态图形组件

实用ASP组件介绍--动态图形组件

发布时间:2009-12-12 23:53:00
9.1.1.1 AspImage组件关于AspImageASPImage可允许你从asp中随意创建和修改图片。你可以利用这个组件,创建自己的动态图形。 AspImage包括以下特性:创建动态GIF生成GIF(仅指RLE编码,不支持载入GIF)、JPG,PNG和BMP格式的图片创建和修改图像渐进填充支持rectangl

9.1.1.1              AspImage组件

关于AspImage

ASPImage可允许你从asp中随意创建和修改图片。你可以利用这个组件,创建自己的动态图形。

 

AspImage包括以下特性:

创建动态GIF

生成GIF(仅指RLE编码,不支持载入GIF)、JPG,PNG和BMP格式的图片

创建和修改图像

渐进填充

支持rectangle(矩形画图),arc(弧形)和circle(圆)等画图方法

切割,抽取,修改大小和旋转图形

按钮,变暗,加亮和其他效果

从OLE变量或其他AspImage对象中载入图像

支持response.binarywrite

 

ASPImage的安装

将dll文件,拷贝到一个子目录,例如NT的目录\winnt\system32,win95/98的目录\windows\system.

注册dll文件,命令行将当前目录换到该目录,然后键入:

  regsvr32 aspping.dll

regsvr32在windows系统目录可以找到   

 

ASPImage的使用说明

组件使用方法:set oVar=Server.CreateOject(“AspImage.Image”)

下表列出了ASP Image的属性

编号

属性

描述

举例

1

AntiAliasText

该属性允许你在图片中建立无锯齿文本,默认值为False

 

Image.AntiAliasText = True

2

AutoClear

默认值为真。一旦图片保存后,现有图片将被清除。如将AutoClear设置为False,图片保存后仍可以保留现有版本,对其进行处理。

Image.AutoClear = false

3

AutoSize

确定当图片被拖动到现有坐标之外时是否将该图片剪切到合适大小。该属性为真时,图片将配合要求自动增大。为假时,拖动操作将被剪切到合适现有图片的大小。

Image.AutoSize = False

 

4

BackgroundColor

整型数,用来指定背景色。

Image.BackgroundColor = vbWhite

5

Bold

True or false. 指定字体是否加粗。

Image.Bold = True

6

BrushColor

用以指定格式刷的颜色(1.8以上版本适用,使用格式刷之后背景色失效)

Image.BrushColor = VbRed

 

7

BrushStyle

用来指定格式刷的刷笔样式. Value Type Description

0 Solid 填充方式

1 Clear 清除方式

2 Horizontal 水平方向

3 Vertical 垂直方向

4 FDiagonal 45度自左到右斜向下

5 BDiagonal 45度自左到右斜向上

6 Cross 水平和垂直交叉方式

7 DiagCross 45度交叉方式

 

8

Error

用于记录在调用各种方法的过程中可能出现的错误信息。

Response.Write "Error: " & Chart.Error

9

Expires

如果使用的ASPImage组件是测试版或beta版,该属性返回该组件失效日期。 

Response.Write "Component Expires: " & Image.Expires

 

10

FileName

指定用SaveImage方法保存文件时文件的绝对路径。

Image.FileName = "d:\inetpub\wwwroot\images\abc.jpg"

 

11

FontColor

整型值,指定字体的颜色。

Image.FontColor = vbRed

12

FontName

字符型,指定字体名称。

Image.FontName = "MS Sans Serif"

13

FontSize

整型值,指定字体的大小。

Image.FontSize = 12

14

Image

该属性只读,它包含当前图片的二进制数据。用户可以直接将二进制数据写如客户端,而不使用saveimage方法,具体采用那种方式需要视应用程序的设计而定。在ASP中可以使用response.binarywrite方法将图片的二进制数据写入客户端,但要注意把contenttype属性设置成相应的值。现有版本image属性仅支持JPEG或PNG文件。包含文件中的BinWTExt.asp介绍了如何使用该属性。在使用该属性之前把imageformat属性设置成JPG或PNG。

 

15

ImageFormat

该属性指定要保存的图片类型。

 合法的值有:

JPG = 1

BMP = 2

PNG = 3

GIF = 5

Image.ImageFormat = 5

Image.FileName = "c:\inetpub\wwwroot\images\logo.gif"

 

16

JPEGQuality

JPEG图象的质量。合法值是1到100。

Image.JPEGQuality = 95

17

MaxX

指定图象的X方向大小。

Image.MaxX = 100

18

MaxY

指定图象的Y方向大小。

Image.MaxY = 100

 

19

PadSize

该属性是允许用户在文字周围按水平和垂直方向用背景色自动填充的宽度。

Image.PadSize = 5

 

20

PenColor

指定在画布上画线时所使用的颜色。

Image.PenColor = &h80000011

21

PenStyle

指定画线时画笔的样式。

0 Solid 实线

1 Dash 虚线

2 Dot 点线

3 DashDot 虚线与点交替

4 DashDotDot 虚线与两点交替

5 Clear 无 (用于去掉使用当前画笔所画图型的边线)

6 InsideFrame 实线,但如果宽度大于1就可以使用渐进色

 

 

22

PenWidth

指定画笔的象素宽度

Image.PenWidth = 2

23

ProgressiveJPEGEncoding

指定当图片解压时是否以增量显示,默认值为False。

上次就没有看懂,现在勉强翻译出来,还望大家指正。

ProgressiveJPEGEncoding = true

24

RegisteredTo

返回购买ASPImage组件的用户名和公司名,当该组件是测试版时返回“Evaluation”字样。

 

25

Strikeout

True or false. 指定字体是否有删除线。

Image.Strikeout = False

26

TextAngle

指定用TextOut方法写文字时文字倾斜的角度,默认值为0

Image.TextAngle = 90

27

ThreeDColor

设定立体文字的阴影色。

Image.ThreeDColor = &h80000011

28

TransparentColor

指定在保存GIF图片时所需透明的颜色。

Image.TransparentColor = vbWhite

29

TransparentText

指定在使用TextOut方法在图片上写入文字时是否使用透明模式,默认值为True。

Image.TransparentText = true

 

30

Underline

True or false 指定文字是否有下划线

Image.Underline = False

31

Version

取得组件的内部版本号

Response.Write "Component Version: " & Image.Version

32

X

该属性指定图片中当前X坐标

Image.X = 10

33

Y

该属性指定图片中当前Y坐标 

Image.Y = 10

表9.3.2.1-1AspImage组件属性列表

 

ASPImage的方法

编号

方法

参数

返回值

描述

1

AddAnimationControl

intDelay, bolTransparent, intTransparentColor

N/A

在GIF各帧间加入一个动画控制块。intdelay是指到跳下副图片所需的延迟的微秒数(1.8以上版本适用)

Image.AddAnimationControl intDelay, false, 0

 

2

AddImage

strFileName, intX, intY

True/False

使用x、y坐标在画布上加入一个新图片

3

AddImageToAnimation

N/A

N/A

将当前图片加入GIF动画中。在调用addimagetoanimation之前必须先调用startanimation,参见saveAnimation. (1.8以上版本适用)

Image.AddImageToAnimation

4

AddImageTransparent

strFileName, intX, intY, intTransparentColor

True/False

使用x、y坐标在画布上加入一个新图片. strFilename为指定需要透明化的图片. intTransparentColor是指定用于透明化时确切的颜色. 相似的颜色将不会被替代

Image.AddImageTransparent "d:\apps\gr3\im.jpg", 5, 12, vbWhite

5

AngleArc

intX, intY, intRadius, dblStartDegrees, dblSweepDegrees

N/A

AngleArc可用来画一段直线和弧线. 直线是从当前位置到弧线的起点,弧线是沿着给定圆心和半径的圆画出的一段圆弧. 圆弧的长度是由给定起点和弧度来确定的. (1.8以上版本适用)

Image.AngleArc 50, 60, 60, 50, 90

6

Arc

intX1, intY1, intX2, intY2, intX3, intY3, intX4, intY4

N/A

在图片中沿着由指定矩形确定的椭圆的圆周画一段圆弧

7

BeginPath

N/A

N/A

打开一个路径 (参见EndPath and FillPath). 该方法支持以下路径: Polyline, Polygon, PolyBezier

8

BrightenImage

intDegree

N/A

使已有图片显示亮度加强。

Example:

Image.BrightenImage 30

9

CreateBlackWhite

N/A

N/A

将当前图片转化成灰度图片

10

CreateButton

intBorder, bolSoft

N/A

生成一个类似图片边框的按钮,宽度为intborder个象素。如果bolSoft为真,按钮的边框变得柔和

Example:

 

Image.CreateButton 10, true

11

CreateNegative

N/A

N/A

对当前图片生成反相效果

12

CropImage

intStartX, intStartY, intWidth, intHeight

N/A

使用起始x、y坐标位置和宽、高来剪切图片

13

Chord

intX1, intY1, intX2, intY2, intX3, intY3, intX4, intY4

N/A

画一个由直线和椭圆交叉部分指定的封闭图形

14

ClearImage

N/A

N/A

用当前背景色作为填充色清除图片的画布

15

DarkenImage

intDegree

N/A

使现有图片显示亮度加深

Example:

 

Image.DarkenImage 30

16

DoMerge

strFileName, intPercent

N/A

载入由strFileName指定的图片 (BMP或JPG文件需要完整的路径) ,然后和现有图片进行合并。参数intPercent值越接近100,载入的图片在现有图片中可见部分越多。 参数intPercent取值范围为1~99 . (1.8以上版本适用) 如若在使用loadimage方法载入图片时出错,那么domerge函数同样也会失效,这个函数使用的是相同的载入函数. 因此如果合并失败,试着先用loadimage函数将图片载入。如果还是不管用,查阅该文档的FAQ部分,找到loadimage函数不能成功载入图片的原因。一旦成功就可以进行DoMerge

Example:

 

DoMerge "c:\webs\shared\images\logo.jpg", 20

17

EndPath

N/A

N/A

关闭一个路径 (参见BeginPath、FillPath)

18

Ellipse

intX1, intY1, intX2, intY2

N/A

在图片上画一个由矩形限定的椭圆

19

FillPath

N/A

N/A

FillPath函数用来关闭所有当前路径下的已打开的图形,并且使用当前格式刷和多边形填充方式对路径内部进行填充(1.8以上版本适用)

Dim aRgnPts(5,1)

 

aRgnPts(0,0) = 182

aRgnPts(0,1) = 34

aRgnPts(1,0) = 210

aRgnPts(1,1) = 72

aRgnPts(2,0) = 212

aRgnPts(2,1) = 112

aRgnPts(3,0) = 146

aRgnPts(3,1) = 112

aRgnPts(4,0) = 146

aRgnPts(4,1) = 76

 

Image.BrushStyle = 6

Image.BrushColor = vbRed

Image.BeginPath

Image.Polygon aRgnPts

Image.EndPath

Image.FillPath

 

20

FillRect

intLeft, intTop, intRight, intBottom

N/A

FillRect函数填充图片中指定的矩形

21

FlipImage

intDirection

N/A

翻转图片

参数intDirection的合法值为:

1 : 水平

2 : 垂直

22

FloodFill

intX, intY, intColor, intFillStyle

N/A

使用FloodFill函数填充图片中非矩形区域. 填充区域的边界是由从点(x,y)到颜色的边界处(包含所遇到的intcolor)。 Floodfill是使用背景色和格式刷样式来进行填充

参数intFillStyle合法值为:

 

Value Type Description

0 Surface 填充所有由intcolor参数指定颜**域,直至和另外一种颜色的交叉处

1 Border 填充所有非intcolor参数指定颜**域,直至和intcolor的交叉处

 

23

FrameRect

intLeft, intTop, intRight, intBottom

N/A

使用现有画笔在矩形区域的周围画一个象素宽的边界。

24

LoadImage

strFileName

True/False

载入一个已有的图片到画布上。载入的图片类型为JPG、BMP。使用loadimage后会重置文字属性,因此文字的字体大小、字体和特性的改变都会丢失。在调用LoadImage后记得要把修改字体属性。

25

GetPixel

intX, intY

IntColor

返回点(x,y)的象素颜色

26

GradientOneWay

intBeginColor, intEndColor, intDirection

N/A

生成颜色范围从intbegincolor到intendcolor单向渐变填充

27

GradientTwoWay

intBeginColor, intEndColor, intDirection, intInOut

N/A

生成颜色范围从intbegincolor到intendcolor双向渐变填充

28

LineTo

intX, intY

N/A

画一条从当前x,y到intx,inty的直线

29

LoadBlob

ovBlob, intType

True/False

LoadBlob允许载入二进制数据的图片,这些图片可以是其他ASPImage对象(使用image属性)得到的、或者是从其他可以通过OLE变量指针得到二进制图象数据的数据源中得到。ovBlob 一个指向原图象数据的OLE变量指针。原图象数据是装载在ASPImage画布上的。intType参数指定了二进制文件的类型。合法的类型为:

1 : JPEG

2: BMP

Example:

 

Set Image = Server.CreateObject("AspImage.Image")

Image.LoadImage ("d:\inetpub\wwwroot\images\map.jpg")

Image.FlipImage 2

Image.ImageFormat = 1

 

Set Image2 = Server.CreateObject("AspImage.Image")

Image2.LoadBlob Image.Image, 1

[Image2 now has a flipped image of map.jpg]

30

Pie

intX1, intY1, intX2, intY2, intX3, intY3, intX4, intY4

N/A

画一个椭圆扇形(好象是这么说的吧,几何都忘干净了)intX1, intY1, intX2, intY2是椭圆的外接矩形的顶点,intX3, intY3, intX4, intY4是两条半径上的点。

31

PolyBezier

aryPoints

N/A

画一个或多个贝塞尔曲线。 在一个polybezier中最大支持99点(1.8以上版本适用)

Dim RgnPts(3,1)

 

RgnPts(0,0) = 79

RgnPts(0,1) = 70

RgnPts(1,0) = 64

RgnPts(1,1) = 86

RgnPts(2,0) = 47

RgnPts(2,1) = 88

Image.PolyBezier RgnPts

32

Polygon

aryPoints

N/A

Polygon 在画布上画若干条经过指定点的直线,并且画一条由终点到起点的直线将该多边形封闭。(1.8以上版本适用)

Dim RgnPts(4,1)

 

RgnPts(0,0) = 70

RgnPts(0,1) = 76

RgnPts(1,0) = 310

RgnPts(1,1) = 350

RgnPts(2,0) = 200

RgnPts(2,1) = 450

RgnPts(3,0) = 100

RgnPts(3,1) = 300

Image.Polygon RgnPts

33

PolyLine

aryPoints

N/A

Polyline用当前画笔在画布上画若干条经过所有指定点的直线(1.8以上版本适用)

Dim RgnPts(3,1)

 

RgnPts(0,0) = 79

RgnPts(0,1) = 70

RgnPts(1,0) = 64

RgnPts(1,1) = 86

RgnPts(2,0) = 47

RgnPts(2,1) = 88

Image.PolyLine RgnPts

 

34

Rectangle

intX1, intY1, intX2, intY2

N/A

根据指定的点画出一个矩形

35

Resize

intWidth, intHeight

N/A

改变图片的大小,宽、高分别为intWidth, intHeight

36

RotateImage

intDegrees

N/A

按指定角度旋转图片

37

RoundRect

intX1, intY1, intX2, intY2, intX3, intY3

N/A

由三个指定的点画出一个圆

38

SaveAnimation

N/A

True/False

将当前GIF动画保存到指定文件名的文件中(1.8或以上版本适用)

Image.SaveAnimation

39

SaveImage

N/A

True/False

将当前图象保存到指定文件名的文件中。

40

SetPixel

intX, intY, intColor

N/A

将象素点(intx,inty)的颜色改成intcolor (1.8或以上版本适用)

for i = 10 to 50

Image.SetPixel 5+(rnd*10), i, vbGreen

next

41

StartAnimation

bolLoop

N/A

开始顺序播放GIF动画帧. bolLoop用来确定动画是否循环播放(1.8或以上版本适用)

Image.StartAnimation true

42

StrokeAndFillPath

N/A

N/A

关闭一个路径。使用当前画笔描绘路径的轮廓,并使用笔刷填充路径内部。(1.8或以上版本适用)

43

TextOut

strText, intX, intY, bol3d

N/A

在图片的(intx,inty)位置上使用当前的字体、颜色和其他特性写上文字strtext。如果bol3d为真,则文字以3d方式显示。

44

TextHeight

strValue

Integer

返回strvalue的文字高度(字体、字体大小、字体特性均为当前设置)

45

TextWidth

strValue

Integer

返回strvalue的文字宽度(字体、字体大小、字体特性均为当前设置)

46

TintImage

intColor

N/A

在已有图片,在图片周围用intcolor做阴影

Example:

 

Image.TintImage vbBlue

表9.3.2.1-2 AspImage组件方法列表

 

调用范例:

使用ASPImage组件仅需以下步骤:

1.       建一个对象

2.       设置若干属性

3.       调用SaveImage方法

 

以下代码举例说明如何在vbscript中使用ASPImage组件,在这个例子中我们要建立一个渐进填充的字样

 

为 "welcome to"的文字图片:

<%

  Set Image = Server.CreateObject("AspImage.Image")

 

  rem Set various font parameters

  Image.FontColor = vbBlack

  Image.Italic = True

  Image.Bold = True

  Image.FontName = "Arial"

  Image.FontSize = 12

  Image.PadSize = 10

 

  REM 计算文字的大小信息,以确定图片大小

  REM 因为要渐进填充一个区域,所以必须计算

  strMessage = "Welcome to"

  Image.MaxX = Image.TextWidth (strMessage)

  Image.MaxY = Image.TextHeight (strMessage)

 

  rem 创建一个色阶(从一个颜色到另一种颜色的范围)

  Image.GradientOneWay vbRed, vbWhite, 0

 

  rem 在图像上打印输出字符串

  Image.TextOut strMessage, Image.X, Image.Y, false

 

  rem 设置保存的文件名并保存之

  rem   注意:如果多用户调用,你应该动态产生文件名(如果同名的话,在生成文件的时候可能冲突)

  Image.FileName = "d:\inetpub\wwwroot\images\msg1.jpg"

  if Image.SaveImage then

    rem 这个文件已经被保存了,所以可以写 <img src> tag 让浏览器显示这个图。

    Response.Write "<img src='/images/loading.gif' data-original=""/images/msg1.jpg""><br>"

  else

    rem 由于某些原因,不能保存为图片文件。所以输出html

    rem   需要调试这段脚本才能找出原因。

    Response.Write "<h2>Welcome to</h2>

  end if

%>

 

通过使用SaveImage方法我们可以得知图片是否已经正确保存了。一般导致图片不能正确保存的原因是图片的保存路径不合法或者对该路径没有写的权限。

 

aspImage 1.8支持直接用response.binary向浏览器输出。

首先要把response.contenttype设置为"image/jpeg",然后设置完了各种图形的参数

之后

 

下面是代码例子:

<%

 

  rem 使用Binarywrite直接把图像写到浏览器的简单代码示例

   

  rem 设置content-type为图片

  Response.ContentType = "image/jpeg"

 

  rem 创建对象的实例

  Set Image = Server.CreateObject("AspImage.Image")

 

  rem 设置一些字体参数

  Image.FontColor = vbYellow

  Image.Italic = True

  Image.Bold = True

  Image.FontName = "Arial"

  Image.FontSize = 12

  Image.PadSize = 10

 

  rem 计算文本的大小,然后设置图像的尺寸

  rem 渐进色填充必须进行填充。。

  strMessage = "你好!" & vbCrLf & "欢迎访问" & _

               VbCrLf & "http://www.chinaasp.com"

 

  Image.MaxX = Image.TextWidth (strMessage)

  Image.MaxY = Image.TextHeight (strMessage)

 

  rem 创建一个色阶(从一个颜色到另一种颜色的范围)

  Image.GradientOneWay vbRed, vbWhite, 0

 

  rem 使用3维风格在当前坐标(x,y)位置打印文字

  Image.TextOut strMessage, Image.X, Image.Y, true

 

 

  Response.BinaryWrite Image.Image

 

  Set Image = nothing

 

%>

 

 

9.1.1.2              Image Library组件

ASP Image Library是一个十分有用的组件,运用它你可以使用ASP程序可以动态的图形。例如:使用这个部件你可以创建一个ASP计数器。ASP Image Library支持GIF(不支持动态Gif),JPG 和BMP格式的图片。

主页:http://www.overpower.com.br/ImageLib/

 

Image Library的安装

将dll文件,拷贝到一个子目录,例如NT的目录\winnt\system32,win95/98的目录\windows\system.

注册dll文件,命令行将当前目录换到该目录,然后键入:

  regsvr32 overpower.dll

 

Image Library的使用说明

组件使用方法:set oVar=Server.CreateOject(“AspImage.Image”)

 

Image Library对象属性

这个组件是使用Delphi写的。所以下面的参数说明是Pascal风格的。

 

编号

属性

描述

举例

1

Width: Integer

输出图形的宽度大小,可读可写

 

2

Height: Integer

使用这个属性可以读或修改输出图形的高度大小

 

3

BrushColor: String (color)

决定了刷子的颜色,这是户

 

4

PenColor: String (color)

设置画线和轮廓图形的画笔的颜色。边/线决定于PenMode和PenStyle。

 

5

FontFace: String

设定字体的字体名

 

6

FontSize: Integer

指定字体的大小

 

7

FontBold: Boolean

字体是否加粗

 

8

StretchQuality: Boolean

Set TRUE to enabled antialiasing after stretch images using InsertPicture or false to don't use (faster).

 

9

FontUnderline: Boolean

是否字体是带下划线的。

 

10

FontColor: String (Color)

文本字符的颜色

 

11

FontAngle: Integer

0-360之间的一个值,画字体的角度

 

12

FontAntialiasing: Boolean

字体显示的时候,是否平滑显示。(需要Plus!或Windows 98)

 

13

PenStyle: Integer

画笔的风格

1 (Solid)  实心线

2 (Dash)  划线

3 (Dot) 点线

4 (Dashdot) 点划线

5 (DashDotDot) 划点点线

6 (Clear) 没有线

7 (Insideframe) 实心线但是当PenWidth大于1,只有使用抖动颜色才有效

 

2到5 只有当PenWidth为1才有效

 

14

PenAntialiased: Boolean

使用函数line画笔宽为1图的时候是否平滑

 

15

PenWidth: Integer

笔宽

 

16

PenMode: Integer

笔的模式

Value Pixels color 

1 (Black)  黑色

2 (White) 白色

3 (Nop) 不变

4 (Not) 画布背景色的反色

5 (Copy) 笔的颜色(Color属性指定的)

6 (Not Copy) 笔色的反色

7 (Merge pen not) 笔色和背景反色的组合

8 (Mask pen Not)  笔色和画布背景颜色的共同色的组合

9 (Merge not pen) 画布背景色和笔色反色的组合

10 (Mask not Pen) 画布背景色和笔色反色的共同色的组合

11 (Merge) 画布笔色和背景色的组合

12 (Not merge) I画布笔色和背景色的组合色的反色

13 (Mask) 笔色和画布背景颜色的共同色的组合

14 (Not mask) 笔色和画布背景颜色的共同色的组合 的反色

15 (Xor).笔色与画布颜色异或操作

16 (Not xor) 笔色与画布颜色异或操作

之后求非。

 

 

表9.3.2.2-1 Image Libray组件属性列表

 

ImageLibrary的方法

编号

方法

参数

描述

1

Textout

(X: Integer, Y: Integer, Text: String)

向画布上输出一个字符串,这个串使用FontColor, FontFace, FontSize, FontBold, FontItalic, FontUnderline, FontAngle的当前值

4

GetTextWidth: Integer

(Text: String)

计算一个字符串在图片中绘制的长度

5

GetTextHeight: Integer

(Text: String)

计算一个字符串在图片中绘制的高度

6

Line

(x1: Integer, y1: Integer, x2: Integer, y2:Integer)

画一条从(x1,y1)到(x2,y2)的线

7

Box

(x1: Integer, y1: Integer, x2: Integer, y2:Integer)

从(x1,y1)到(x2,y2)画一个框,不填充

8

Fbox

(x1: Integer, y1: Integer, x2: Integer, y2:Integer)

从(x1,y1)到(x2,y2)画一个框,填充

9

Chord

(x1: Integer, y1: Integer, x2: Integer, y2:Integer, x3: Integer, y3: Integer, x4: Integer, y4:Integer)

绘制弓弧线。在区性区域(x1,y1)到(x2,y2)的椭圆,被(x3,y3)到(x4,y4)的直线切开。弓弧线取(x3,y3)顺时针方向的走至(x4,y4),然后走直线返回(x3,y3)。

图形的轮廓取决于PenColor, PenStyle 和PenMode,图形使用BrushColor, BrushStyle 的值来填充。

10

Ellipse

(x1: Integer, y1: Integer, x2: Integer, y2:Integer)

画一个在区性区域(x1,y1)到(x2,y2)的椭圆。

图形的轮廓取决于PenColor, PenStyle 和PenMode,图形使用BrushColor, BrushStyle 的值来填充。

11

Pie

(x1: Integer, y1: Integer, x2: Integer, y2:Integer, x3: Integer, y3: Integer, x4: Integer, y4:Integer)

饼图。在区性区域(x1,y1)到(x2,y2)的椭圆。

椭圆圆心到(x3,y3),椭圆圆心到(x4,y4)两根直线之间的区域。

图形的轮廓取决于PenColor, PenStyle 和PenMode,图形使用BrushColor, BrushStyle 的值来填充。

12

Arc

(x1: Integer, y1: Integer, x2: Integer, y2:Integer, x3: Integer, y3: Integer, x4: Integer, y4:Integer)

使用当前的Pen属性绘制弧线。

在区性区域(x1,y1)到(x2,y2)的椭圆。弧线从椭圆和直线(椭圆圆心到(x3,y3))的交点开始,到椭圆和直线(椭圆圆心到(x4,y4))的交点结束。

13

Rectangle

(x1: Integer, y1: Integer, x2: Integer, y2:Integer)

使用PenStyle, PenMode, PenColor, PenWidth 画一个矩形

并使用BrushColor,BrushStyle 填充之。

要填充矩形区域,但不用当前pen绘制边线,可以使用FillRect方法。如果要画不填充的矩形区域,使用FrameRect 或 Polygon 。画圆脚矩形使用 RoundRectangle

14

RoundRectangle

 

(x1: Integer, y1: Integer, x2: Integer, y2:Integer, x3: Integer, y3:Integer)

使用PenStyle, PenMode, PenColor, PenWidth 绘制圆角矩形,并用BrushColor,BrushStyle填充之。矩形四个角为

(X1,Y1), (X2,Y1), (X2,Y2), (X1,Y2)。圆角的弧形决定于椭圆(该椭圆的高度是y3,宽度是x3)

15

GetPixel: String (Color)

 

 

(x: Integer, y: Integer)

当前区域(x,y)位置的像素

16

SetPixel

 

(x: Integer, y: Integer,Color: String (Color))

使用颜色Color画像素(x,y)

17

FloodFill

(x: Integer, y: Integer, Color: String (Color))

使用BrushColor,BrushStyle填充不规则区域。该区域的边界从(x,y)处向外扩散,直到遇到不同颜色的边界为止。

18

PictureSize

(Filename: String, *pWidth: Integer, *pHeight:Integer)

获得由filename指定的文件名的图片文件的大小尺寸(宽和高)。

19

SavePicture

(Filename: String, format: Integer, JPGQuality: Integer, GIFTransparentColor:String (color))

保存图片到服务器上。格式可以是

1- BMP

2-Gif (使用GIFTransparentColor参数)

3-JPG(使用JPGQuality参数)

 

 

20

InsertPicture

(Filename: String, x: Integer, y: Integer, Scale: Boolean, width: integer, height:integer)

在位置(x,y)插入图片(GIF,BMP或JPG)

21

PictureBinaryWrite

(format: integer, JPEGQuality: Integer, GIFTransparentColor: String (color))

使用需要的格式和response.contenttype,输出response.binarywrite 。

22

GetRGBColor:String (Color)

(R: Integer, G: Integer, B: Integer)

指定R(红),G(绿),B(蓝)三个元色的值,返回一个颜色的值(字符串)

23

GetRValue: Integer

(Color: String (Color))

返回一个颜色的红元色值。

24

GetGValue: Integer

(Color: String (Color))

返回一个颜色的绿元色值。

25

GetBValue: Integer

(Color: String (Color))

返回一个颜色的蓝元色值。

26

Fillrect

(x: Integer; y: Integer; x2: Integer; y2: Integer)

用当前的brush,填充矩形区域

 

27

PolyBezier

Points: Array (x,x) of Integer

贝塞尔曲线

28

Polygon

(Points: Array (x,x) of Integer)

绘制闭合的多边形(使用当前的pen的值)。并使用Brush的值填充。如果不填充这个多边形,可以调用Polyline

29

SidePolygon

(x: Integer; y: Integer; ray: Integer; sides: Integer; angle: Integer)

绘制一个多边形,以(x,y)为中心,并以一个定义好的数值(sides)发散出去。你可以使用angle参数旋转这个多边形。

30

Fillrect

(x: Integer; y: Integer; x2: Integer; y2: Integer; Startcolor: Color (String); EndColor: Color (String))

使用一个水平方向的色阶(StartColor->EndColor)填充矩形。

31

Polyline

 

(Points: Array (x,x) of Integer)

多边形 但是不填充。如果只有两个点,就绘制一个直线。

表9.3.2.2-2 Image Libray组件方法列表

 

使用范例:

‘ 这里的代码是一个图形计数器。它会在站点根目录下创建一个文本文件纪录访问数目。

‘ 调用方法: <img src='/images/loading.gif' data-original=”count.asp?id=mypage1”> 可以改变mypage1为你其他的计数名字。

 

function Barra(Pasta)

Barra = Pasta

if mid(Barra,len(Barra),1) <> "\" then Barra = Barra + "\"

end function

 

Set Sistema = CreateObject("Scripting.FileSystemObject")

set ILIB = server.createobject("Overpower.ImageLib")

BaseFolder = barra(server.mappath("/"))

CounterFile = BaseFolder + "count"+request.querystring("ID") + ".COU"

contagem = 0

if Sistema.FileExists(counterfile) then

Set arquivo = Sistema.GetFile(counterfile)

Set texto = arquivo.OpenAsTextStream(1, -2)

contagem = texto.readline

texto.close

end if

contagem = contagem + 1

 

Set texto = sistema.CreateTextFile(counterfile, true, false)

texto.writeline contagem

texto.close

 

texto = contagem & " visit"

if contagem > 1 then texto = texto + "s"

ILIB.FontColor = "ClRed"

ILIB.BrushColor = "clBlack"

ILIB.FontFace = "Comic Sans MS"

ILIB.FontSize = 12

ILIB.FontBold = false

ILIB.width = ILIB.GetTextwidth(texto)+5

ILIB.height = ILIB.GetTextHeight(texto)+5

ILIB.PenColor = "clRed"

ILIB.fBox 1,1,ILIB.WIDTH,ILIB.HEIGHT

ILIB.Textout texto,3,-3

ILIB.FontColor = "ClWhite"

ILIB.FontSize = 7

tamanho = ILIB.GetTextWidth("Example")

ILIB.Textout "Example",ILIB.width/2 - tamanho/2,10

ILIB.PictureBinaryWrite 2, 0, ""

%>

原标题:实用ASP组件介绍--动态图形组件

关键词:ASP

ASP
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。