delphi Image控件操作数据库Image
来源:互联网 发布:实现发牌java 编辑:程序博客网 时间:2024/06/06 16:50
引用这个单元jpeg
procedure TCommMethods.uploadimage(img:TImage);
var
OpenPictureDialog:TOpenPictureDialog;
bmp1:TBitmap;
jpg1:TJpegImage;
sFileName:string;
begin
OpenPictureDialog:= TOpenPictureDialog.Create(nil);
with OpenPictureDialog do
begin
if Execute then
begin
sFileName:=FileName;
if ExtractFileExt(sFileName)='.bmp' then
begin
bmp1:=TBitmap.Create;
bmp1.LoadFromFile(sFileName);
bmp1.Assign(bmp1);
end;
if (ExtractFileExt(sFileName) ='.jpg') or (ExtractFileExt(sFileName)='.jpeg') then
begin
bmp1:=TBitmap.Create;
jpg1:=TJpegImage.Create;
jpg1.LoadFromFile(sFileName);
bmp1.Assign(jpg1);
end;
img.Picture.Assign(bmp1);
end;
end;
end;
用于插入数据库
function TCommMethods.retrunchannelimageid(img:Timage):string;
var jpg1:TJpegImage;
begin
try
jpg1:=TJpegImage.Create;
jpg1.Assign(img.Picture.Bitmap);
with DM.qrypublic do
begin
Close;
SQL.Clear;
SQL.Add('INSERT INTO T_ImageOfChannel (channelimage) VALUES (:channelimage)');
Parameters[0].Assign(jpg1);
ExecSQL;
Close;
SQL.Clear;
SQL.Add('SELECT max(channelimageid) as channelimageid FROM T_ImageOfChannel');
Open;
Result:=fieldbyname('channelimageid').AsString;
end;
except
on Exception do
end;
end;
用于更新数据库
Function TCommMethods.updateChannelImage(img:Timage;channelID:string):boolean;
var jpg1:TJpegImage;
begin
try
jpg1:=TJpegImage.Create;
jpg1.Assign(img.Picture.Bitmap);
with DM.qrypublic do
begin
Close;
SQL.Clear;
SQL.Add(' update T_ImageOfChannel ');
SQL.Add(' set channelimage = :channelimage ');
SQL.Add(' where channelimageid ='#39+channelID+#39'');
Parameters[0].Assign(jpg1);
ExecSQL;
end;
result:=true;
except
on Exception do result:=false;
end;
end;
从数据库查询出来并在Image控件上面显示出来
procedure TCommMethods.showchannelico(channelno:string;img:TImage);
var ipg1:TJPEGImage;
bmp1:TBitmap;
begin
try
bmp1:=TBitmap.Create;
ipg1:=TJPEGImage.Create;
with DM.qrypublic do
begin
Close;
SQL.Clear;
SQL.Add('SELECT channelico FROM T_IcoOfChannel where Channelno='#39+channelno+#39'');
Open;
ipg1.Assign(FieldByName('channelico'));
bmp1.Assign(ipg1);
img.Picture.Assign(bmp1);
end;
except
img.Picture.Assign(nil);
end;
end;
- delphi Image控件操作数据库Image
- Image控件
- Image 控件
- delphi中如何用image控件显示网络图片
- delphi image控件上画矩形的问题
- 上传控件和image控件以及图片插入数据库
- Image
- Image
- Image
- Image
- image
- image
- image
- image
- Image$$
- Image
- image
- image
- 15.5.1 为什么要使用密钥
- 经典绝句
- Template模式
- servlet的应用及其他
- linux内核驱动DIY (踏踏实实学内核之2)
- delphi Image控件操作数据库Image
- 我不清楚的,亟待学习的
- XP下装windows 7和linux d的问题 原来什么都要自己去尝试!
- 15.5.2 生成密钥对
- 15.5.3 复制公有密钥至远程主机
- 导EXCEL表之网上资料
- Eclipse+Qt4配置步骤——最简单的方法(Windows版)
- 要再次显示该网页,Internet Explorer 需要重新发送你以前提交的信息
- Makefile_mini2440