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 #include "SkImageDecoder_wbmp.h" |
10 #include "SkImageDecoder.h" | |
11 #include "SkColor.h" | 10 #include "SkColor.h" |
12 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
13 #include "SkMath.h" | 12 #include "SkMath.h" |
14 #include "SkStream.h" | 13 #include "SkStream.h" |
15 #include "SkTemplates.h" | 14 #include "SkTemplates.h" |
16 #include "SkUtils.h" | 15 #include "SkUtils.h" |
17 | 16 |
18 class SkWBMPImageDecoder : public SkImageDecoder { | 17 class SkWBMPImageDecoder : public SkImageDecoder { |
19 public: | 18 public: |
20 virtual Format getFormat() const SK_OVERRIDE { | 19 virtual Format getFormat() const SK_OVERRIDE { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 for (int y = 0; y < height; y++) | 140 for (int y = 0; y < height; y++) |
142 { | 141 { |
143 expand_bits_to_bytes(dst, src, width); | 142 expand_bits_to_bytes(dst, src, width); |
144 dst += decodedBitmap->rowBytes(); | 143 dst += decodedBitmap->rowBytes(); |
145 src += srcRB; | 144 src += srcRB; |
146 } | 145 } |
147 | 146 |
148 return kSuccess; | 147 return kSuccess; |
149 } | 148 } |
150 | 149 |
151 /////////////////////////////////////////////////////////////////////////////// | 150 SkImageDecoder* SkCreateWBMPImageDecoder(SkImageDecoder::Format format) { |
152 DEFINE_DECODER_CREATOR(WBMPImageDecoder); | 151 SkASSERT(SkImageDecoder::kWBMP_Format == format); |
153 /////////////////////////////////////////////////////////////////////////////// | 152 return SkNEW(SkWBMPImageDecoder); |
154 | |
155 static SkImageDecoder* sk_wbmp_dfactory(SkStreamRewindable* stream) { | |
156 wbmp_head head; | |
157 | |
158 if (head.init(stream)) { | |
159 return SkNEW(SkWBMPImageDecoder); | |
160 } | |
161 return NULL; | |
162 } | 153 } |
163 | 154 |
164 static SkImageDecoder::Format get_format_wbmp(SkStreamRewindable* stream) { | 155 SkImageDecoder::Format SkDetectFormatWBMPImageDecoder(SkStreamRewindable* stream
) { |
165 wbmp_head head; | 156 wbmp_head head; |
166 if (head.init(stream)) { | 157 if (head.init(stream)) { |
167 return SkImageDecoder::kWBMP_Format; | 158 return SkImageDecoder::kWBMP_Format; |
168 } | 159 } |
169 return SkImageDecoder::kUnknown_Format; | 160 return SkImageDecoder::kUnknown_Format; |
170 } | 161 } |
171 | |
172 static SkImageDecoder_DecodeReg gDReg(sk_wbmp_dfactory); | |
173 static SkImageDecoder_FormatReg gFormatReg(get_format_wbmp); | |
OLD | NEW |