Available

amalgame-image

Reads PNG/JPG/BMP/TGA/GIF/PSD/HDR, writes PNG/JPG/BMP/TGA, via stb_image.

amc package add image GitHub ↗ ← Back to the ecosystem

Overview

Wrapper around stb_image.h and stb_image_write.h (public domain), vendored in the package. Load and write images with no system dependency. 8-bit RGBA pixels, read and written one at a time (GetPixel, SetPixel).

Features

  • ✓Decode: PNG, JPG, BMP, TGA, GIF (first frame), PSD, HDR
  • ✓Encode: PNG, JPG, BMP, TGA
  • ✓Format conversion via double-pass load/save
  • ✓Vendored — no external dep

Planned: resize, crop, rotate.

Example

Minimal usage example.

amc package add image

import Amalgame.Image

public class Program {
    public static void Main(string[] args) {
        let img = Image.Load("input.png")
        if (!Image.IsValid(img)) {
            Console.WriteLine("load failed: " + Image.LastError(img))
            return
        }
        Console.WriteLine(String_FromInt(Image.Width(img)) + "x" + String_FromInt(Image.Height(img)))
        Image.SetPixel(img, 0, 0, 0xFF0000FF)
        Image.SaveAsJpg(img, "output.jpg", 85)
    }
}

At a glance

Related packages