Ken Lewis Posted February 28, 2022 Share Posted February 28, 2022 UniGUI 1555 var tmpStream : TMemoryStream; begin ...... TBlobField(FieldByName('li_image')).SaveToStream(tmpStream); tmpStream.Position :=0; UniCanvas1.Color := clWhite; UniCanvas1.Clear; uniCanvas1.LoadFromStream(tmpStream); //When I use this ,the picture is not shown; tmpStream.SaveToFile(UniServerModule.StartPath + 'images/1.png'); UniCanvas1.LoadFromFile(UniServerModule.StartPath + 'images/1.png'); //The picture is shown; end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 28, 2022 Share Posted February 28, 2022 Hello, What type of image are you storing in a blob? Quote Link to comment Share on other sites More sharing options...
Ken Lewis Posted February 28, 2022 Author Share Posted February 28, 2022 The file type maybe *.jpg, *.png, or other image types. In this example, I saved .png file in blob. Quote Link to comment Share on other sites More sharing options...
likemike Posted February 28, 2022 Share Posted February 28, 2022 I don't see any creation of tmpStream... Try this: var tmpStream : TMemoryStream; begin tmpStream:=TMemorystream.Create; TRY TBlobField(FieldByName('li_image')).SaveToStream(tmpStream); tmpStream.Position :=0; UniCanvas1.Color := clWhite; UniCanvas1.Clear; uniCanvas1.LoadFromStream(tmpStream); FINALLY FreeAndNil(tmpStream); END; end; Quote Link to comment Share on other sites More sharing options...
Ken Lewis Posted March 1, 2022 Author Share Posted March 1, 2022 I only pasted the main part of the code, the part of the code you mentioned is actually there. Design page: Run page: When I click btn1: And when I click btn2: Source Code: procedure TSysParamFrm.btn1Click(Sender: TObject); var tmpStream : TMemoryStream; begin tmpStream:=TMemorystream.Create; try with qryGetImage do begin Close; Open; if not IsEmpty then begin TBlobField(FieldByName('li_image')).SaveToStream(tmpStream); tmpStream.Position :=0; UniCanvas1.Color := clWhite; UniCanvas1.Clear; uniCanvas1.LoadFromStream(tmpStream); end; Close; end; finally FreeAndNil(tmpStream); end; end; procedure TSysParamFrm.btn2Click(Sender: TObject); var tmpStream : TMemoryStream; begin tmpStream:=TMemorystream.Create; try with qryGetImage do begin Close; Open; if not IsEmpty then begin TBlobField(FieldByName('li_image')).SaveToStream(tmpStream); tmpStream.Position :=0; UniCanvas1.Color := clWhite; UniCanvas1.Clear; tmpStream.SaveToFile(UniServerModule.StartPath + 'images/1.png'); UniCanvas1.LoadFromFile(UniServerModule.StartPath + 'images/1.png'); end; Close; end; finally FreeAndNil(tmpStream); end; end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 1, 2022 Share Posted March 1, 2022 Hello, Sorry, are you using trial version? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.