主题:[讨论]不能显示数据库图片
procedure Tcontact.SimpleDataSet1AfterScroll(DataSet: TDataSet);
var
strm:tClientblobstream;
jpegimage:tjpegimage;
bitmap:tbitmap;
begin
strm := tClientblobstream.Create(tblobfield(simpledataset1.fieldbyname('photo')),bmread);
try
strm.position :=0;
image1.Picture.Graphic := nil;
if simpledataset1.fieldbyname('pt').asstring ='1' then //BMP型图像数据
begin
bitmap := tbitmap.Create ;
try
bitmap.LoadFromStream(strm);
image1.Picture.Graphic := bitmap;
finally
bitmap.Free;
end;
end
else if simpledataset1.fieldbyname('pt').asstring ='0' then //JPEG型图像数据
begin
jpegimage := tjpegimage.Create ;
try
jpegimage.LoadFromStream(strm);
image1.Picture.Graphic := jpegimage;
finally
jpegimage.Free ;
end;
end;
finally
strm.Free ;
end;
end;
以上程序不能在image1中显示图片有谁知道
var
strm:tClientblobstream;
jpegimage:tjpegimage;
bitmap:tbitmap;
begin
strm := tClientblobstream.Create(tblobfield(simpledataset1.fieldbyname('photo')),bmread);
try
strm.position :=0;
image1.Picture.Graphic := nil;
if simpledataset1.fieldbyname('pt').asstring ='1' then //BMP型图像数据
begin
bitmap := tbitmap.Create ;
try
bitmap.LoadFromStream(strm);
image1.Picture.Graphic := bitmap;
finally
bitmap.Free;
end;
end
else if simpledataset1.fieldbyname('pt').asstring ='0' then //JPEG型图像数据
begin
jpegimage := tjpegimage.Create ;
try
jpegimage.LoadFromStream(strm);
image1.Picture.Graphic := jpegimage;
finally
jpegimage.Free ;
end;
end;
finally
strm.Free ;
end;
end;
以上程序不能在image1中显示图片有谁知道