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

Side by Side Diff: src/codec/SkBmpCodec.cpp

Issue 1694513002: Support more color types for ICOs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: inIco Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/codec/SkBmpStandardCodec.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBmpCodec.h" 8 #include "SkBmpCodec.h"
9 #include "SkBmpMaskCodec.h" 9 #include "SkBmpMaskCodec.h"
10 #include "SkBmpRLECodec.h" 10 #include "SkBmpRLECodec.h"
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 // We can do this here because there is no color table to read 465 // We can do this here because there is no color table to read
466 // in bit mask mode. 466 // in bit mask mode.
467 if (!inIco && kBitMask_BmpInputFormat == inputFormat) { 467 if (!inIco && kBitMask_BmpInputFormat == inputFormat) {
468 if (stream->skip(offset - bytesRead) != offset - bytesRead) { 468 if (stream->skip(offset - bytesRead) != offset - bytesRead) {
469 SkCodecPrintf("Error: unable to skip to image data.\n"); 469 SkCodecPrintf("Error: unable to skip to image data.\n");
470 return false; 470 return false;
471 } 471 }
472 } 472 }
473 473
474 if (codecOut) { 474 if (codecOut) {
475 // BMPs-in-ICOs contain an alpha mask after the image which means we
476 // cannot guarantee that an image is opaque, even if the bmp thinks
477 // it is.
478 bool isOpaque = kOpaque_SkAlphaType == alphaType;
479 if (inIco) {
480 alphaType = kUnpremul_SkAlphaType;
481 }
482
475 // Set the image info 483 // Set the image info
476 const SkImageInfo& imageInfo = SkImageInfo::Make(width, height, 484 const SkImageInfo& imageInfo = SkImageInfo::Make(width, height,
477 colorType, alphaType); 485 colorType, alphaType);
478 486
479 // Return the codec 487 // Return the codec
480 switch (inputFormat) { 488 switch (inputFormat) {
481 case kStandard_BmpInputFormat: 489 case kStandard_BmpInputFormat:
482 // We require streams to have a memory base for Bmp-in-Ico decod es. 490 // We require streams to have a memory base for Bmp-in-Ico decod es.
483 SkASSERT(!inIco || nullptr != stream->getMemoryBase()); 491 SkASSERT(!inIco || nullptr != stream->getMemoryBase());
484 *codecOut = new SkBmpStandardCodec(imageInfo, stream, bitsPerPix el, numColors, 492 *codecOut = new SkBmpStandardCodec(imageInfo, stream, bitsPerPix el, numColors,
485 bytesPerColor, offset - bytesRead, rowOrder, inIco); 493 bytesPerColor, offset - bytesRead, rowOrder, isOpaque, i nIco);
486 return true; 494 return true;
487 case kBitMask_BmpInputFormat: 495 case kBitMask_BmpInputFormat:
488 // Bmp-in-Ico must be standard mode 496 // Bmp-in-Ico must be standard mode
489 if (inIco) { 497 if (inIco) {
490 SkCodecPrintf("Error: Icos may not use bit mask format.\n"); 498 SkCodecPrintf("Error: Icos may not use bit mask format.\n");
491 return false; 499 return false;
492 } 500 }
493 501
494 *codecOut = new SkBmpMaskCodec(imageInfo, stream, bitsPerPixel, masks.detach(), 502 *codecOut = new SkBmpMaskCodec(imageInfo, stream, bitsPerPixel, masks.detach(),
495 rowOrder); 503 rowOrder);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount); 566 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount);
559 } 567 }
560 568
561 int SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { 569 int SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes) {
562 // Create a new image info representing the portion of the image to decode 570 // Create a new image info representing the portion of the image to decode
563 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count) ; 571 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count) ;
564 572
565 // Decode the requested rows 573 // Decode the requested rows
566 return this->decodeRows(rowInfo, dst, rowBytes, this->options()); 574 return this->decodeRows(rowInfo, dst, rowBytes, this->options());
567 } 575 }
OLDNEW
« no previous file with comments | « no previous file | src/codec/SkBmpStandardCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698