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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Preserve PNG transparency when saving from TImageEnMView database?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

933 Posts

Posted - Dec 11 2023 :  06:37:07  Show Profile  Reply
In the demo \Demos\Database\DBMultiBitmap_AllRecords, I append images from PNG files with transparency:

fDBMultiBitmap.AppendImage('InTest.PNG');


I set the compression to UNCOMPRESSED:

procedure TForm1.DBMBitmapOnGetSaveParams(Sender: TObject; const Filename: string; Params: TIOParams);
begin
  Params.TIFF_Compression := ioTIFF_UNCOMPRESSED;
end;


Then I save the image that is currently selected in ImageEnMView1 with:

fDBMultiBitmap.GetImageToFile(idx, 'OutTest.PNG');


Unfortunately, the transparency in the saved PNG file is lost!

How can the PNG transparency be preserved in this process?

(also PNG_TextKeys should be preserved)

xequte

38610 Posts

Posted - Dec 11 2023 :  22:30:17  Show Profile  Reply
Hi

AppendImage() will save the image to the database in the format specified by:

http://www.imageen.com/help/TIEDBMultiBitmap.ImageFormat.html

Ensure it is PNG, or just append the image (directly from file) using normal database methods.

I will make it do this automatically for matching file formats for a coming update.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PeterPanino

933 Posts

Posted - Dec 12 2023 :  07:47:00  Show Profile  Reply
Hi Nigel,

Thanks. Now, it works, and the transparency of the saved PNG file is preserved.
Go to Top of Page

PeterPanino

933 Posts

Posted - Dec 12 2023 :  16:47:41  Show Profile  Reply
An interesting detail in this context is if TIEDBMultiBitmap.ImageFormat is defined as ioSVG: SVG files are loaded from a file with AppendImage and displayed correctly, but when saved back to an SVG file, they are not saved as the original SVG files (containing XML paths) but as SVG files containing an encoded raster graphics image!

Is it possible to save the SVG files in this case as the exact same copies with XML paths they were previously loaded? (As is the case with PNG files).
Go to Top of Page

xequte

38610 Posts

Posted - Dec 14 2023 :  14:03:34  Show Profile  Reply
Hi Peter

At this time, ImageEn only supports loading SVG files as raster images, so they will be saved as an encoded image SVG if loaded in this way.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

38610 Posts

Posted - Dec 14 2023 :  19:29:28  Show Profile  Reply
Please email me for the latest beta. When TIEDBMultiBitmap stores images in blobs it will now load the image content directly (if ImageFormat is not specified). This maintains the original format, e.g. for SVG files, or PNG with transparency.


Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: