OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 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 "bmpdecoderhelper.h" | 10 #include "bmpdecoderhelper.h" |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkImageDecoder.h" | 12 #include "SkImageDecoder.h" |
13 #include "SkScaledBitmapSampler.h" | 13 #include "SkScaledBitmapSampler.h" |
14 #include "SkStream.h" | 14 #include "SkStream.h" |
15 #include "SkStreamHelpers.h" | 15 #include "SkStreamPriv.h" |
16 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
17 | 17 |
18 class SkBMPImageDecoder : public SkImageDecoder { | 18 class SkBMPImageDecoder : public SkImageDecoder { |
19 public: | 19 public: |
20 SkBMPImageDecoder() {} | 20 SkBMPImageDecoder() {} |
21 | 21 |
22 virtual Format getFormat() const SK_OVERRIDE { | 22 virtual Format getFormat() const SK_OVERRIDE { |
23 return kBMP_Format; | 23 return kBMP_Format; |
24 } | 24 } |
25 | 25 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 bool fJustBounds; | 92 bool fJustBounds; |
93 }; | 93 }; |
94 | 94 |
95 bool SkBMPImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { | 95 bool SkBMPImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { |
96 // First read the entire stream, so that all of the data can be passed to | 96 // First read the entire stream, so that all of the data can be passed to |
97 // the BmpDecoderHelper. | 97 // the BmpDecoderHelper. |
98 | 98 |
99 // Allocated space used to hold the data. | 99 // Allocated space used to hold the data. |
100 SkAutoMalloc storage; | 100 SkAutoMalloc storage; |
101 // Byte length of all of the data. | 101 // Byte length of all of the data. |
102 const size_t length = CopyStreamToStorage(&storage, stream); | 102 const size_t length = SkCopyStreamToStorage(&storage, stream); |
103 if (0 == length) { | 103 if (0 == length) { |
104 return 0; | 104 return 0; |
105 } | 105 } |
106 | 106 |
107 const bool justBounds = SkImageDecoder::kDecodeBounds_Mode == mode; | 107 const bool justBounds = SkImageDecoder::kDecodeBounds_Mode == mode; |
108 SkBmpDecoderCallback callback(justBounds); | 108 SkBmpDecoderCallback callback(justBounds); |
109 | 109 |
110 // Now decode the BMP into callback's rgb() array [r,g,b, r,g,b, ...] | 110 // Now decode the BMP into callback's rgb() array [r,g,b, r,g,b, ...] |
111 { | 111 { |
112 image_codec::BmpDecoderHelper helper; | 112 image_codec::BmpDecoderHelper helper; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 const int dstHeight = sampler.scaledHeight(); | 153 const int dstHeight = sampler.scaledHeight(); |
154 const uint8_t* srcRow = callback.rgb(); | 154 const uint8_t* srcRow = callback.rgb(); |
155 | 155 |
156 srcRow += sampler.srcY0() * srcRowBytes; | 156 srcRow += sampler.srcY0() * srcRowBytes; |
157 for (int y = 0; y < dstHeight; y++) { | 157 for (int y = 0; y < dstHeight; y++) { |
158 sampler.next(srcRow); | 158 sampler.next(srcRow); |
159 srcRow += sampler.srcDY() * srcRowBytes; | 159 srcRow += sampler.srcDY() * srcRowBytes; |
160 } | 160 } |
161 return true; | 161 return true; |
162 } | 162 } |
OLD | NEW |