dkeene Posted November 26, 2020 Share Posted November 26, 2020 Hello I set up for so user can upload a file and it works correctly. So if user uploads a jpg or bitmap, I use UniFileUploadCompleted: procedure TfmTableEdit.UniFileUpload1Completed(Sender: TObject; AStream: TFileStream); var aWinControl: TWinControl; blob: TStream; aField: TField; begin //save to disk CopyFile(PChar(AStream.FileName), PChar(DestName), False); //overwrites. //place file in database field TBlobField(Self.MyQuery1.FieldByName( 'MyImage' ).LoadFromFile(DestName); end; Then I need to copy this image to another control: ms:=TMemoryStream.Create; with MyQuery.FieldByName('mImage') as TBlobField do begin Savetostream(ms); ms.Position:=0; aUniImage.Picture.Graphic.LoadFromStream(ms); end; So if the original image is a Bitmap, it works perfectly. If the original image is a JPEG, it errors with: EInvalidGraphic "Bitmap image is not valid" Am I missing something? The controls usually figure out what type of format. Thanks Doug Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted November 26, 2020 Administrators Share Posted November 26, 2020 Hi, Try this: Image.LoadFromStream(Stream); Graphics can only load image type of its own Type, so below code only works for file types which are sames as TGraphic object class type: aUniImage.Picture.Graphic.LoadFromStream(ms); 1 Quote Link to comment Share on other sites More sharing options...
dkeene Posted November 26, 2020 Author Share Posted November 26, 2020 8 minutes ago, Farshad Mohajeri said: Graphics can only load image type of its own Type, so below code only works for file types which are sames as TGraphic object class type: Thank you Farshad, this worked perfectly !!!! 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.