Skip to content

dlib.image

Timur Gafarov edited this page Mar 16, 2020 · 26 revisions

dlib.image

Image processing package. It may be used as a plotting/rendering backend, or an easy to use texture loader for games and demos. It is not (and probably not going to be) a full-blown graphics engine to compete with GEGL or Cairo. But if all you want is to write some pixels to PNG, dlib.image is the fastest way to get the job done without hassle.

dlib.image supports several popular image formats:

PNG APNG BMP TGA JPEG HDR
load yes yes yes yes yes yes
save yes yes yes yes no yes

Modules

Subpackages

Usage example

Fill image with a color in HSV colorspace:

import dlib.image;

SuperImage fillHSV(
    SuperImage img,
    float h,
    float s,
    float v,
    float a = 1.0f)
{
    foreach(x; img.row)
    foreach(y; img.col)
    {
        img[x, y] = hsv(h, s, v, a);
    }
    return img;
}

void main()
{
    image(100, 100).fillHSV(180.0f, 1.0f, 0.4f).savePNG("test.png");
}
Clone this wiki locally