aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/test_image_decoder.cpp
blob: 106cf782f252a7549e8948b92823c48cef2f12ef (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
35
36
37
38
39
/*
 * Copyright 2013 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "SkBitmap.h"
#include "SkForceLinking.h"
#include "SkGraphics.h"
#include "SkImageDecoder.h"

__SK_FORCE_IMAGE_DECODER_LINKING;

/**
   Simple program to test Skia's ability to decode images without
   errors or debug messages. */
int tool_main(int argc, char** argv);
int tool_main(int argc, char** argv) {
    if (argc < 2) {
        SkDebugf("Usage:\n %s imagefile\n\n", argv[0]);
        return 3;
    }
    SkAutoGraphics ag;  // Enable use of SkRTConfig
    SkBitmap bitmap;
    if (!(SkImageDecoder::DecodeFile(argv[1], &bitmap))) {
        return 2;
    }
    if (bitmap.empty()) {
        return 1;
    }
    return 0;
}

#if !defined SK_BUILD_FOR_IOS
int main(int argc, char * const argv[]) {
    return tool_main(argc, (char**) argv);
}
#endif