ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TImageEnView: Load animated GIF from URL

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Nov 12 2024 : 08:24:30
Please allow loading and playing an animated GIF in TImageEnView from an Internet URL (without having to use a TImageEnMView), for example:

ImageEnView1.IO.LoadFromURL('https://media.tenor.com/Sq7rY9NKKd4AAAAC/oscars-standing-ovation.gif');

Currently, I have to make cumbersome diversions to load and play an animated GIF from an Internet URL in TImageEnView:

procedure TForm1.LoadAndPlayGIFFromURL(const URL: string);
var
  HTTPClient: System.Net.HttpClient.THTTPClient;
  MemoryStream: TMemoryStream;
  TempFileName: string;
begin
  // Create a temporary file name with a .gif extension
  TempFileName := TPath.GetTempFileName + '.gif';
  CodeSite.Send('TForm1.LoadAndPlayGIFFromURL: TempFileName', TempFileName);

  // Create the HTTP client and memory stream
  HTTPClient := THTTPClient.Create;
  MemoryStream := TMemoryStream.Create;
  try
    try
      // Download the GIF data from the URL into the memory stream
      HTTPClient.Get(URL, MemoryStream);
    except
      on E: Exception do
      begin
        ShowMessage('Error downloading GIF: ' + E.Message);
        Exit;
      end;
    end;

    // Save the GIF data to the temporary file
    try
      MemoryStream.Position := 0; // Reset the stream position
      MemoryStream.SaveToFile(TempFileName);
    except
      on E: Exception do
      begin
        ShowMessage('Error saving GIF to file: ' + E.Message);
        Exit;
      end;
    end;
    // Loading the GIF directly from the stream does work, but the GIF cannot be animated:
    //ImageEnView1.IO.LoadFromStreamGIF(MemoryStream);
  finally
    HTTPClient.Free;
    MemoryStream.Free;
  end;

  var TempFileExists := FileExists(TempFileName);
  CodeSite.Send('TForm1.LoadAndPlayGIFFromURL: TempFileExists', TempFileExists);

  // Load the GIF from the temporary file into ImageEnView1
  try
    ImageEnView1.IO.LoadFromFileGIF(TempFileName);
  except
    on E: Exception do
    begin
      ShowMessage('Error loading GIF into ImageEnView1: ' + E.Message);
      Exit;
    end;
  end;

  // Start the animation
  ImageEnView1.Playing := True;

  // Save the temporary file name to the global variable for later cleanup
  FTempGIFFileName := TempFileName;
end;


To make ImageEnView1.IO.LoadFromURL animation possible, TImageEnView should store the GIF frames in memory.

Then, it should be possible to save the GIF as an animated GIF file from the TImageEnView.
2   L A T E S T    R E P L I E S    (Newest First)
PeterPanino Posted - Nov 13 2024 : 16:54:40
Hi Nigel

Thanks, I'm looking forward to it.
xequte Posted - Nov 13 2024 : 13:36:25
Hi Peter

Thank you for the suggestion. We'll consider this for a future version.

Nigel
Xequte Software
www.imageen.com