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

Side by Side Diff: tools/skimage_main.cpp

Issue 25726004: Fixes for decoding to A8. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "gm_expectations.h" 8 #include "gm_expectations.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 static SkTArray<SkString, false> gMissingExpectations; 104 static SkTArray<SkString, false> gMissingExpectations;
105 static SkTArray<SkString, false> gMissingSubsetExpectations; 105 static SkTArray<SkString, false> gMissingSubsetExpectations;
106 106
107 static SkBitmap::Config gPrefConfig(SkBitmap::kNo_Config); 107 static SkBitmap::Config gPrefConfig(SkBitmap::kNo_Config);
108 108
109 // Expections read from a file specified by readExpectationsPath. The expectatio ns must have been 109 // Expections read from a file specified by readExpectationsPath. The expectatio ns must have been
110 // previously written using createExpectationsPath. 110 // previously written using createExpectationsPath.
111 SkAutoTUnref<skiagm::JsonExpectationsSource> gJsonExpectations; 111 SkAutoTUnref<skiagm::JsonExpectationsSource> gJsonExpectations;
112 112
113 static bool write_bitmap(const char outName[], const SkBitmap& bm) { 113 static bool write_bitmap(const char outName[], const SkBitmap& bm) {
114 return SkImageEncoder::EncodeFile(outName, bm, SkImageEncoder::kPNG_Type, 10 0); 114 const SkBitmap* bmPtr;
115 SkBitmap bm8888;
116 if (bm.config() == SkBitmap::kA8_Config) {
117 // Copy A8 into ARGB_8888, since our image encoders do not currently
118 // support A8.
djsollen 2013/10/03 16:54:28 is that a feature that we should support?
scroggo 2013/10/03 16:58:52 Possibly, although I'd set it at a low priority. N
reed1 2013/10/04 08:56:27 Perhaps the code at this level shouldn't know if i
scroggo 2013/10/04 19:45:53 They do report failure. I have a CL at https://cod
119 if (!bm.copyTo(&bm8888, SkBitmap::kARGB_8888_Config)) {
120 return false;
121 }
122 bmPtr = &bm8888;
123 } else {
124 bmPtr = &bm;
125 }
126 return SkImageEncoder::EncodeFile(outName, *bmPtr, SkImageEncoder::kPNG_Type , 100);
115 } 127 }
116 128
117 /** 129 /**
118 * Return a random SkIRect inside the range specified. 130 * Return a random SkIRect inside the range specified.
119 * @param rand Random number generator. 131 * @param rand Random number generator.
120 * @param maxX Exclusive maximum x-coordinate. SkIRect's fLeft and fRight will be 132 * @param maxX Exclusive maximum x-coordinate. SkIRect's fLeft and fRight will be
121 * in the range [0, maxX) 133 * in the range [0, maxX)
122 * @param maxY Exclusive maximum y-coordinate. SkIRect's fTop and fBottom will be 134 * @param maxY Exclusive maximum y-coordinate. SkIRect's fTop and fBottom will be
123 * in the range [0, maxY) 135 * in the range [0, maxY)
124 * @return SkIRect Non-empty, non-degenerate rectangle. 136 * @return SkIRect Non-empty, non-degenerate rectangle.
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 &bitmapFromDecodeSubset, rect, bitmap); 500 &bitmapFromDecodeSubset, rect, bitmap);
489 } 501 }
490 } else { 502 } else {
491 gFailedSubsetDecodes.push_back().printf("Failed to decode re gion %s from %s", 503 gFailedSubsetDecodes.push_back().printf("Failed to decode re gion %s from %s",
492 subsetDim.c_str(), s rcPath); 504 subsetDim.c_str(), s rcPath);
493 } 505 }
494 } 506 }
495 } 507 }
496 } 508 }
497 509
498 if (FLAGS_reencode) { 510 // Do not attempt to re-encode A8, since our image encoders do not support e ncoding to A8.
511 if (FLAGS_reencode && bitmap.config() != SkBitmap::kA8_Config) {
499 // Encode to the format the file was originally in, or PNG if the encode r for the same 512 // Encode to the format the file was originally in, or PNG if the encode r for the same
500 // format is unavailable. 513 // format is unavailable.
501 SkImageDecoder::Format format = codec->getFormat(); 514 SkImageDecoder::Format format = codec->getFormat();
502 if (SkImageDecoder::kUnknown_Format == format) { 515 if (SkImageDecoder::kUnknown_Format == format) {
503 if (stream.rewind()) { 516 if (stream.rewind()) {
504 format = SkImageDecoder::GetStreamFormat(&stream); 517 format = SkImageDecoder::GetStreamFormat(&stream);
505 } 518 }
506 if (SkImageDecoder::kUnknown_Format == format) { 519 if (SkImageDecoder::kUnknown_Format == format) {
507 const char* dot = strrchr(srcPath, '.'); 520 const char* dot = strrchr(srcPath, '.');
508 if (NULL != dot) { 521 if (NULL != dot) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 } 712 }
700 713
701 return failed ? -1 : 0; 714 return failed ? -1 : 0;
702 } 715 }
703 716
704 #if !defined SK_BUILD_FOR_IOS 717 #if !defined SK_BUILD_FOR_IOS
705 int main(int argc, char * const argv[]) { 718 int main(int argc, char * const argv[]) {
706 return tool_main(argc, (char**) argv); 719 return tool_main(argc, (char**) argv);
707 } 720 }
708 #endif 721 #endif
OLDNEW
« src/images/SkImageDecoder_libpng.cpp ('K') | « src/images/SkImageDecoder_libpng.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698