组件Image只处理BMP格式,请高手指点
解决方案 »
- 如何用一句sql分别求出最大值
- delphi 电子书求助
- 采取调用外部程序的方法为什么找不到sql server呢?
- 错误:Exception EACcessViiolation in Module cwts.exe at 0006A09 Access Villation at address 004c6A09 in module'cwts.exe' Read of
- delphi5的ado的bug
- 求助:关于修改表名,高手一句话解决的问题
- 如何用TeeChart画出脂肪图的曲线拟合(正态分布图)
- 关于blockread,blockwrite的使用法(为什么会“read beyond end of file”) 高分诚征答案!!
- 函数
- 我在ClientDataSet控件中实现了对某一字段的求总和,但当我对该字段的某一值更改后,发现该总和数为能自动更新,是什么原因能?
- 怎么使用selete语句的查询结果?如何动态建立索引?在线等待!!!
- 为何在程序中用起用事务就报错?
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, DBCtrls, Grids, DBGrids, Db, ADODB,jpeg, StdCtrls,dbtables;
{一定要USES JPEG单元,使能存储JPG文件格式}
type
TForm1 = class(TForm)
DataSource1: TDataSource;
ADOQuery1: TADOQuery;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
Image1: TImage;
savebutton: TButton;
showbutton: TButton;
OpenDialog1: TOpenDialog;
ADOQuery1id: TIntegerField;
ADOQuery1pic: TBlobField;
procedure savebuttonClick(Sender: TObject);
procedure showbuttonClick(Sender: TObject);
procedure DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}function JpegStartsInBlob(PicField:TBlobField):integer;
var
ghy: TADOBlobstream;
buffer:Word;
hx: string;
begin
Result := -1;
ghy := TADOBlobstream.Create(PicField, bmRead);
try
while (Result = -1) and (ghy.Position + 1 < ghy.Size) do
begin
ghy.ReadBuffer(buffer, 1);
hx:=IntToHex(buffer, 2);
if hx = ’FF’ then begin
ghy.ReadBuffer(buffer, 1);
hx:=IntToHex(buffer, 2);
if hx = ’D8’ then Result := ghy.Position - 2
else if hx = ’FF’ then
ghy.Position := ghy.Position-1;
end; //if
end; //while
finally
ghy.Free
end; //try
end;
procedure TForm1.savebuttonClick(Sender: TObject);
var
picstream:tadoblobstream;
begin
adoquery1.edit;
picstream:=tadoblobstream.Create(tblobfield(adoquery1.fields[1]),bmWrite);
if form1.opendialog1.execute then
begin
picstream.LoadFromFile(opendialog1.filename);
picstream.Position:=0;
adoquery1.edit;
tblobfield(adoquery1.Fields[1]).loadfromstream(picstream);
adoquery1.post;
end;
end;procedure TForm1.showbuttonClick(Sender: TObject);
var
ghy:TADOBlobstream;
pic:tjpegimage;
begin
ghy := TADOBlobstream.Create(Adoquery1pic, bmRead);
try
ghy.Seek(JpegStartsInBlob(Adoquery1pic),soFromBeginning);
Pic:=TJpegImage.Create;
try
Pic.LoadFromStream(ghy);
Image1.Picture.Graphic:=Pic;
finally
Pic.Free;
end;
finally
ghy.Free
end;
end;procedure TForm1.DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
begin
if button in [nbFirst, nbPrior, nbNext, nbLast] then showbutton.Click;
end;end.
那字段的编辑组件还是Image,是吧?
Adoquery1pic这是什么呢?编译时有错,请再指示
能否将你的Demo程序发到