From bf706ac7053f6f595fe1175c32ac28458cef28e3 Mon Sep 17 00:00:00 2001 From: Person Date: Tue, 15 Mar 2022 17:49:48 -0600 Subject: [PATCH] --User changes -Add two new options --width and --height to EmberRender and EmberAnimate to allow the user to specify absolute dimensions to render the image at. --- Source/EmberAnimate/EmberAnimate.cpp | 15 +++++++++++++++ Source/EmberCommon/EmberOptions.h | 16 ++++++++++++---- Source/EmberRender/EmberRender.cpp | 15 +++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/Source/EmberAnimate/EmberAnimate.cpp b/Source/EmberAnimate/EmberAnimate.cpp index bb8ca18..efdd24b 100644 --- a/Source/EmberAnimate/EmberAnimate.cpp +++ b/Source/EmberAnimate/EmberAnimate.cpp @@ -262,6 +262,21 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt) const auto h = std::max(size_t(ember.m_OrigFinalRasH * opt.HeightScale()), 10); ember.SetSizeAndAdjustScale(w, h, false, scaleType); } + else if (opt.Width() || opt.Height()) + { + auto scaleType = eScaleType::SCALE_NONE; + + if (ToLower(opt.ScaleType()) == "width") + scaleType = eScaleType::SCALE_WIDTH; + else if (ToLower(opt.ScaleType()) == "height") + scaleType = eScaleType::SCALE_HEIGHT; + else if (ToLower(opt.ScaleType()) != "none") + cout << "Scale type must be width height or none. Setting to none.\n"; + + auto w = opt.Width() ? opt.Width() : ember.m_OrigFinalRasW; + auto h = opt.Height() ? opt.Height() : ember.m_OrigFinalRasH; + ember.SetSizeAndAdjustScale(w, h, false, scaleType); + } //Cast to double in case the value exceeds 2^32. const auto imageMem = 4 * static_cast(ember.m_FinalRasW) diff --git a/Source/EmberCommon/EmberOptions.h b/Source/EmberCommon/EmberOptions.h index 40e2ca3..d0bbb2c 100644 --- a/Source/EmberCommon/EmberOptions.h +++ b/Source/EmberCommon/EmberOptions.h @@ -93,6 +93,8 @@ enum class eOptionIDs : et OPT_START_COUNT, OPT_PADDING, OPT_PRIORITY, + OPT_W, + OPT_H, OPT_SS,//Float value args. OPT_WS, @@ -402,11 +404,13 @@ public: INITUINTOPTION(MaxXforms, Eou(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_MAX_XFORMS, _T("--maxxforms"), UINT_MAX, SO_REQ_SEP, " --maxxforms= The maximum number of xforms allowed in the final output.\n")); INITUINTOPTION(StartCount, Eou(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_START_COUNT, _T("--startcount"), 0, SO_REQ_SEP, " --startcount= The number to add to each flame name when generating a sequence. Useful for programs like ffmpeg which require numerically increasing filenames [default: 0].\n")); INITUINTOPTION(Padding, Eou(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_PADDING, _T("--padding"), 0, SO_REQ_SEP, " --padding= Override the amount of zero padding added to each flame name when generating a sequence. Useful for programs like ffmpeg which require fixed width filenames [default: 0 (auto calculate padding)].\n")); + INITUINTOPTION(Width, Eou(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_W, _T("--width"), 0, SO_REQ_SEP, " --width= Override the width the flame is rendered at. Ideally used in conjunction with --scaletype [default: 0 (no override)].\n")); + INITUINTOPTION(Height, Eou(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_H, _T("--height"), 0, SO_REQ_SEP, " --height= Override the height the flame is rendered at. Ideally used in conjunction with --scaletype [default: 0 (no override)].\n")); //Double. - INITDOUBLEOPTION(SizeScale, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_SS, _T("--ss"), 1.0, SO_REQ_SEP, " --ss= Size scale. All dimensions are scaled by this amount [default: 1.0].\n")); - INITDOUBLEOPTION(WidthScale, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_WS, _T("--ws"), 1.0, SO_REQ_SEP, " --ws= Width scale. The width is scaled by this amount [default: 1.0].\n")); - INITDOUBLEOPTION(HeightScale, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_HS, _T("--hs"), 1.0, SO_REQ_SEP, " --hs= Height scale. The height is scaled by this amount [default: 1.0].\n")); - INITDOUBLEOPTION(QualityScale, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_QS, _T("--qs"), 1.0, SO_REQ_SEP, " --qs= Quality scale. All quality values are scaled by this amount [default: 1.0].\n")); + INITDOUBLEOPTION(SizeScale, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_SS, _T("--ss"), 1.0, SO_REQ_SEP, " --ss= Size scale. All dimensions are scaled by this amount. Ideally used in conjunction with --scaletype [default: 1.0 (no scaling)].\n")); + INITDOUBLEOPTION(WidthScale, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_WS, _T("--ws"), 1.0, SO_REQ_SEP, " --ws= Width scale. The width is scaled by this amount. Ideally used in conjunction with --scaletype [default: 1.0 (no scaling)].\n")); + INITDOUBLEOPTION(HeightScale, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_HS, _T("--hs"), 1.0, SO_REQ_SEP, " --hs= Height scale. The height is scaled by this amount. Ideally used in conjunction with --scaletype [default: 1.0 (no scaling)].\n")); + INITDOUBLEOPTION(QualityScale, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_QS, _T("--qs"), 1.0, SO_REQ_SEP, " --qs= Quality scale. All quality values are scaled by this amount [default: 1.0 (no scaling)].\n")); INITDOUBLEOPTION(Quality, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_QUALITY, _T("--quality"), 0.0, SO_REQ_SEP, " --quality= Override the quality of the flame if not 0 [default: 0].\n")); INITDOUBLEOPTION(SBPctPerTh, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_SBPCTTH, _T("--sbpctth"), 0.025, SO_REQ_SEP, " --sbpctth= The percentage of a sub batch from 0.01 to 1.0 to complete per thread per kernel launch done in OpenCL rendering. This is for performance tuning with OpenCL and does not apply to CPU rendering [default: 0.025 (256 iters with the default sub batch size of 10k)].\n")); INITDOUBLEOPTION(DeMin, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_DE_MIN, _T("--demin"), -1.0, SO_REQ_SEP, " --demin= Override the minimum size of the density estimator filter radius if not -1 [default: -1].\n")); @@ -556,6 +560,8 @@ public: PARSEOPTION(eOptionIDs::OPT_MAX_XFORMS, MaxXforms); PARSEOPTION(eOptionIDs::OPT_START_COUNT, StartCount); PARSEOPTION(eOptionIDs::OPT_PADDING, Padding); + PARSEOPTION(eOptionIDs::OPT_W, Width); + PARSEOPTION(eOptionIDs::OPT_H, Height); PARSEOPTION(eOptionIDs::OPT_SS, SizeScale);//Double args. PARSEOPTION(eOptionIDs::OPT_WS, WidthScale); PARSEOPTION(eOptionIDs::OPT_HS, HeightScale); @@ -847,6 +853,8 @@ public: Eou MaxXforms; Eou StartCount; Eou Padding; + Eou Width; + Eou Height; Eod SizeScale;//Value double. Eod WidthScale; diff --git a/Source/EmberRender/EmberRender.cpp b/Source/EmberRender/EmberRender.cpp index a922aa8..f5a6e8b 100644 --- a/Source/EmberRender/EmberRender.cpp +++ b/Source/EmberRender/EmberRender.cpp @@ -201,6 +201,21 @@ bool EmberRender(int argc, _TCHAR* argv[], EmberOptions& opt) auto h = std::max(size_t(ember.m_OrigFinalRasH * opt.HeightScale()), 10); ember.SetSizeAndAdjustScale(w, h, false, scaleType); } + else if (opt.Width() || opt.Height()) + { + auto scaleType = eScaleType::SCALE_NONE; + + if (ToLower(opt.ScaleType()) == "width") + scaleType = eScaleType::SCALE_WIDTH; + else if (ToLower(opt.ScaleType()) == "height") + scaleType = eScaleType::SCALE_HEIGHT; + else if (ToLower(opt.ScaleType()) != "none") + cout << "Scale type must be width height or none. Setting to none.\n"; + + auto w = opt.Width() ? opt.Width() : ember.m_OrigFinalRasW; + auto h = opt.Height() ? opt.Height() : ember.m_OrigFinalRasH; + ember.SetSizeAndAdjustScale(w, h, false, scaleType); + } if (ember.m_FinalRasW == 0 || ember.m_FinalRasH == 0) {