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" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // Add 4 to ensure that it is still a multiple of 4. | 68 // Add 4 to ensure that it is still a multiple of 4. |
69 if (4 == bitCount && (w & 0x1)) { | 69 if (4 == bitCount && (w & 0x1)) { |
70 return (w + 1) << 2; | 70 return (w + 1) << 2; |
71 } | 71 } |
72 // Otherwise return 0, which will allow it to be calculated automatically. | 72 // Otherwise return 0, which will allow it to be calculated automatically. |
73 return 0; | 73 return 0; |
74 } | 74 } |
75 | 75 |
76 bool SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) | 76 bool SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) |
77 { | 77 { |
78 size_t length = stream->read(NULL, 0); | 78 size_t length = stream->getLength(); |
79 SkAutoMalloc autoMal(length); | 79 SkAutoMalloc autoMal(length); |
80 unsigned char* buf = (unsigned char*)autoMal.get(); | 80 unsigned char* buf = (unsigned char*)autoMal.get(); |
81 if (stream->read((void*)buf, length) != length) { | 81 if (stream->read((void*)buf, length) != length) { |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 //these should always be the same - should i use for error checking? - what
about files that have some | 85 //these should always be the same - should i use for error checking? - what
about files that have some |
86 //incorrect values, but still decode properly? | 86 //incorrect values, but still decode properly? |
87 int reserved = read2Bytes(buf, 0); // 0 | 87 int reserved = read2Bytes(buf, 0); // 0 |
88 int type = read2Bytes(buf, 2); // 1 | 88 int type = read2Bytes(buf, 2); // 1 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 int reserved = read2Bytes(buf, 0); | 384 int reserved = read2Bytes(buf, 0); |
385 int type = read2Bytes(buf, 2); | 385 int type = read2Bytes(buf, 2); |
386 if (reserved != 0 || type != 1) { | 386 if (reserved != 0 || type != 1) { |
387 // This stream does not represent an ICO image. | 387 // This stream does not represent an ICO image. |
388 return NULL; | 388 return NULL; |
389 } | 389 } |
390 return SkNEW(SkICOImageDecoder); | 390 return SkNEW(SkICOImageDecoder); |
391 } | 391 } |
392 | 392 |
393 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libico_dfactory); | 393 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libico_dfactory); |
OLD | NEW |