{"id":34896684,"url":"https://github.com/uctakeoff/uc_apng_loader","last_synced_at":"2025-12-26T07:07:00.883Z","repository":{"id":80252747,"uuid":"87634498","full_name":"uctakeoff/uc_apng_loader","owner":"uctakeoff","description":"uc::apng::loader is a header only C++11  apng (Animated PNG) decoder.","archived":false,"fork":false,"pushed_at":"2024-07-24T22:18:23.000Z","size":270,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-07-25T00:28:24.688Z","etag":null,"topics":["apng","cpp","cpp11","cross-platform","header-only"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uctakeoff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-08T13:06:37.000Z","updated_at":"2024-07-24T22:18:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"c887c843-48cc-41d3-98e2-aa477f15097b","html_url":"https://github.com/uctakeoff/uc_apng_loader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/uctakeoff/uc_apng_loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uctakeoff%2Fuc_apng_loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uctakeoff%2Fuc_apng_loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uctakeoff%2Fuc_apng_loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uctakeoff%2Fuc_apng_loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uctakeoff","download_url":"https://codeload.github.com/uctakeoff/uc_apng_loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uctakeoff%2Fuc_apng_loader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28048045,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-26T02:00:06.189Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apng","cpp","cpp11","cross-platform","header-only"],"created_at":"2025-12-26T07:06:01.959Z","updated_at":"2025-12-26T07:07:00.873Z","avatar_url":"https://github.com/uctakeoff.png","language":"C++","readme":"# uc::apng::loader\n**uc::apng::loader** is a header only C++11  APNG (Animated PNG) decoder.\n\n## Requirements\n\n* C++11 support compiler\n* [stb_image.h](https://github.com/nothings/stb)\n\n## Example\n\n### source code\n\n```cpp\n// apng2pngs.cpp\n\n#define STB_IMAGE_IMPLEMENTATION\n#include \"uc_apng_loader.h\"\n#define STB_IMAGE_WRITE_IMPLEMENTATION\n#include \"stb_image_write.h\"\n#include \u003ciostream\u003e\n#include \u003ciomanip\u003e\n#include \u003csstream\u003e\n#include \u003cstring\u003e\n\nint main(int argc, char** argv)\n{\n    if (argc \u003c 2) {\n        std::cerr \u003c\u003c \"Usage : \" \u003c\u003c argv[0] \u003c\u003c \" [APNG filename]\" \u003c\u003c std::endl;\n        return 1;\n    }\n    try {\n        auto loader = uc::apng::create_file_loader(argv[1]);\n\n        while (loader.has_frame()) {\n\n            auto frame = loader.next_frame();\n\n            std::ostringstream filename;\n            filename \u003c\u003c \"out\" \u003c\u003c std::setw(3) \u003c\u003c std::setfill('0') \u003c\u003c frame.index \u003c\u003c \".png\";\n\n            stbi_write_png(filename.str().c_str(), frame.image.width(), frame.image.height(), \n\t        4, frame.image.data(), frame.image.width() * 4);\n        }\n    } catch (std::exception\u0026 ex) {\n        std::cout \u003c\u003c \"failed : \" \u003c\u003c ex.what() \u003c\u003c std::endl;\n    } \n    return 0;\n}\n```\n### compile\n\n```bash\n$ g++ -std=c++11 apng2pngs.cpp\n```\n\n## Usage\n\n### Load APNG data\n\n```cpp\n// from file\nauto loader = uc::apng::create_file_loader(\"filename.apng\");\n\n// from memory (std::string stringdata)\nauto loader = uc::apng::create_memory_loader(stringData);\n\n// from memory (const char* buf, size_t buflen)\nauto loader = uc::apng::create_memory_loader(buf, buflen);\n\n// member\nstd::cout \u003c\u003c \"(\" \u003c\u003c loader.width() \u003c\u003c \"x\" \u003c\u003c loader.height() \u003c\u003c \"), \" \n\t\u003c\u003c loader.num_frames() \u003c\u003c \"frames, \" \n\t\u003c\u003c loader.num_plays() \u003c\u003c \" times to loop (0 indicates infinite looping).\\n\";\n```\n\n### Get APNG frames\n\n```cpp\nstd::vector\u003cuc::apng::frame\u003e frames;\nwhile (loader.has_frame()) {\n\tframes.push_back(loader.next_frame());\n}\n```\n\n### Write to PNG file (using `stb_image_write.h`)\n\n```cpp\nfor (auto\u0026\u0026 frame : frames) {\n\n\tauto filename = \"out\" + std::to_string(frame.index) + \".png\";\n\n\tstbi_write_png(filename.c_str(), frame.image.width(), frame.image.height(), 4,\n\t\t frame.image.data(), frame.image.width() * 4);\n}\n```\n\n### Load to OpenGL Texture\n\n```cpp\n\tglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, frame.image.width(), frame.image.height(), \n\t\t0, GL_RGBA, GL_UNSIGNED_BYTE, frame.image.data());\n```\n\n\n## Sample Code\n\n### APNG to PNGs Example\n\n```bash\n$ g++ -std=c++11 apng2pngs.cpp\n$ ./a.out test_data/beach_ball.apng\n```\n\n### Emscripten WebGL Rendering \n\n```bash\n$ emcc -std=c++11 -s USE_GLFW=3 emglsample.cpp -o glsample.html --preload-file test_data/beach_ball.apng\n```\n\n## Test\n\n### Build \u0026 Execute\n\n```bash\n$ g++ -std=c++11 test.cpp\n$ ./a.out\n```\n\n## License\n\nMIT License\n\n## References\n\n* [APNG Specification](https://wiki.mozilla.org/APNG_Specification#.60fcTL.60:_The_Frame_Control_Chunk)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuctakeoff%2Fuc_apng_loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuctakeoff%2Fuc_apng_loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuctakeoff%2Fuc_apng_loader/lists"}