+
Skip to content

Conversation

Nor-s
Copy link
Collaborator

@Nor-s Nor-s commented Oct 5, 2025

Changes

  1. Fixed a saver background reference leak 102efc5

  2. Added Static PNG Saver in savers/png

    • Copied the necessary PNG encoding functions from lodepng in loaders/png/tvgLodePng.cpp and loaders/png/tvgLodePng.h
      • Enabled CRC in tvgLodePng.cpp when THORVG_PNG_SAVER_SUPPORT is defined. (used only by the saver)
    • Added meson option for savers/png
      • Note: png_loader = png_loader or png_saver currently, the lodepng-based implementation resides under the loader module, which introduces an unintended dependency between the loader and saver.
  3. Added External(libpng-based) PNG Saver in savers/external_png

    • Since the static PNG version caused a dependency between the loader and saver(tvgLodePng), a new libpng-based PNG saver (external_png) was added to keep them separate.

issue: #3737

Output


image

@github-actions github-actions bot added infrastructure Dev infrastructure tools Tvg Viewer / Tools test Unit tests renderer Core rendering labels Oct 5, 2025
@Nor-s Nor-s self-assigned this Oct 5, 2025
@Nor-s Nor-s force-pushed the issue-3737-support-png-saver branch from 85cce51 to 6917a3d Compare October 7, 2025 11:47
@github-actions github-actions bot added image Bitmap image features (jpg/png/webp/gif) and removed tools Tvg Viewer / Tools labels Oct 7, 2025
@Nor-s Nor-s force-pushed the issue-3737-support-png-saver branch 3 times, most recently from 3ba970d to 174f70f Compare October 7, 2025 14:16
@Nor-s Nor-s marked this pull request as ready for review October 7, 2025 14:22
@Nor-s Nor-s requested a review from hermet as a code owner October 7, 2025 14:22
@hermet hermet requested a review from Copilot October 10, 2025 06:12
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds PNG saver functionality to ThorVG with two implementation options: a static PNG saver using lodepng code and an external PNG saver using libpng. The changes include necessary PNG encoding functions copied from the loader module, meson build configuration updates, and test coverage for the new PNG saving capabilities.

Key changes:

  • Added static PNG saver implementation in savers/png using lodepng functions
  • Added external PNG saver implementation in savers/external_png using libpng
  • Updated build system configuration to support PNG saver options
  • Fixed a background reference leak in the saver module

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/testSavers.cpp Added PNG saver test cases and updated GIF test file names
src/savers/png/tvgPngSaver.h Header file for static PNG saver implementation
src/savers/png/tvgPngSaver.cpp Implementation of static PNG saver using lodepng
src/savers/external_png/tvgPngSaver.h Header file for external PNG saver implementation
src/savers/external_png/tvgPngSaver.cpp Implementation of external PNG saver using libpng
src/renderer/tvgSaver.cpp Updated saver registry to support PNG format and fixed background reference leak
src/loaders/png/tvgLodePng.h Added PNG encoder structures and function declarations
src/loaders/png/tvgLodePng.cpp Added PNG encoding functionality when saver support is enabled
meson_options.txt Added PNG to saver options
meson.build Added PNG saver configuration and dependencies

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Nor-s added 4 commits October 12, 2025 14:48
- `Saver::background()` calls `ref()` on the incoming bg, so the old bg must
be released with `unref()` (not `TVG_DELETE`).
- support: static png saver (Copied only necessary encoding functions from the lodepng opensource. See: https://lodev.org/lodepng/)
- support: libpng based png saver
- additional changes: tvgLodePng.cpp: enable crc when defined THORVG_PNG_SAVER_SUPPORT

- issue: thorvg#3737
- lodepng_malloc -> tvg::malloc
- lodepng_realloc -> tvg::realloc
- lodepng_free -> tvg::free
@Nor-s Nor-s force-pushed the issue-3737-support-png-saver branch from 3848504 to e863091 Compare October 12, 2025 05:49
@hermet hermet requested a review from tinyjin October 13, 2025 03:35
@hermet hermet force-pushed the main branch 2 times, most recently from c0b5a3c to 0c67392 Compare October 13, 2025 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

image Bitmap image features (jpg/png/webp/gif) infrastructure Dev infrastructure renderer Core rendering test Unit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载