From afbede3eaece5349a45648f52d1ff619aa6ff435 Mon Sep 17 00:00:00 2001 From: Gaspar Capello Date: Mon, 8 May 2023 13:40:31 -0300 Subject: [PATCH] Fix webp export to export one tag correctly instead of all frames (fix #3622) --- src/app/file/webp_format.cpp | 16 ++++++++++++---- tests/cli/save-as.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/app/file/webp_format.cpp b/src/app/file/webp_format.cpp index ccbbe751b..744825540 100644 --- a/src/app/file/webp_format.cpp +++ b/src/app/file/webp_format.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2022 Igara Studio S.A. +// Copyright (C) 2018-2023 Igara Studio S.A. // Copyright (C) 2015-2018 David Capello // Copyright (C) 2015 Gabriel Rauter // @@ -257,7 +257,6 @@ bool WebPFormat::onSave(FileOp* fop) FILE* fp = handle.get(); const FileAbstractImage* sprite = fop->abstractImage(); - const doc::frame_t totalFrames = sprite->frames(); const int w = sprite->width(); const int h = sprite->height(); @@ -302,6 +301,7 @@ bool WebPFormat::onSave(FileOp* fop) ImageRef image(Image::create(IMAGE_RGB, w, h)); + const doc::frame_t totalFrames = fop->roi().frames(); WriterData wd(fp, fop, 0, totalFrames, 0.0); WebPPicture pic; WebPPictureInit(&pic); @@ -315,10 +315,18 @@ bool WebPFormat::onSave(FileOp* fop) WebPAnimEncoder* enc = WebPAnimEncoderNew(w, h, &enc_options); int timestamp_ms = 0; + auto frame_beg = fop->roi().selectedFrames().begin(); +#if _DEBUG + auto frame_end = fop->roi().selectedFrames().end(); +#endif + auto frame_it = frame_beg; for (frame_t f=0; fmaskColor()); - sprite->renderFrame(f, image.get()); + sprite->renderFrame(frame, image.get()); // Switch R <-> B channels because WebPAnimEncoderAssemble() // expects MODE_BGRA pictures. @@ -342,7 +350,7 @@ bool WebPFormat::onSave(FileOp* fop) else return true; } - timestamp_ms += sprite->frameDuration(f); + timestamp_ms += sprite->frameDuration(frame); wd.f = f; } diff --git a/tests/cli/save-as.sh b/tests/cli/save-as.sh index eb5d69b24..80dced488 100644 --- a/tests/cli/save-as.sh +++ b/tests/cli/save-as.sh @@ -322,3 +322,38 @@ d=$t/save-as-with-slice $ASEPRITE -b sprites/slices.aseprite -save-as $d/{slice}.png expect "line.png square.png" "list_files $d" + +# Test https://github.com/aseprite/aseprite/issues/3622 +# Test that -save-as -tag will save the right tag frames in webp file format + +d=$t/save-as-tag-webp +mkdir $d # TODO why do we need this? +$ASEPRITE -b -frame-tag "a" sprites/1empty3.aseprite -save-as $d/save-as-tag.webp || exit 1 +expect "save-as-tag.webp" "list_files $d" +cat >$d/compare.lua <