From 298daa4e8370c2b27df5ae0ea1eebb8d60211968 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 9 Oct 2025 10:56:33 +0530 Subject: [PATCH] Utility method to save frame as uncompressed PNG --- tools/utils/images/loading.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/utils/images/loading.go b/tools/utils/images/loading.go index ebd1de262..b6a05a729 100644 --- a/tools/utils/images/loading.go +++ b/tools/utils/images/loading.go @@ -10,6 +10,7 @@ import ( "image" "image/color" "image/gif" + "image/png" "io" "os" "os/exec" @@ -176,6 +177,11 @@ type SerializableImageMetadata struct { const SERIALIZE_VERSION = 1 +func (self *ImageFrame) SaveAsUncompressedPNG(output io.Writer) error { + encoder := png.Encoder{CompressionLevel: png.NoCompression} + return encoder.Encode(output, self.Img) +} + func (self *ImageData) SerializeOnlyMetadata() SerializableImageMetadata { f := make([]SerializableImageFrame, len(self.Frames)) for i, s := range self.Frames {