MAGIC_LEN = 8;
PNG_MAGIC: String[MAGIC_LEN] = #$89#$50#$4E#$47#$0D#$0A#$1A#$0A;
var
- png: TPortableNetworkGraphic;
+ reader: TLazReaderPNG;
intf: TLazIntfImage;
StreamPos: Int64;
magic: String[MAGIC_LEN];
exit;
end;
- png := TPortableNetworkGraphic.Create;
+ intf := TLazIntfImage.Create(0, 0);
+ reader := TLazReaderPNG.Create;
try try
- png.LoadFromStream(aStream);
- intf := png.CreateIntfImage;
- try try
- AssignFromLazIntfImage(intf);
- except
- result := false;
- aStream.Position := StreamPos;
- exit;
- end;
- finally
- intf.Free;
- end;
+ reader.UpdateDescription := true;
+ reader.ImageRead(aStream, intf);
+ AssignFromLazIntfImage(intf);
except
result := false;
aStream.Position := StreamPos;
exit;
end;
finally
- png.Free;
+ reader.Free;
+ intf.Free;
end;
end;