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
 TImageEnIO.SaveToFileZIP?

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 - Feb 02 2025 : 04:36:40
The existing method TImageEnIO.LoadFromFileZIP loads an image from a ZIP file into the attached TImageEnView or TIEBitmap using a plug-in.

AFAIK, there is no REVERSE function TImageEnIO.SaveToFileZIP using the same plugin. I need this function to:
1. Load an image from ZIP in TImageEnView using TImageEnIO.LoadFromFileZIP
2. Edit the image in TImageEnView
3. Save the image back to the same ZIP file using TImageEnIO.SaveToFileZIP (including CompressionLevel parameter from 0=Store to 9=Maximum)

Could you implement this?

This would save me from having to save the image to a temporary file first and then add that temporary file to the ZIP using TZip methods.
4   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Feb 03 2025 : 16:29:24
Yes, it is on the to-do list.



Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Feb 03 2025 : 10:40:11
That's not relevant. However, for the sake of simplicity and completeness, a TImageEnIO.SaveToFileZIP method would be nice.
xequte Posted - Feb 02 2025 : 19:29:22
Thanks for posting that, Peter. How much larger was the EXE file size after adding the zip unit to your project?

Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Feb 02 2025 : 12:07:44
In the meantime, I've implemented a routine that uses TZipFile to save the image in the ZIP file:

procedure SaveImageInZip(AIO: TImageEnIO; const AImageName, AZipFile: string; AFileType: TIOFileType = hyieutils.ioUnknown);
var
  Zip: TZipFile;
  Stream: TMemoryStream;
  ZipPath: string;
  ExistingIndex: Integer;
begin
  Stream := TMemoryStream.Create;
  try
    // Save the image to the stream using the specified or determined file type
    AIO.SaveToStream(Stream, AFileType);
    Stream.Position := 0; // Reset stream position to beginning

    // Ensure the target directory exists
    ZipPath := ExtractFilePath(AZipFile);
    if ZipPath <> '' then
      ForceDirectories(ZipPath);

    // Add the stream to the zip file
    Zip := TZipFile.Create;
    try
      // Handle existing zip files
      if FileExists(AZipFile) then
      begin
        Zip.Open(AZipFile, TZipMode.zmReadWrite);

        // Delete existing entry if it exists
        ExistingIndex := Zip.IndexOf(AImageName);
        if ExistingIndex >= 0 then
          Zip.Delete(ExistingIndex);
      end
      else
        Zip.Open(AZipFile, TZipMode.zmWrite);

      // Add with STORE compression (no compression)
      Zip.Add(Stream, AImageName, TZipCompression.zcStored);
      Zip.Close;
    finally
      Zip.Free;
    end;
  finally
    Stream.Free;
  end;
end;