I have some code that loads a png image into a TBitmap and saves it again. However, the output is not the same. The quality of the image seems to deteriorate every time the previous image is loaded and then saved again.
I have attached the PNG image, which contains an alpha channel. The original image has a smooth gradient, but the last one clearly doesn't with clear banding. Does anyone know why this may be? I can perhaps understand why the 2nd image may be different since some aspects of the original PNG may not be supported, but I can't understand why subsequent images would vary to the 2nd image. This would indicate that Delphi FMX cannot correctly load an image that it saved. I'm running on Windows 32 bit and using Delphi 11.2 with default project settings. I'm comparing the images by viewing in Gimp and also by comparing in WinMerge. Even the file sizes vary.
procedure TForm1.Button1Click(Sender: TObject);
var
bmp : TBitmap;
i : Integer;
name : String;
begin
bmp := TBitmap.Create;
name := 'whiteglower_8bit';
for i := 1 to 4 do begin
bmp.LoadFromFile(name + IntToStr(i) + '.png');
bmp.SaveToFile(name + IntToStr(i+1) + '.png');
end;
bmp.Free;
end;