H
huangli_nj
Unregistered / Unconfirmed
GUEST, unregistred user!
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, ExtCtrls, ExtDlgs;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Image1: TImage;
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
Image2: TImage;
OpenPictureDialog1: TOpenPictureDialog;
Button2: TButton;
Button3: TButton;
Label2: TLabel;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses GIFImage;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
SourceStream: TMemoryStream;
DestStream: TMemoryStream;
Buffer: PChar;
Count: Integer;
MyGif : TGIFImage;
imgSeal:TMemoryStream;
begin
myGif:=TGIFImage.Create;
myBmp:=TBitmap.Create;
imgSeal:=TMemoryStream.Create;
DestStream := TMemoryStream.Create;
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select SDImage from sealdata where code='+''''+trim(Edit2.Text)+'''');
Open;
if(RecordCount<=0) then
else
begin
TBlobField(ADOQuery1.FieldByName('SDImage')).SaveToStream(imgSeal);
imgSeal.ReadBuffer(Count, SizeOf(Count));
GetMem(Buffer, Count);
SourceStream:= TMemoryStream.Create;
SourceStream.WriteBuffer(Buffer^, Count);
//将原始图像流保存至 DestStream流中
DestStream.Position := 0;//复位流指针
DestStream.WriteBuffer(Buffer^, Count);
myGif.LoadFromStream(DestStream);
image2.Picture.Assign(myGif);
end;
end;
end;
end.
就是为了把储存在数据库中图片显示出来,是压缩过的gif格式的图片
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, ExtCtrls, ExtDlgs;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Image1: TImage;
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
Image2: TImage;
OpenPictureDialog1: TOpenPictureDialog;
Button2: TButton;
Button3: TButton;
Label2: TLabel;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses GIFImage;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
SourceStream: TMemoryStream;
DestStream: TMemoryStream;
Buffer: PChar;
Count: Integer;
MyGif : TGIFImage;
imgSeal:TMemoryStream;
begin
myGif:=TGIFImage.Create;
myBmp:=TBitmap.Create;
imgSeal:=TMemoryStream.Create;
DestStream := TMemoryStream.Create;
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select SDImage from sealdata where code='+''''+trim(Edit2.Text)+'''');
Open;
if(RecordCount<=0) then
else
begin
TBlobField(ADOQuery1.FieldByName('SDImage')).SaveToStream(imgSeal);
imgSeal.ReadBuffer(Count, SizeOf(Count));
GetMem(Buffer, Count);
SourceStream:= TMemoryStream.Create;
SourceStream.WriteBuffer(Buffer^, Count);
//将原始图像流保存至 DestStream流中
DestStream.Position := 0;//复位流指针
DestStream.WriteBuffer(Buffer^, Count);
myGif.LoadFromStream(DestStream);
image2.Picture.Assign(myGif);
end;
end;
end;
end.
就是为了把储存在数据库中图片显示出来,是压缩过的gif格式的图片