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
 About TImageEnMView's LoadFromFileOnDemand

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
Flashcqxg Posted - Apr 21 2025 : 01:28:53
I want to download images from a server, load them into TImageEnMView, and then use CopyToIEBitmap to view and edit them in TImageEnView.
To speed up the process, I download the image stream from the server to the local machine and then load it into TImageEnMView using LoadFromFileOnDemand. My question is: When can I safely delete the locally downloaded image files without affecting the use of the CopyToIEBitmap method?

Here is my code:

while not rs.eof do  
begin  
  PhotoStream := TBytesStream.Create;  
  vImageName := rs.fieldbyname('imagename').ToString;  
  try  
    if RequestStream('get', 'test03', vImageName, vMsg, PhotoStream) then  
    begin  
      PhotoStream.Position := 0;  
      PhotoStream.SaveToFile(vImageName);  
      ImageEnMView.LoadFromFileOnDemand(vImageName, True);  
      TFile.Delete(vImageName); // When to delete it? 
    end;  
  finally  
    PhotoStream.Free;  
  end;  
  rs.next;  
end;
8   L A T E S T    R E P L I E S    (Newest First)
Flashcqxg Posted - Apr 23 2025 : 01:19:57
I see,thanks.
xequte Posted - Apr 23 2025 : 00:51:17
Hi

To force loading you can use:

http://www.imageen.com/help/TIECustomMView.EnsureImageLoaded.html


But the whole point of LoadFromFileOnDemand is only to load them as you scroll, otherwise you should just force loading with MIO.LoadFromFile() or AppendImage().



Nigel
Xequte Software
www.imageen.com
Flashcqxg Posted - Apr 22 2025 : 20:22:27
Alternatively, is it possible to achieve Load From Stream On Demand?
Flashcqxg Posted - Apr 21 2025 : 22:44:35
Is there any way to automatically load all the images into TImageEnMView without dragging the scroll bar?
xequte Posted - Apr 21 2025 : 22:39:56
Hi

In OnImageLoaded, you should only delete the image of the relevant idx parameter. Each image only exists in TImageEnMView once OnImageLoaded as occurred for THAT image.

// After image has loaded, delete the file
procedure TForm1.ImageEnMView1ImageLoaded(Sender: TObject; Idx: Integer);
var
  fn: string;
begin
  fn := ImageEnMView1.ImageFilename[ Idx ];
  DeleteFile( fn );
end;

(Assuming you are not adding frames of a multi-frame format to TImageEnMView, which is a different story).


Nigel
Xequte Software
www.imageen.com
Flashcqxg Posted - Apr 21 2025 : 02:54:49
That is to say, for the images that are not displayed in the ImageEnMView, I have to drag the vertical scroll bar before they can be deleted. Is there a way to delete them directly after loading?
Flashcqxg Posted - Apr 21 2025 : 02:52:49
Hi
Thank you.
I tested it, and the images that are displayed can be deleted after loading, but for the other images, you need to scroll to display them before they can be deleted.
xequte Posted - Apr 21 2025 : 02:41:34
Hi

If your StoreType is ietNormal then you can delete the file after it is loaded into TImageEnMView. The OnImageLoaded will fire after loading of each image:

https://www.imageen.com/help/TImageEnMView.OnImageLoaded.html

Nigel
Xequte Software
www.imageen.com