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;