Chromium Code Reviews| Index: tools/skimage_main.cpp |
| diff --git a/tools/skimage_main.cpp b/tools/skimage_main.cpp |
| index 2041f7bbcc5a4991fc81791519b65f4de86ea068..cb69e1e81ac81e9fdd66c4393ba58a8f92306268 100644 |
| --- a/tools/skimage_main.cpp |
| +++ b/tools/skimage_main.cpp |
| @@ -299,21 +299,33 @@ static void decodeFileAndWrite(const char srcPath[], const SkString* writePath) |
| write_expectations(bitmapFromDecodeSubset, subsetName.c_str()); |
| if (writePath != NULL) { |
| - // Write the region to a file whose name includes the dimensions. |
| - SkString suffix = SkStringPrintf("_%s.png", subsetDim.c_str()); |
| - SkString outPath; |
| - make_outname(&outPath, writePath->c_str(), srcPath, suffix.c_str()); |
| - SkDEBUGCODE(bool success =) |
| - write_bitmap(outPath.c_str(), &bitmapFromDecodeSubset); |
| - SkASSERT(success); |
| - gSuccessfulSubsetDecodes.push_back().printf("\twrote %s", outPath.c_str()); |
| - // Also use extractSubset from the original for visual comparison. |
| - SkBitmap extractedSubset; |
| - if (bitmap.extractSubset(&extractedSubset, rect)) { |
| - suffix.printf("_%s_extracted.png", subsetDim.c_str()); |
| - make_outname(&outPath, writePath->c_str(), srcPath, suffix.c_str()); |
| - SkDEBUGCODE(success =) write_bitmap(outPath.c_str(), &extractedSubset); |
| + // Create a subdirectory to hold the results of decodeSubset. |
| + SkString dir(*writePath); |
| + dir.appendf("%s%c", "subsets", SkPATH_SEPARATOR); |
| + if (sk_mkdir(dir.c_str())) { |
|
epoger
2013/05/09 17:45:40
What happens if the mkdir fails? Does it pretend
scroggo
2013/05/13 17:34:12
Now it will provide an error.
|
| + // Write the subset to a file whose name includes the dimensions. |
| + SkString suffix = SkStringPrintf("_%s.png", subsetDim.c_str()); |
| + SkString outPath; |
| + make_outname(&outPath, dir.c_str(), srcPath, suffix.c_str()); |
| + SkDEBUGCODE(bool success =) |
| + write_bitmap(outPath.c_str(), &bitmapFromDecodeSubset); |
|
epoger
2013/05/09 17:45:40
Instead of the 3 lines, I think you can do it like
scroggo
2013/05/13 17:34:12
Done.
|
| SkASSERT(success); |
| + gSuccessfulSubsetDecodes.push_back().printf("\twrote %s", |
| + outPath.c_str()); |
| + // Also use extractSubset from the original for visual comparison. |
| + // Write the result to a file in a separate subdirectory. |
| + SkBitmap extractedSubset; |
| + if (bitmap.extractSubset(&extractedSubset, rect)) { |
| + SkString dirExtracted(*writePath); |
| + dirExtracted.appendf("%s%c", "extracted", SkPATH_SEPARATOR); |
| + if (sk_mkdir(dirExtracted.c_str())) { |
| + make_outname(&outPath, dirExtracted.c_str(), srcPath, |
| + suffix.c_str()); |
| + SkDEBUGCODE(success =) |
| + write_bitmap(outPath.c_str(), &extractedSubset); |
| + SkASSERT(success); |
| + } |
| + } |
| } |
| } |
| } else { |