Jump to content

Graphic File Type Problem


dkeene

Recommended Posts

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

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...