-
-
Notifications
You must be signed in to change notification settings - Fork 160
saver/png: support png saver #3874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
85cce51
to
6917a3d
Compare
3ba970d
to
174f70f
Compare
There was a problem hiding this 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.
3848504
to
e863091
Compare
d471af2
to
0aaa738
Compare
f8b6dff
to
7fa65c4
Compare
- 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
- The PNG saver used a color space incompatible with PNG encoding. - Adjusted to use the correct ColorSpace::ABGR8888 without pixel conversion.
7fa65c4
to
ceffcf5
Compare
submitted separately -> aca4a24 |
@Nor-s Hello, I just skimmed through your main commit to decide the approach first. Basic approach would be like this:
So that two modules have no dependency and for clean maintenance. The key decision point for the design here would be how much this increases the binary size. After making visible data, we can decide the approach with:
No remarkable binary size diff, I might prefer to separate implementation. Thanks for your contribution. |
Hello, thank you for the review. For now, I’ve made a temporary commit to separate the implementation into tvgPngEncoder and tvgPngDecoder. To estimate the size of the common code, I’ve temporarily added the encoder-related logic to tvgPngEncoder2.
I haven’t compared the binary size yet, but I’ll leave a comment later after checking it. Thank you. Common Functions
|
163382f
to
d810dca
Compare
Hello, I’ve checked the binary size differences. Would you consider this size difference negligible? Thanks for your feedback!
details...1. Loader + Saver
2. Only Saver
3. Only Loader
4. No Png
5. before d810dca
|
@Nor-s Thanks for the detailed information. I think we need to proceed with a unified version -> (common/tvgPngCodec.h and .cpp) I think you can first add a commit to refactor the PNG loader (png/tvgLodePng → common/tvgPngCodec). We can then build the saver feature on top of it. |
Changes
Fixed a saver background reference leak 102efc5
Added
Static
PNG Saver insavers/png
loaders/png/tvgLodePng.cpp
andloaders/png/tvgLodePng.h
tvgLodePng.cpp
whenTHORVG_PNG_SAVER_SUPPORT
is defined. (used only by the saver)savers/png
Added
External(libpng-based)
PNG Saver insavers/external_png
tvgLodePng
), a new libpng-based PNG saver (external_png
) was added to keep them separate.Output