Updates to skimage tool to use it for testing.

skimage_main.cpp:
More changes in the interest of testing our decoders.

force_all_opaque before writing PNG files.

Test reencoding the image to its original type (if possible), and
then test redecoding it (to make sure the encoding was successful).
Add an option to turn off this behavior.

Merge decodeFileAndWrite with decodeFile.

SkImageDecoder:
Add kUnknown_Type to SkImageEncoder::Types.

Add a static function to get the Format of an SkStream.

In getFormatName(), remove an incorrect assert.

When calling the flavor of DecodeStream that returns the Format,
check the stream if the decoder returns kUnknown_Format.

BUG=https://code.google.com/p/skia/issues/detail?id=1241

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

git-svn-id: http://skia.googlecode.com/svn/trunk@8862 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/images/SkImageDecoder_libico.cpp b/src/images/SkImageDecoder_libico.cpp
index ffc59e0..195b6ff 100644
--- a/src/images/SkImageDecoder_libico.cpp
+++ b/src/images/SkImageDecoder_libico.cpp
@@ -373,9 +373,7 @@
 DEFINE_DECODER_CREATOR(ICOImageDecoder);
 /////////////////////////////////////////////////////////////////////////////////////////
 
-#include "SkTRegistry.h"
-
-static SkImageDecoder* sk_libico_dfactory(SkStream* stream) {
+static bool is_ico(SkStream* stream) {
     // Check to see if the first four bytes are 0,0,1,0
     // FIXME: Is that required and sufficient?
     SkAutoMalloc autoMal(4);
@@ -385,9 +383,27 @@
     int type = read2Bytes(buf, 2);
     if (reserved != 0 || type != 1) {
         // This stream does not represent an ICO image.
-        return NULL;
+        return false;
     }
-    return SkNEW(SkICOImageDecoder);
+    return true;
+}
+
+#include "SkTRegistry.h"
+
+static SkImageDecoder* sk_libico_dfactory(SkStream* stream) {
+    if (is_ico(stream)) {
+        return SkNEW(SkICOImageDecoder);
+    }
+    return NULL;
 }
 
 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libico_dfactory);
+
+static SkImageDecoder::Format get_format_ico(SkStream* stream) {
+    if (is_ico(stream)) {
+        return SkImageDecoder::kICO_Format;
+    }
+    return SkImageDecoder::kUnknown_Format;
+}
+
+static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_ico);