Skip to content

dlib.image

Timur Gafarov edited this page Aug 5, 2016 · 26 revisions

dlib.image

Image processing package. This part of dlib is under active development, but the main API is stable enough: we only add new functionality and make cosmetic changes.

dlib.image is mostly well-suited for computer scientist's everyday image manipulation tasks. 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 BMP TGA JPEG HDR
load yes yes yes yes yes
save yes yes yes no no

Modules

dlib.image.image

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