top
Loading...
給ASP增加繪圖功能
好東西大家分享:一個用來畫圖的組件(畫餅圖,條形圖,各種形狀圖象的組件)

東西是好,可惜我沒地方放這個組件,哎。

為什么說是個好東西了,大家看看下面的介紹就知道了該組件有兩個版本,一個是注冊版本,一個是非注冊版本非注
冊版本功能:(雖然是非注冊的,但是可以一直使用下去的哦,這也是一個為什么我大力推薦的原因之一)

1。可生成JPEG格式的圖形文件
2。可生成透明的GIF格式的圖形文件
3。可生成交錯的GIF格式的圖形文件
4。可以使用兩種方式保存圖形文件:一種是直接生成圖形文件;另外一種是保存到數組中然后直接輸出到WWW頁面中5。可
以繪制文本圖形,并且支持安裝在你機器上的任何字體的文本6。可以導出和預覽由OLE服務程序生成的文檔,例如MS
Word,Excel等等。
7。可以使用位圖方式自由的縮放,鏡像,旋轉和剪切圖形
8。可使用本地圖形緩存
9。可以ZOOM圖片
10。可以獲取任何JPEG, GIF,BMP格式文件的詳細信息
11。可以進行Windows抓屏
12。可生成動態GIF非注冊版本的限制如下:

(1)。只能夠最多使用8種顏色,不過我認為對大多數人來說根本不算什么限制的,呵呵
(2)。能夠生成的最大圖形尺寸為320x240如果是注冊版本:
13。可在線修改現有的GIF, JPEG和BMP文件14。可自定義調色板15。可循環放映GIF動畫

例子程序:
VBScript的例子:

set obj=CreateObject("shotgraph.image")
size=201
obj.CreateImage size,size,4
obj.SetColor 0,255,255,255
obj.SetColor 1,0,0,0
obj.SetColor 2,255,108,0
obj.SetColor 3,0,0,204
obj.SetBgColor 0
obj.FillRect 0,0,size-1,size-1
obj.SetDrawColor 1
obj.Line size-1,0,0,size-1
obj.SetBgColor 2
obj.Ellipse 5,5,size-6,size-6
obj.SetBgColor 3
obj.Ellipse 5,(size-5)/4,size/2,(size-5)*3/4
obj.GifImage 0,1,"test.gif"
ASP的例子代碼:

Response.ContentType="image/gif"
set obj=Server.CreateObject("shotgraph.image")
size=201
obj.CreateImage size,size,4
obj.SetColor 0,255,255,255
obj.SetColor 1,0,0,0
obj.SetColor 2,255,108,0
obj.SetColor 3,0,0,204
obj.SetBgColor 0
obj.FillRect 0,0,size-1,size-1

obj.SetDrawColor 1
obj.Line size-1,0,0,size-1
obj.SetBgColor 2
obj.Ellipse 5,5,size-6,size-6
obj.SetBgColor 3
obj.Ellipse 5,(size-5)/4,size/2,(size-5)*3/4

img=obj.GifImage(0,1,"")
Response.BinaryWrite img

那么如何畫動畫呢,步驟如下:
1.Create一個"shotgraph.image"對象
2.隨便畫點東西把,就看你的創意了
3.調用TrackAdd函數
4.重復2,3步知道你想要的禎數
5.如果想要重復放動畫,調用TrackLoop方法,不過只有注冊版本有此功能
6.調用TrackPlay方法生成這個動化文件
例子代碼如下:
set obj=CreateObject("shotgraph.image")
xsize=400
ysize=50

obj.CreateImage xsize,ysize,256
obj.InitClipboard xsize,ysize*2
obj.SelectClipboard True
obj.ReadImage "frame1.gif",pal1,0,0
obj.ReadImage "frame2.gif",pal2,0,ysize
obj.BuildPalette 0

obj.Copy 0,0,xsize,ysize,0,0,"SRCCOPY"
obj.TrackAdd -1,0,0,0,0,xsize,ysize,50
obj.Copy 0,0,xsize,ysize,0,ysize,"SRCCOPY"
obj.TrackAdd -1,0,0,0,0,xsize,ysize,50

obj.TrackLoop 0
obj.TrackPlay "frames12.gif"

怎么畫文本文字呢,呵呵,過程如下:
使用時,請注意FontSmoothing這個屬性:
它是用來定義文字是否防鋸齒的。
0 - 使用系統默認設置
1 - 不防鋸齒
2 - 防鋸齒
代碼如下:

<%
Response.Contenttype="image/gif"
Set g=CreateObject("shotgraph.image")
g.CreateImage 320,200,16
g.SetColor 0,255,255,255
g.SetColor 1,0,0,0
g.SetBgColor 0
g.SetTextColor 1
g.FillRect 0,0,320,200
g.FontSmoothing=1
g.CreateFont "Arial",0,42,0,True,False,False,False
g.TextOut 0,30,"Non-Antialiased"
g.FontSmoothing=2
g.CreateFont "Arial",0,42,0,True,False,False,False
g.TextOut 0,120,"Antialiased"
g.BuildPalette 2
Response.BinaryWrite g.GifImage(-1,0,"")
%>

下載地址:
http://download.proxy.ru/mike/shotgraph/
http://www.geocities.com/SiliconValley/Foothills/9219/shotgraph/

北斗有巢氏 有巢氏北斗