From: Hermet Park Date: Sat, 31 Aug 2019 09:11:26 +0000 (+0900) Subject: lottie2gif: add option to set resolution X-Git-Tag: submit/tizen/20190905.064609~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=67ab33338bea83028d48a226d1f6f197acc4813e;p=platform%2Fcore%2Fuifw%2Flottie-player.git lottie2gif: add option to set resolution Usage: lottie2gif [lottieFileName] [Resolution] [bgColor] Examples: $ lottie2gif input.json $ lottie2gif input.json 200x200 $ lottie2gif input.json 200x200 ff00ff --- diff --git a/example/lottie2gif.cpp b/example/lottie2gif.cpp index 23d24a5..cb43c21 100644 --- a/example/lottie2gif.cpp +++ b/example/lottie2gif.cpp @@ -94,12 +94,24 @@ public: return result(); } - int setup(int argc, char **argv) + int setup(int argc, char **argv, size_t *width, size_t *height) { char *path{nullptr}; + *width = *height = 200; //default gif size + if (argc > 1) path = argv[1]; - if (argc > 2) bgColor = strtol(argv[2], NULL, 16); + if (argc > 2) { + char tmp[20]; + char *x = strstr(argv[2], "x"); + if (x) { + snprintf(tmp, x - argv[2] + 1, "%s", argv[2]); + *width = atoi(tmp); + snprintf(tmp, sizeof(tmp), "%s", x + 1); + *height = atoi(tmp); + } + } + if (argc > 3) bgColor = strtol(argv[3], NULL, 16); if (!path) return help(); @@ -142,7 +154,7 @@ private: } int help() { - std::cout<<"Usage: \n lottie2gif [lottieFileName] [bgColor]\n\nExamples: \n $ lottie2gif input.json\n $ lottie2gif input.json ff00ff\n\n"; + std::cout<<"Usage: \n lottie2gif [lottieFileName] [Resolution] [bgColor]\n\nExamples: \n $ lottie2gif input.json\n $ lottie2gif input.json 200x200\n $ lottie2gif input.json 200x200 ff00ff\n\n"; return 1; } @@ -156,10 +168,11 @@ int main(int argc, char **argv) { App app; + size_t w, h; - if (app.setup(argc, argv)) return 1; + if (app.setup(argc, argv, &w, &h)) return 1; - app.render(200, 200); + app.render(w, h); return 0; }