在Delphi中怎样把JPG图片保存到SQL的库表中?
1个回答
展开全部
'); 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格式的文件到更新包里。
procedure TForm7.Button1Click(Sender: TObject); //保存.bmp格式的文件到更新包里。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询