{"id":14990725,"url":"https://github.com/zig-gamedev/zstbi","last_synced_at":"2025-04-12T02:43:38.577Z","repository":{"id":252153160,"uuid":"839580529","full_name":"zig-gamedev/zstbi","owner":"zig-gamedev","description":"Zig bindings and build package for stb_image, stb_image_resize and stb_image_write","archived":false,"fork":false,"pushed_at":"2025-03-25T21:19:30.000Z","size":132,"stargazers_count":10,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T22:22:07.687Z","etag":null,"topics":["bindings","gamedev","stb-image","zig"],"latest_commit_sha":null,"homepage":"","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/zig-gamedev.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":"2024-08-07T22:58:40.000Z","updated_at":"2025-03-25T21:19:33.000Z","dependencies_parsed_at":"2025-01-03T02:21:31.894Z","dependency_job_id":"160e8d0e-fa70-424f-bf19-cc11704f4a1b","html_url":"https://github.com/zig-gamedev/zstbi","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"3809262fe582e5128f8ec95eb94235783e185a26"},"previous_names":["zig-gamedev/zstbi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zig-gamedev%2Fzstbi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zig-gamedev%2Fzstbi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zig-gamedev%2Fzstbi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zig-gamedev%2Fzstbi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zig-gamedev","download_url":"https://codeload.github.com/zig-gamedev/zstbi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248507813,"owners_count":21115677,"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","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":["bindings","gamedev","stb-image","zig"],"created_at":"2024-09-24T14:20:39.827Z","updated_at":"2025-04-12T02:43:38.571Z","avatar_url":"https://github.com/zig-gamedev.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [zstbi](https://github.com/zig-gamedev/zstbi)\n\nZig bindings and build package for stb_image, stb_image_resize and stb_image_write from [Sean Barrett's stb single-file C libraries](https://github.com/nothings/stb)\n\n## Features\n\n* Supports Zig memory allocators\n* Supports decoding most popular formats\n* Supports HDR images\n* Supports 8-bits and 16-bits per channel\n* Supports image resizing\n* Supports image writing (.png, .jpg)\n\n## Getting started\n\nAdd `zstbi` to your `build.zig.zon` .dependencies with:\n\n```\nzig fetch --save git+https://github.com/zig-gamedev/zstbi\n```\n\nand in your `build.zig` add:\n\n```zig\npub fn build(b: *std.Build) void {\n    const exe = b.addExecutable(.{ ... });\n\n    const zstbi = b.dependency(\"zstbi\", .{});\n    exe.root_module.addImport(\"zstbi\", zstbi.module(\"root\"));\n}\n```\nNow in your code you may import and use `zstbi`.\n\nInit the lib. `zstbi.init()` is cheap and you may call it whenever you need to change memory allocator. Must be called from the main thread.\n```zig\nconst zstbi = @import(\"zstbi\");\n\nzstbi.init(allocator);\ndefer zstbi.deinit();\n```\n```zig\npub const Image = struct {\n    data: []u8,\n    width: u32,\n    height: u32,\n    num_components: u32,\n    bytes_per_component: u32,\n    bytes_per_row: u32,\n    is_hdr: bool,\n    ...\n```\n```zig\npub fn loadFromFile(pathname: [:0]const u8, forced_num_components: u32) !Image\n\npub fn loadFromMemory(data: []const u8, forced_num_components: u32) !Image\n\npub fn createEmpty(width: u32, height: u32, num_components: u32, args: struct {\n    bytes_per_component: u32 = 0,\n    bytes_per_row: u32 = 0,\n}) !Image\n\npub fn info(pathname: [:0]const u8) struct {\n    is_supported: bool,\n    width: u32,\n    height: u32,\n    num_components: u32,\n}\n\npub fn resize(image: *const Image, new_width: u32, new_height: u32) Image\n\npub fn writeToFile(\n    image: *const Image,\n    filename: [:0]const u8,\n    image_format: ImageWriteFormat,\n) ImageWriteError!void\n\npub fn writeToFn(\n    image: *const Image,\n    write_fn: *const fn (ctx: ?*anyopaque, data: ?*anyopaque, size: c_int) callconv(.C) void,\n    context: ?*anyopaque,\n    image_format: ImageWriteFormat,\n) ImageWriteError!void\n```\n```zig\nvar image = try zstbi.Image.loadFromFile(\"data/image.png\", forced_num_components);\ndefer image.deinit();\n\nconst new_resized_image = image.resize(1024, 1024);\n```\nMisc functions:\n```zig\npub fn isHdr(filename: [:0]const u8) bool\npub fn is16bit(filename: [:0]const u8) bool\n\npub fn setFlipVerticallyOnLoad(should_flip: bool) void\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzig-gamedev%2Fzstbi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzig-gamedev%2Fzstbi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzig-gamedev%2Fzstbi/lists"}