summaryrefslogtreecommitdiffstats
path: root/src/common/test/image_test.cpp
blob: 0ad1ee2badda614dd68a0a4e4b3616c67faf6b4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "../image.h"

#include <SDL/SDL.h>
#include <stdio.h>

/* For now, just a simple test: loading a file from image
 * and saving it to another in PNG. */

int main(int argc, char *argv[])
{
    if (argc != 3)
    {
        printf("Usage: %s in_image out_image\n", argv[0]);
        return 0;
    }

    CImage image;

    if (! image.Load(argv[1]))
    {
        std::string err = image.GetError();
        printf("Error loading '%s': %s\n", err.c_str());
        return 1;
    }

    if (! image.SavePNG(argv[2]))
    {
        std::string err = image.GetError();
        printf("Error saving PNG '%s': %s\n", err.c_str());
        return 2;
    }

    return 0;
}