Description

Decoders for PNG, TGA, BMP, JPEG and encoders for PNG, TGA, BMP.

Package Information

Version6.1.0 (2016-Aug-29)
Repositoryhttps://github.com/lgvz/imageformats
LicenseBSL-1.0
AuthorsTero Hänninen
Registered byTero Hänninen
Dependenciesnone

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

imageformats Build Status

  • Returned image data is 8-bit except PNG can also return 16-bit.
  • Image data can be converted to Y, YA, RGB or RGBA.

| Format | Decoder | Encoder | | --- | --- | --- | | png | 8-bit, 16-bit | 8-bit non-paletted non-interlaced | | tga | 8-bit non-paletted | 8-bit non-paletted | | bmp | 8-bit | 8-bit uncompressed | | jpeg | baseline | nope |

import imageformats;

void main() {
    // optional last argument defines conversion
    IFImage im = read_image("peruna.png");
    IFImage im2 = read_image("peruna.png", ColFmt.YA);
    IFImage im3 = read_image("peruna.png", ColFmt.RGB);

    write_image("peruna.tga", im.w, im.h, im.pixels);
    write_image("peruna.tga", im.w, im.h, im.pixels, ColFmt.RGBA);

    // get basic info without decoding
    int w, h, chans;
    read_image_info("peruna.png", w, h, chans);

    // there are also format specific functions
    PNG_Header hdr = read_png_header("peruna.png"); // get detailed info
    IFImage im4 = read_jpeg("porkkana.jpg");
    write_tga("porkkana.tga", im4.w, im4.h, im4.pixels);
}

Available versions

6.1.0 6.0.1 6.0.0 5.2.0 5.1.0 5.0.0 4.2.2 4.2.1 4.2.0 4.1.1 4.1.0 4.0.1 4.0.0 3.1.0 3.0.6 3.0.5 3.0.4 3.0.3 2.0.1 2.0.0 1.0.0 ~master