谢谢各位大侠的指教!!!
我现在已经能够把JPG文件保存到数据库中,但是当JPG文件大于32K的时候显示就有问题,
只能看到一点图象,其他都是黑色的,请问有什么办法解决?我已经看过以前同类问题的
解答,但是还是不行!我的程序代码如下:请各位大虾帮看看有什么问题!很急,谢谢!
保存图象:
procedure TForm1.Button1Click(Sender: TObject);
var
jpegs:TJpegImage;
mstream: tstringstream;
begin
Query1.Close ; //进行存储
Query1.SQL.Clear ;
jpegs:=TJpegImage.Create;
jpegs.Assign(FootImage.Picture.Graphic);
mstream:=Tstringstream.create('');
jpegs.SaveToStream(mStream);
//在query1的SQL属性里写上:tx_temp2
Query1.SQl.ADD('Insert Into image1 (id,image) values (10,:myimage)') ;
Query1.Params[0].AsBlob:=mstream.DataString;
Query1.ExecSQL;
jpegs.Free;
mstream.Free;
end;
显示图象:
procedure TForm1.Button2Click(Sender: TObject);
var
MyJpeg:TJpegImage;
MyStm:TMemoryStream;
begin
with Query1 do
begin
sql.Clear;
sql.Add('select * from image1 where id=10');
open;
end;
if not Query1.FieldByName('image').IsNull then
begin
try
MyJpeg:=TJpegImage.Create;
MyStm:=TMemoryStream.Create;
MyStm.Clear;
TBlobField(Query1.FieldByName('image')).SaveToStream(MyStm);
MyStm.Position:=0;
MyJpeg.LoadFromStream(MyStm);
FootImage.Picture.BitMap.Assign(MyJpeg);
finally
MyJpeg.Free;
MyStm.Free;
end;
end
else
begin
if FootImage.Picture<>Nil then
begin
FootImage.Picture.Assign(Nil);
end;
end;
end;