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

Unified Diff: experimental/webtry/main.cpp

Issue 656463002: add support for skfiddle width/height options (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add new db creation commands to the design documnt Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/webtry/DESIGN.md ('k') | experimental/webtry/res/js/webtry.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/webtry/main.cpp
diff --git a/experimental/webtry/main.cpp b/experimental/webtry/main.cpp
index 0a71d9613333de2f86b45fb9dd2265608ab87dda..98c2f5e4e68aa6a6421d32bb6533da005a1414e3 100644
--- a/experimental/webtry/main.cpp
+++ b/experimental/webtry/main.cpp
@@ -9,6 +9,7 @@
#include "SkImageDecoder.h"
#include "SkImageEncoder.h"
#include "SkImageInfo.h"
+#include "SkOSFile.h"
#include "SkStream.h"
#include "SkSurface.h"
@@ -18,6 +19,8 @@ __SK_FORCE_IMAGE_DECODER_LINKING;
DEFINE_string(out, "", "Filename of the PNG to write to.");
DEFINE_string(source, "", "Filename of the source image.");
+DEFINE_int32(width, 256, "Width of output image.");
+DEFINE_int32(height, 256, "Height of output image.");
// Defined in template.cpp.
extern SkBitmap source;
@@ -102,14 +105,20 @@ int main(int argc, char** argv) {
}
if (FLAGS_source.count() == 1) {
- if (!SkImageDecoder::DecodeFile(FLAGS_source[0], &source)) {
- perror("Unable to read the source image.");
- }
+ const char *sourceDir = getenv("WEBTRY_INOUT");
+ if (NULL == sourceDir) {
+ sourceDir = "/skia_build/inout";
+ }
+
+ SkString sourcePath = SkOSPath::Join(sourceDir, FLAGS_source[0]);
+ if (!SkImageDecoder::DecodeFile(sourcePath.c_str(), &source)) {
+ perror("Unable to read the source image.");
+ }
}
SkFILEWStream stream(FLAGS_out[0]);
- SkImageInfo info = SkImageInfo::MakeN32(256, 256, kPremul_SkAlphaType);
+ SkImageInfo info = SkImageInfo::MakeN32(FLAGS_width, FLAGS_height, kPremul_SkAlphaType);
SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
SkCanvas* canvas = surface->getCanvas();
« no previous file with comments | « experimental/webtry/DESIGN.md ('k') | experimental/webtry/res/js/webtry.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698