发布网友 发布时间:2022-05-05 06:19
共1个回答
热心网友 时间:2023-10-12 15:19
'); exit; end; except end;end; //读取procere 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转换为JPGprocere 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;下面用流的方式存储