在Delphi中怎样把JPG图片保存到SQL的库表中?

 我来答
猴儆朗3
2013-11-16 · TA获得超过113个赞
知道答主
回答量:106
采纳率:0%
帮助的人:145万
展开全部
'); exit; end; except end;end; //读取procedure TForm1.ImageFromDBBitBtnClick(Sender: TObject);var m_jpegstream:tmemorystream;begin with Query1 do begin close; sql.clear; sql.Add('select imga from img'); try Open; except exit; end; end; if (Query1.FieldByName('imga') as tblobfield).asstring='' then begin exit; end else begin try try m_jpegStream:=TMemoryStream.Create; (Query1.fieldbyname('imga') as TBlobField).SaveToStream(m_JpegStream); m_JpegStream.Position:=0; try image2.Picture.Graphic:=nil; image2.Picture.Graphic:=TJpegImage.Create; image2.Picture.Graphic.LoadFromStream(m_JpegStream); //读Jpeg except Image2.Picture.Bitmap.LoadFromStream(m_JpegStream); //读Bmp end; except end; finally m_JpegStream.Free; Query1.Close; Query1.UnPrepare; end; end;end; //BMP转换为JPGprocedure TStuXXSLForm.LoadImageBitBtnClick(Sender: TObject);var MyJpeg:TJpegImage;begin inherited; if OpenPictureDialog1.Execute then begin FileName:=OpenPictureDialog1.FileName; Image1.Picture.LoadFromFile(FileName); if ExtractFileExt(FileName)='.Bmp' then begin MyJpeg:= TJpegImage.Create; MyJpeg.Assign(Image1.Picture.Bitmap); FileName:='Photo.Jpg'; MyJpeg.SaveToFile(FileName); MyJpeg.Free; end; end;end;下面用流的方式存储
procedure TForm7.Button1Click(Sender: TObject); //保存.bmp格式的文件到更新包里。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式