Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: src/codec/SkCodec_wbmp.cpp

Issue 1473673005: Support wbmp that are supported by SkImageDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/CodexTest.cpp » ('j') | tests/CodexTest.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodec_wbmp.cpp
diff --git a/src/codec/SkCodec_wbmp.cpp b/src/codec/SkCodec_wbmp.cpp
index 900ab6f7017c8781ca82bd2a7707569fd807ce59..8f8763fb90e0f0256506c12e82c54c04ab570ce2 100644
--- a/src/codec/SkCodec_wbmp.cpp
+++ b/src/codec/SkCodec_wbmp.cpp
@@ -29,6 +29,11 @@ static inline void setup_color_table(SkColorType colorType,
}
}
+static bool read_byte(SkStream* stream, uint8_t* data)
+{
+ return stream->read(data, 1) == 1;
+}
+
// http://en.wikipedia.org/wiki/Variable-length_quantity
static bool read_mbf(SkStream* stream, uint64_t* value) {
uint64_t n = 0;
@@ -49,11 +54,17 @@ static bool read_mbf(SkStream* stream, uint64_t* value) {
}
static bool read_header(SkStream* stream, SkISize* size) {
- uint64_t width, height;
- uint16_t data;
- if (stream->read(&data, 2) != 2 || data != 0) {
- return false;
+ {
+ uint8_t data;
+ if (!read_byte(stream, &data) || data != 0) { // unknown type
+ return false;
+ }
+ if (!read_byte(stream, &data) || (data & 0x9F)) { // skip fixed header
+ return false;
+ }
}
+
+ uint64_t width, height;
if (!read_mbf(stream, &width) || width > 0xFFFF || !width) {
return false;
}
« no previous file with comments | « no previous file | tests/CodexTest.cpp » ('j') | tests/CodexTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698