这个是我做的ASP组件里面取Image的过程;
function TmyChart.GetImage: OleVariant;
var S:TmemoryStream;
i,j:integer;
ch:Byte;
Chart1:TChart;
p
ointer;
begin
s:=TmemoryStream.Create;
Chart1:=TChart.Create(nil);
With Chart1 do
begin
Left:= 0;
Top:= 0;
Width:=500;
Height:=350;
Title.Text.Text:='利用TeeChart在ASP组建中生成图形';
View3DOptions.Elevation:= 315;
View3DOptions.Orthogonal:= False;
View3DOptions.Perspective:= 0;
View3DOptions.Rotation := 360;
end;
With TPieSeries.Create(Chart1) do
begin
ParentChart:=Chart1;
Marks.ArrowLength:= 8;
Marks.Visible := True;
SeriesColor := clRed;
PieValues.Name := 'Pie';
PieValues.Order := loNone;
Shadow.Color := 10526880;
FillSampleValues(10);
end;
//将chart转换成GIF格式
With TGIFExportFormat.Create do
try
Panel:=Chart1;
SaveToStream(S);//保存到流里
finally
Free;
end;
Chart1.Free;
j:=S.Size;
result:=varArrayCreate([0,j-1],varByte);//创建variant数组
p:=VarArrayLock(result);
S.Seek(0,soFromBeginning);
S.Read(p^,j);//将GIF流返回,在ASP中用Response.binarywrite xxxx.getimage 就可以输出图形
vararrayunlock(result);
end;
//asp
<%@ language=VBSCRIPT %>
<% response.expires=-1
response.ContentType="image/gif"
dim Achart
set delphiASPobj=server.createobject("project.mychart")
response.binarywrite Delphiaspobj.getimage
set delphiaspobj=nothing
%>