Coder Social home page Coder Social logo

durobot / export_ppm Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 19 KB

A couple of functions to export data as a PPM/PGM image file from your Zig code

License: MIT License

Zig 100.00%
ppm-format ppm-image zig ziglang pgm pgm-format pgm-image pgm-writer ppm zig-package

export_ppm's Introduction

export_ppm

Just a couple of functions in Zig that export image data, RGB/RGBA/grayscale/grayscale+alpha (but alpha channel is ignored), 8 or 16 bits per channel, as PPM/PGM files. Not enough code to be called a library.

PPM and PGM are very simple graphic file formats, but they are widespread enough for popular editors, like Gimp, Krita or Adobe Photoshop to be able to open them. Meaning you can quickly dump whatever you want from your Zig programs as a PPM/PGM file and open it in an editor.

See https://en.wikipedia.org/wiki/Netpbm?useskin=vector, https://netpbm.sourceforge.net/doc/ppm.html.

Check out the tests in export_ppm.zig for examples of use.

test_data_src folder contains PNG images I used as test data, ignore them or use them however you want. I release them in public domain.

export_ppm.zig is licensed under the MIT License.

Just drop export_ppm.zig into your project and add const eppm = @import("export_ppm.zig");, or use the Zig package manager:

  1. In your project's build.zig.zon, in .dependencies, add

    .export_ppm =
    .{
        .url = "https://github.com/Durobot/export_ppm/archive/<GIT COMMIT HASH, 40 HEX DIGITS>.tar.gz",
        .hash = "<ZIG PACKAGE HASH, 68 HEX DIGITS>" // Use arbitrary hash, get correct hash from the error 
    }
  2. In your project's build.zig, in pub fn build, before b.installArtifact(exe);, add

    const eppm = b.dependency("export_ppm",
    .{
        .target = target,
        .optimize = optimize,
    });
    exe.root_module.addImport("export_ppm", eppm.module("export_ppm"));
  3. Add const eppm = @import("export_ppm");in your source file(s).

  4. Build your project with zig build, as you normally do.

export_ppm's People

Contributors

durobot avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.