skia2/tools/test_image_decoder.cpp
halcanary@google.com 04b57f87ab Runtime configuration setting for suppressing JPEG decoder errors.
Add new runtime config variable, images.jpeg.suppressDecoderErrors
which defaults to false in Debug and true otherwise.  When Jpeg errors
are suppressed and an error happens, SkJPEGImageDecoder::onDecode()
will return silently false (Consequently, so will SkImageDecoder's
DecodeFile() and DecodeMemory() functions).

Also, the test_image_decoder program now respects runtime
configuration settings.

BUG=skia:1680
R=scroggo@google.com

Review URL: https://codereview.chromium.org/27230002

git-svn-id: http://skia.googlecode.com/svn/trunk@11763 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-10-14 20:08:48 +00:00

40 lines
909 B
C++

/*
* 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