Index: src/codec/SkRawCodec.cpp |
diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp |
index 762e82364cd3a6dd27e7c6534f69f0d40d6c8eb4..ef8ba700a46b22130bdfd262b610e2b66e1c72ee 100644 |
--- a/src/codec/SkRawCodec.cpp |
+++ b/src/codec/SkRawCodec.cpp |
@@ -640,7 +640,11 @@ SkCodec* SkRawCodec::NewFromStream(SkStream* stream) { |
if (::piex::IsRaw(&piexStream)) { |
::piex::Error error = ::piex::GetPreviewImageData(&piexStream, &imageData); |
- if (error == ::piex::Error::kOk && imageData.preview.length > 0) { |
+ // Theoretically PIEX can return JPEG compressed image or uncompressed RGB image. We only |
+ // handle the JPEG compressed preview image here. |
+ if (error == ::piex::Error::kOk && imageData.preview.length > 0 && |
+ imageData.preview.format == ::piex::Image::kJpegCompressed) |
+ { |
// transferBuffer() is destructive to the rawStream. Abandon the rawStream after this |
// function call. |
// FIXME: one may avoid the copy of memoryStream and use the buffered rawStream. |