diff --git a/modules/imgcodecs/src/grfmt_png.cpp b/modules/imgcodecs/src/grfmt_png.cpp index 32620fdbc0ec..e8b5fcedd441 100644 --- a/modules/imgcodecs/src/grfmt_png.cpp +++ b/modules/imgcodecs/src/grfmt_png.cpp @@ -1444,7 +1444,7 @@ bool PngEncoder::writeanimation(const Animation& animation, const std::vector 0 && !getRect(width, height, frames.back().getPixels(), apngFrame.getPixels(), over1.data(), bpp, rowbytes, 0, 0, 0, 3)) { - frames[i - 1].setDelayNum(frames.back().getDelayNum() + apngFrame.getDelayNum()); + frames.back().setDelayNum(frames.back().getDelayNum() + apngFrame.getDelayNum()); num_frames--; } else