从内存流中读取图片给数据库的i字段.txt
来自「dephi视频控制(Demo+源码) SendMessage做视频捕获,不要驱动」· 文本 代码 · 共 32 行
TXT
32 行
从内存流中读取图片给数据库的i字段
procedure TForm1.Button5Click(Sender: TObject);
//保存图像
var
strm: TMemoryStream;
ext: String;
begin
if image1.picture.Graphic <> nil then //避免image1中无图像保存出错
begin
ext:=extractfileext(openpicturedialog1.FileName ); //取出文件的扩展名
strm := tmemorystream.Create ;
try
image1.Picture.Graphic.SaveToStream(strm);
adotable1.Edit ;
strm.Position :=0;
tblobfield(adotable1.FieldByName('i')).LoadFromStream(strm);//提示bitmap is not valid// 请问该怎么改写 谢谢
//以下记录保存到数据库的图像格式
if (uppercase(ext) = '.BMP') then
adotable1.FieldByName('isbmp').Value := 1 //BMP型图像数据
else
if (uppercase(ext) = '.JPG') OR ( uppercase(ext) = '.JPEG') Then
adotable1.FieldByName('isbmp').Value := 0; //JPEG型图像数据
adotable1.Post ;
finally
strm.Free ;
Application.MessageBox('保存成功');
end;
end;
end;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?