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

Unified Diff: src/codec/SkBmpCodec.cpp

Issue 1273853004: Fix bmp RLE "bug" and add invalid image test to CodexTest (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments plus final nits from 1258863008 Created 5 years, 4 months 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
Index: src/codec/SkBmpCodec.cpp
diff --git a/src/codec/SkBmpCodec.cpp b/src/codec/SkBmpCodec.cpp
index 4383382d8a60a729686be58c2e34f4705ebf8d83..92aa2c37989579b74c94a07f159bc71aade12254 100644
--- a/src/codec/SkBmpCodec.cpp
+++ b/src/codec/SkBmpCodec.cpp
@@ -478,6 +478,7 @@ bool SkBmpCodec::ReadHeader(SkStream* stream, bool inIco, SkCodec** codecOut) {
case kBitMask_BmpInputFormat:
// Bmp-in-Ico must be standard mode
if (inIco) {
msarett 2015/08/11 22:35:03 Turns out this is reachable and we have a test now
+ SkCodecPrintf("Error: Icos may not use bit mask format.\n");
return false;
}
// Skip to the start of the pixel array.
@@ -493,9 +494,10 @@ bool SkBmpCodec::ReadHeader(SkStream* stream, bool inIco, SkCodec** codecOut) {
return true;
case kRLE_BmpInputFormat:
// Bmp-in-Ico must be standard mode
- if (inIco) {
- return false;
- }
+ // This line should be unreachable, since we require that
scroggo 2015/08/12 14:14:30 nit: this line is reachable - it just shouldn't be
msarett 2015/08/12 15:01:24 Haha yep. Fixing the comment.
+ // RLE Bmps have a valid number of totalBytes, and Icos skip
+ // the header that contains totalBytes.
+ SkASSERT(!inIco);
msarett 2015/08/11 22:35:03 I discovered that this is unreachable when trying
*codecOut = SkNEW_ARGS(SkBmpRLECodec, (
imageInfo, stream, bitsPerPixel, numColors,
bytesPerColor, offset - bytesRead, rowOrder, RLEBytes));
@@ -564,7 +566,7 @@ void* SkBmpCodec::getDstStartRow(void* dst, size_t dstRowBytes, int32_t y) const
*/
uint32_t SkBmpCodec::computeNumColors(uint32_t numColors) {
// Zero is a default for maxColors
- // Also set fNumColors to maxColors when it is too large
+ // Also set numColors to maxColors when it is too large
uint32_t maxColors = 1 << fBitsPerPixel;
if (numColors == 0 || numColors >= maxColors) {
return maxColors;

Powered by Google App Engine
This is Rietveld 408576698