Index: src/images/SkImageDecoder_libbmp.cpp |
diff --git a/src/images/SkImageDecoder_libbmp.cpp b/src/images/SkImageDecoder_libbmp.cpp |
index 488eddce1edb203065ce063db82e449c169db99f..5c2299b77cc138611fe058724ad55cf6957fe638 100644 |
--- a/src/images/SkImageDecoder_libbmp.cpp |
+++ b/src/images/SkImageDecoder_libbmp.cpp |
@@ -34,14 +34,18 @@ private: |
DEFINE_DECODER_CREATOR(BMPImageDecoder); |
/////////////////////////////////////////////////////////////////////////////// |
-static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) { |
+static bool is_bmp(SkStream* stream) { |
static const char kBmpMagic[] = { 'B', 'M' }; |
char buffer[sizeof(kBmpMagic)]; |
- if (stream->read(buffer, sizeof(kBmpMagic)) == sizeof(kBmpMagic) && |
- !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic))) { |
+ return stream->read(buffer, sizeof(kBmpMagic)) == sizeof(kBmpMagic) && |
+ !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic)); |
+} |
+ |
+static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) { |
+ if (is_bmp(stream)) { |
return SkNEW(SkBMPImageDecoder); |
} |
return NULL; |
@@ -49,6 +53,15 @@ static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) { |
static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libbmp_dfactory); |
+static SkImageDecoder::Format get_format_bmp(SkStream* stream) { |
+ if (is_bmp(stream)) { |
+ return SkImageDecoder::kBMP_Format; |
+ } |
+ return SkImageDecoder::kUnknown_Format; |
+} |
+ |
+static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_bmp); |
+ |
/////////////////////////////////////////////////////////////////////////////// |
class SkBmpDecoderCallback : public image_codec::BmpDecoderCallback { |