请问在Delphi中可以显示Gif图像吗?如何显示。谢谢!(20分)

  • 主题发起人 tianjh007
  • 开始时间
T

tianjh007

Unregistered / Unconfirmed
GUEST, unregistred user!
请问在Delphi中可以显示Gif图像吗?如何显示。谢谢!
 
装一个gifimage
 
不装也行,试试这个:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, ExtDlgs;

type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
OpenPictureDialog1: TOpenPictureDialog;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
targetframename, postdata, heads, flags: olevariant;
url: widestring;
begin
if OpenPictureDialog1.Execute then
begin
url := OpenPictureDialog1.FileName;
end;
targetframename := '';
postdata := false;
heads := '';
flags := 0;
try
with self.WebBrowser1 do
begin
navigate(url, flags, targetframename, postdata, heads);
end;
finally
end;



end;

end.
 
用浏览器控件就可以了,
 
以下是我收集的别人的,你参考一下!
问题的标题是: 如何將 jpg 圖形存放到 SQL 7.0 數據庫中? (100分 )

来自 :rixin 时间 :2001-2-8 9:37:00
如何將 jpg 圖形存放到 SQL 7.0 數據庫中?

来自 :xujiancai 时间 :2001-02-08 09:40:00
将任何图像插入到sql7中(用二进制方式写入):
if OpenPDia.Execute then
begin
Table.Edit;
(Table.FieldByName('Photo') as TBlobField).loadfromfile(openPdia.filename);
Table.FieldByName('PhotoPath').asstring := ExtractFileName(openPdia.filename);
end

来自 :xujiancai 时间 :2001-02-08 09:42:00
读出jpg,bmp到image中:
procedure TMainFrm.ReadPhotoActExecute(Sender: TObject);
var
JP: TJPEGImage;
bs: TBlobStream;
bmp: Tbitmap;
begin
if not (Table1.IsEmpty) then
begin
bs := TBlobStream.Create((Table1.FieldByName('photo') as TBlobField), bmRead);
try
jp := TJPEGImage.Create;
jp.LoadFromStream(bs);
Image1.Picture.Assign(jp);
bs.free;
jp.free;
except
bs.Free;
jp.Free;
bs := TBlobStream.Create((Table1.FieldByName('photo') as TBlobField), bmRead);
bmp := Tbitmap.Create;
bmp.loadFromStream(bs);
image1.Picture.Assign(bmp);
bs.free;
end;
end;
nd;


来自 :rixin 时间 :2001-02-08 09:43:00
OpenPDia 是啥?

来自 :terry_lzs 时间 :2001-02-08 10:25:00
openpia是想指opendialog控件
其实方法就用xujiancai的,挺好的。

来自 :Zoushikun 时间 :2001-02-13 08:40:00
另外,有点需要注意的地方是,如果保存的文件较大,需要设置在TDatabase中修改
BLOB SIZE 或 BLOBS TO CACHE的大小,否则嘿嘿......


来自 :小聆儿 时间 :2001-03-02 15:37:00
'PhotoPath'是sql7.0自带的字段吗?还是要在表中设这样一个字段?
在提交之后还会出现EWriteError :"Stream write error!"但是sql库里面相应字段有
几百k的空间被占,说明存进去了。怎么回事?xujiancai能帮帮我吗?

来自 :sportsman 时间 :2001-03-02 20:36:00
:)

来自 :雨人 时间 :2001-03-02 20:42:00
to xujiancai
方法挺好的.:)

来自 :xujiancai 时间 :2001-03-03 09:41:00
>>'PhotoPath'是sql7.0自带的字段吗?还是要在表中设这样一个字段?
方便修改而已,修改就拿回原来的修改,在load进去
To 小聆儿
需要设置在TDatabase中修改BLOB SIZE 或 BLOBS TO CACHE的大小

来自 :程云 时间 :2001-03-03 09:56:00
好象是不能直接存入JPG图像的,
要先转化成BMP的才能存入。

来自 :JiesieWonder 时间 :2001-03-03 18:49:00
其实最重要的是你无法知道库中存的是什么格式的图片!!!
有两种解决方案:
1:读出数据后,根据文件头的特殊信息判断(较烦)
2:在写入数据时,在流的前面写上图片的格式。读出时判断以下即可。

以下是我修改过的TPicture中的读写代码。

procedure TCPicture.SaveToStream(Stream: TStream);
var
CName: string[63];
begin
with Stream do
begin
if Graphic <> nil then
CName := Graphic.ClassName else
CName := '';
Write(CName, Length(CName) + 1);
if Graphic <> nil then
TCGraphic(Graphic).WriteData(Stream);
end;
end;

procedure TCPicture.LoadFromStream(Stream: TStream);
var
CName: string[63];
NewGraphic: TGraphic;
GraphicClass: TGraphicClass;
begin
Stream.Read(CName[0], 1);
Stream.Read(CName[1], Integer(CName[0]));
GraphicClass := FileFormats.FindClassName(CName);
if GraphicClass <> nil then
begin
NewGraphic := GraphicClass.Create;
try
TCGraphic(NewGraphic).ReadData(Stream);
Graphic := NewGraphic;
finally
NewGraphic.Free;
end;
end;
end;



来自 :bigroom 时间 :2001-04-23 13:19:00
可不可以不使用TTABLE,只使用QUERY实现读取数据库中的JPG图片信息?
很想看看您的例子代码

来自 :rixin 时间 :2001-07-19 22:36:00
多人接受答案了。

 
多谢了![:)]
 
顶部