OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
11 #include "SkColor.h" | 11 #include "SkColor.h" |
12 #include "SkColorPriv.h" | 12 #include "SkColorPriv.h" |
13 #include "SkMath.h" | 13 #include "SkMath.h" |
14 #include "SkStream.h" | 14 #include "SkStream.h" |
15 #include "SkTemplates.h" | 15 #include "SkTemplates.h" |
16 #include "SkUtils.h" | 16 #include "SkUtils.h" |
17 | 17 |
18 class SkWBMPImageDecoder : public SkImageDecoder { | 18 class SkWBMPImageDecoder : public SkImageDecoder { |
19 public: | 19 public: |
20 virtual Format getFormat() const SK_OVERRIDE { | 20 virtual Format getFormat() const SK_OVERRIDE { |
21 return kWBMP_Format; | 21 return kWBMP_Format; |
22 } | 22 } |
23 | 23 |
| 24 virtual Format onGetFormat(SkStream*) const SK_OVERRIDE; |
| 25 |
24 protected: | 26 protected: |
25 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE; | 27 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE; |
26 | 28 |
27 private: | 29 private: |
28 typedef SkImageDecoder INHERITED; | 30 typedef SkImageDecoder INHERITED; |
29 }; | 31 }; |
30 | 32 |
31 static bool read_byte(SkStream* stream, uint8_t* data) | 33 static bool read_byte(SkStream* stream, uint8_t* data) |
32 { | 34 { |
33 return stream->read(data, 1) == 1; | 35 return stream->read(data, 1) == 1; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 for (int y = 0; y < height; y++) | 150 for (int y = 0; y < height; y++) |
149 { | 151 { |
150 expand_bits_to_bytes(dst, src, width); | 152 expand_bits_to_bytes(dst, src, width); |
151 dst += decodedBitmap->rowBytes(); | 153 dst += decodedBitmap->rowBytes(); |
152 src += srcRB; | 154 src += srcRB; |
153 } | 155 } |
154 | 156 |
155 return true; | 157 return true; |
156 } | 158 } |
157 | 159 |
| 160 SkImageDecoder::Format SkWBMPImageDecoder::onGetFormat(SkStream* stream) const { |
| 161 wbmp_head head; |
| 162 if (head.init(stream)) { |
| 163 return kWBMP_Format; |
| 164 } |
| 165 return kUnknown_Format; |
| 166 } |
| 167 |
158 /////////////////////////////////////////////////////////////////////////////// | 168 /////////////////////////////////////////////////////////////////////////////// |
159 DEFINE_DECODER_CREATOR(WBMPImageDecoder); | 169 DEFINE_DECODER_CREATOR(WBMPImageDecoder); |
160 /////////////////////////////////////////////////////////////////////////////// | 170 /////////////////////////////////////////////////////////////////////////////// |
161 | 171 |
162 #include "SkTRegistry.h" | 172 #include "SkTRegistry.h" |
163 | 173 |
164 static SkImageDecoder* sk_wbmp_dfactory(SkStream* stream) { | 174 static SkImageDecoder* sk_wbmp_dfactory(SkStream* stream) { |
165 wbmp_head head; | 175 wbmp_head head; |
166 | 176 |
167 if (head.init(stream)) { | 177 if (head.init(stream)) { |
168 return SkNEW(SkWBMPImageDecoder); | 178 return SkNEW(SkWBMPImageDecoder); |
169 } | 179 } |
170 return NULL; | 180 return NULL; |
171 } | 181 } |
172 | 182 |
173 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_wbmp_dfactory); | 183 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_wbmp_dfactory); |
OLD | NEW |