请问,存取在C/S数据库中的Jpeg图片,谢谢各位了.(100分)

  • 主题发起人 主题发起人 wang5793
  • 开始时间 开始时间
W

wang5793

Unregistered / Unconfirmed
GUEST, unregistred user!
我在做一个C/S数据库,涉及到将Jpeg图片存入和从库中读出,先做了一个子程序全部能正常存取.重新做一个子程序时却报错"Jpeg error #53".但在先的子程序又是完全正常的.谢谢各位的指教了.代码如下:<br>var <br>&nbsp; mStream:TMemoryStream; <br>&nbsp; JpgFile:TjpegImage;<br>begin<br>&nbsp; &nbsp; With ADOQuery1 Do<br>&nbsp; &nbsp; Begin<br>&nbsp; &nbsp; &nbsp; Close;<br>&nbsp; &nbsp; &nbsp; SQL.Clear;<br>&nbsp; &nbsp; &nbsp; SQL.Text:='select * from tempdb';<br>&nbsp; &nbsp; &nbsp; Open;<br>&nbsp; &nbsp; End;<br>&nbsp; if not ADOQuery1.FieldByName('photo').IsNull then<br>&nbsp; begin &nbsp; &nbsp; <br>&nbsp; &nbsp; mStream:=TMemoryStream.Create ;<br>&nbsp; &nbsp; JpgFile:=TjpegImage.Create ;<br>&nbsp; &nbsp; TBlobField(ADOQuery1.FieldByName('photo')).SaveToStream(mStream);<br>&nbsp; &nbsp; mStream.Position :=0;<br>&nbsp; &nbsp; jpgfile.LoadFromStream(MStream);<br>&nbsp; &nbsp; fcImager1.Picture.Assign(JpgFile);<br>&nbsp; &nbsp; MStream.Free;<br>&nbsp; &nbsp; jpgfile.Free;<br>&nbsp;end<br>&nbsp;else<br>&nbsp;begin<br>&nbsp; &nbsp;image1.Picture :=nil;<br>&nbsp;End; &nbsp;<br>end;
 
并且已加入了 uses jpeg
 
procedure TForm1.Button3Click(Sender: TObject);<br>var<br>&nbsp; &nbsp;JPEGImage: TJPEGImage;<br>begin<br>&nbsp; //直接保存会出现错误:<br>&nbsp; //'project raised exception class EJPEG with<br>&nbsp; // message 'JPEG error #53'. Process stopped.'<br>&nbsp; //分析应为保存的jpg文件格式有问题,无法预览<br>&nbsp; //官方说法是: 53 &nbsp;cstrJERR_OUT_OF_MEMORY<br>&nbsp; // 'Insufficient memory (case %d)'<br>&nbsp; if SavePictureDialog1.InitialDir='' then<br>&nbsp; &nbsp; SavePictureDialog1.InitialDir:=ExtractFilePath(OpenPictureDialog1.FileName);<br>&nbsp; if trim(LabeledEdit1.Text)&lt;&gt;'' then<br>&nbsp; &nbsp; SavePictureDialog1.FileName:=trim(LabeledEdit1.Text)+'.jpg';<br>&nbsp; if SavePictureDialog1.execute then<br>&nbsp; begin<br>&nbsp; &nbsp; JPEGImage:=TJPEGImage.Create;<br>&nbsp; &nbsp; JPEGImage.Assign(image2.Picture.Graphic);<br>&nbsp; &nbsp; JPEGImage.SaveToFile(ExtractFilePath(SavePictureDialog1.Filename)+trim(LabeledEdit1.Text)+'.jpg');<br>&nbsp; end;<br>end;
 
用间接的办法可以避免!
 
我已解决了,是我的程序问题.<br>谢谢lps对我的问题的关心,已给你加分了.
 
后退
顶部