Y
yirong
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure Tm_product.BitBtn3Click(Sender: TObject);<br>var<br>pict,pict1,PICT2:string;<br>pic3,pic1:tjpegimage;<br>strm,strm1:TMemoryStream;<br>begin<br> s_PROD_dict.Edit;<br> pict:=opendialog1.FileName;<br> if PICT <>'' then<br> BEGIN<br> PICT1:=ExtractFileName(opendialog1.FileName);<br> s_PROD_dict['picture']:=pict1;<br> strm:=tmemorystream.Create ;<br> PICT2:='//192.168.1.2/image1/'+pict1;<br> SaveDialog1.FileName:=PICT2;<br> Pic1:=TJpegImage.Create;<br> try<br> pic1.loadfromfile(pict); //取得OPENDIAG1所取得JPG文件<br> except<br> ShowMessage('Error On LoadFile strm');<br> end;<br> if Assigned(pic1) then<br> pic1.SaveToStream(strm);<br> strm.seek(0, 0);<br> if strm<>nil then<br> begin<br> try<br> strm.savetofile(SaveDialog1.FileName); //保存到指定位置 file://内存流保存,大小与file://pict1一样<br> except<br> showmessage('error on access memory!');<br> end;<br> end;<br> //test<br> //测试把保存的图片文件显示出来<br> strm1:=tmemorystream.Create ;<br> Pic3:=TJpegImage.Create;<br> image1.Picture.Graphic := nil;<br> pict1:=s_prod_dict.fieldbyname('picture').asstring;<br> if pict1<>'' then<br> begin<br> PICT2:='//192.168.1.2/image1/'+pict1; //服务器共享目录,必需允许用户可以读写<br> openDialog1.FileName:=PICT2;<br> strm1.loadfromfile(openDialog1.FileName);<br> if strm1<>nil then<br> begin<br> try<br> strm1.seek(0, 0);<br> pic3.LoadFromStream(strm1);<br> image1.Picture.Graphic:=pic3;<br> except<br> showmessage('error on access memory!');<br> end;<br> end;<br> end;<br> strm1.free;<br> pic3.Free ;<br> strm.Free ;<br> PIC1.Free;<br> end;<br>end;