Access violation while saving .png
When I try to call the SaveToFile method on a TPNGImage object, I get an Acces violation error.
PNG construction:
pngTest:=TPngImage.CreateBlank(COLOR_GRAYSCALE, 16, 2048, 2048);
Method call: pngTest.SaveToFile('testtttt.png');
The PNG object is created correctly because I can assign it to a TImage and it works.
source to share
This is a defect in the Delphi PNG library code. Please report this to Embarcadero.
The defect appears to be caused by the use of 16-bit color depth. If you switch the code to use 8-bit color, then the code will execute successfully.
There is no easy workaround, so you will need to find another PNG library if you want to continue with 16-bit color. I expect the Microsoft Windows Imaging Component to work correctly. Or, you might consider Graphics32 with the GR32PNG extension.
source to share