没有用 CXimage 它继承于TIMAGE 有如下两个方法img1.Picture.SaveToFile();
img1.Picture.Graphic.SaveToStream(); 存入数据库两种一种存图片路径 一种以BOLOB 形式存入数据库 存
ADOQuery1.Close;
ADOQuery1.SQL.Text:= 'insert into test1 values(:id,:pic) ';
ADOQuery1.Parameters[0].Value:=1;
ADOQuery1.Parameters[1].LoadFromFile( 'd:\temp\025.jpg ',ftBlob );
ADOQuery1.ExecSQL;
取
VAR
MS: TMemoryStream;
Jpg:TJpegImage;
begin
MS := TMemoryStream.Create;
Jpg:=TJpegImage.Create; ADOQuery1.Close;
ADOQuery1.SQL.Text:= 'select id,pic from test1 where id=1 ';
ADOQuery1.Open;
Edit1.Text:=IntToStr(ADOQuery1.FieldValues[ 'id ']);
(ADOQuery1.FieldByname( 'pic ') AS TBlobField).SaveToStream(ms);
MS.Position :=0;
jpg.LoadFromStream(ms);
Image1.Picture.Assign(jpg);
jpg.Free;
MS.Free;
end;
img1.Picture.Graphic.SaveToStream(); 存入数据库两种一种存图片路径 一种以BOLOB 形式存入数据库 存
ADOQuery1.Close;
ADOQuery1.SQL.Text:= 'insert into test1 values(:id,:pic) ';
ADOQuery1.Parameters[0].Value:=1;
ADOQuery1.Parameters[1].LoadFromFile( 'd:\temp\025.jpg ',ftBlob );
ADOQuery1.ExecSQL;
取
VAR
MS: TMemoryStream;
Jpg:TJpegImage;
begin
MS := TMemoryStream.Create;
Jpg:=TJpegImage.Create; ADOQuery1.Close;
ADOQuery1.SQL.Text:= 'select id,pic from test1 where id=1 ';
ADOQuery1.Open;
Edit1.Text:=IntToStr(ADOQuery1.FieldValues[ 'id ']);
(ADOQuery1.FieldByname( 'pic ') AS TBlobField).SaveToStream(ms);
MS.Position :=0;
jpg.LoadFromStream(ms);
Image1.Picture.Assign(jpg);
jpg.Free;
MS.Free;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货