var Picture:TPicture; BMP:TBitmap; jpg:TJPEGImage; Stream:TMemoryStream; begin if openpicturedialog1.Execute then begin Picture:=TPicture.Create; Picture.LoadFromFile(OpenPictureDialog1.FileName); image1.Picture.Assign(Picture); begin if Picture.Graphic is TBitmap then dbimage1.Picture:=image1.Picture else if Picture.Graphic is TJPEGImage then begin Stream:=TMemoryStream.create; Jpg:=TJpegImage.create; Bmp:=TBitmap.create; try Stream.loadfromFile(OpenPictureDialog1.FileName); Stream.seek(0,0); Jpg.loadFromStream(Stream); Bmp.Assign(Jpg); Image1.Picture.Bitmap.Assign(Bmp); dbimage1.Picture:=image1.Picture; finally Stream.free; Bmp.free; Jpg.free; end; end; end; Picture.Free; end; end;
用ADOBlobStream对象读写,看看Delphi Help就很容易了,和TFileStream差不多,我就不废话了
不过前两个问题还没有,lesstif,dainellee二位能否把代码写的详细一点
感谢不尽~
问题解决后立马结帖!
Picture:TPicture;
BMP:TBitmap;
jpg:TJPEGImage;
Stream:TMemoryStream;
begin
if openpicturedialog1.Execute then
begin
Picture:=TPicture.Create;
Picture.LoadFromFile(OpenPictureDialog1.FileName);
image1.Picture.Assign(Picture);
begin
if Picture.Graphic is TBitmap then
dbimage1.Picture:=image1.Picture
else if Picture.Graphic is TJPEGImage then
begin
Stream:=TMemoryStream.create;
Jpg:=TJpegImage.create;
Bmp:=TBitmap.create;
try
Stream.loadfromFile(OpenPictureDialog1.FileName);
Stream.seek(0,0);
Jpg.loadFromStream(Stream);
Bmp.Assign(Jpg);
Image1.Picture.Bitmap.Assign(Bmp);
dbimage1.Picture:=image1.Picture;
finally
Stream.free;
Bmp.free;
Jpg.free;
end;
end;
end;
Picture.Free;
end;
end;