-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from kanurag94/batchrender
Support for Batch Rendering
- Loading branch information
Showing
4 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
#include "play.h" | ||
#include "i18n.h" | ||
#include "xthread.h" | ||
#include "customdialog.h" | ||
|
||
#define LANG(name, name2) \ | ||
MENUSTRING("lang", NULL, name, name2, 0, \ | ||
|
@@ -62,7 +63,7 @@ const char *const uih_colornames[] = {"white", "black", "red", NULL}; | |
* Zoltan Kovacs <[email protected]>, 2003-01-05 | ||
*/ | ||
|
||
#define MAX_MENUDIALOGS_I18N 104 | ||
#define MAX_MENUDIALOGS_I18N 115 | ||
#define Register(variable) variable = &menudialogs_i18n[no_menudialogs_i18n] | ||
static menudialog menudialogs_i18n[MAX_MENUDIALOGS_I18N]; | ||
// static int no_menudialogs_i18n; | ||
|
@@ -76,7 +77,8 @@ static menudialog *uih_perturbationdialog, *uih_juliadialog, | |
*uih_filterdialog, *uih_shiftdialog, *uih_speeddialog, *printdialog, | ||
*uih_bailoutdialog, *uih_threaddialog, *saveanimdialog, *uih_juliamodedialog, | ||
*uih_textposdialog, *uih_fastmodedialog, *uih_timedialog, *uih_numdialog, | ||
*uih_fpdialog, *palettedialog, *uih_cyclingdialog, *loadimgdialog, *palettegradientdialog | ||
*uih_fpdialog, *palettedialog, *uih_cyclingdialog, *loadimgdialog, *palettegradientdialog, | ||
*uih_batchrenderdialog | ||
#ifdef USE_SFFE | ||
, | ||
*uih_sffedialog, *uih_sffeinitdialog | ||
|
@@ -128,6 +130,19 @@ void uih_registermenudialogs_i18n(void) | |
DIALOGCHOICE_I(TR("Dialog", "Always recalculate:"), yesno, 0); | ||
NULL_I(); | ||
|
||
Register(uih_batchrenderdialog); | ||
DIALOGIFILES_I(TR("Dialog", "Files to render:"), NULL); | ||
DIALOGOFILE_I(TR("Dialog", "Basename:"), "anim"); | ||
DIALOGINT_I(TR("Dialog", "Width:"), 640); | ||
DIALOGINT_I(TR("Dialog", "Height:"), 480); | ||
DIALOGFLOAT_I(TR("Dialog", "Pixel width (cm):"), 0.025); | ||
DIALOGFLOAT_I(TR("Dialog", "Pixel height (cm):"), 0.025); | ||
DIALOGFLOAT_I(TR("Dialog", "Framerate:"), 30); | ||
DIALOGCHOICE_I(TR("Dialog", "Image type:"), imgtypes, 0); | ||
DIALOGCHOICE_I(TR("Dialog", "Antialiasing:"), yesno, 0); | ||
DIALOGCHOICE_I(TR("Dialog", "Always recalculate:"), yesno, 0); | ||
NULL_I(); | ||
|
||
Register(uih_viewdialog); | ||
DIALOGCOORD_I(TR("Dialog", "Center:"), 0, 0); | ||
DIALOGFLOAT_I(TR("Dialog", "Radius:"), 1); | ||
|
@@ -380,6 +395,69 @@ static void uih_render(struct uih_context *c, dialogparam *d) | |
d[8].dint, d[9].dint, c->letterspersec, NULL); | ||
} | ||
|
||
static void uih_batchrender(struct uih_context *c, dialogparam *d) | ||
{ | ||
if(fnames.isEmpty()) { | ||
uih_error(c, "No file Selected"); | ||
return; | ||
} | ||
if (d[2].dint <= 0 || d[2].dint > 4096) { | ||
uih_error( | ||
c, | ||
TR("Error", | ||
"renderanim: Width parameter must be positive integer in the range 0..4096")); | ||
return; | ||
} | ||
if (d[3].dint <= 0 || d[3].dint > 4096) { | ||
uih_error( | ||
c, | ||
TR("Error", | ||
"renderanim: Height parameter must be positive integer in the range 0..4096")); | ||
return; | ||
} | ||
if (d[4].number <= 0 || d[5].number <= 0) { | ||
uih_error(c, | ||
TR("Error", | ||
"renderanim: Invalid real width and height dimensions")); | ||
return; | ||
} | ||
if (d[6].number <= 0 || d[6].number >= 1000000) { | ||
uih_error(c, TR("Error", "renderanim: invalid framerate")); | ||
return; | ||
} | ||
if (d[7].dint && d[8].dint) { | ||
uih_error( | ||
c, TR("Error", | ||
"renderanim: antialiasing not supported in 256 color mode")); | ||
return; | ||
} | ||
for(int i=0; i < (int)fnames.size(); i++) { | ||
QString hlpmsg = "Rendering (" + QString::number(i) + "/" + | ||
QString::number(fnames.size()) + ") " + fnames[i]; | ||
uih_message(c, hlpmsg.toStdString().c_str()); | ||
char* curr_file = strdup(fnames[i].toStdString().c_str()); | ||
strdup(d[1].dstring); | ||
QString file_number = "_" + QString::number(i) + "_"; | ||
char* file_suffix = strdup(file_number.toStdString().c_str()); | ||
char* base_name = (char *)malloc(strlen(d[1].dstring) + strlen(file_suffix) + 2); | ||
strcpy(base_name, d[1].dstring); | ||
strcat(base_name, file_suffix); | ||
|
||
uih_renderanimation(c, base_name, (xio_path)curr_file, d[2].dint, | ||
d[3].dint, d[4].number, d[5].number, | ||
(int)(1000000 / d[6].number), | ||
#ifdef STRUECOLOR24 | ||
d[7].dint ? C256 : TRUECOLOR24, | ||
#else | ||
d[7].dint ? C256 : TRUECOLOR, | ||
#endif | ||
d[8].dint, d[9].dint, c->letterspersec, NULL); | ||
free(base_name); | ||
} | ||
} | ||
|
||
|
||
|
||
static menudialog *uih_getcolordialog(struct uih_context *c) | ||
{ | ||
if (c != NULL) { | ||
|
@@ -1037,8 +1115,11 @@ void uih_registermenus_i18n(void) | |
MENUFLAG_INTERRUPT, uih_loadpngfile, loadimgdialog); | ||
MENUDIALOG_I("file", NULL, TR("Menu", "Save image"), "saveimg", 0, | ||
uih_savepngfile, saveimgdialog); | ||
MENUSEPARATOR_I("file"); | ||
MENUDIALOG_I("file", NULL, TR("Menu", "Render"), "renderanim", UI, | ||
uih_render, uih_renderdialog); | ||
MENUDIALOG_I("file", NULL, TR("Menu", "Batch Render"), "batchrender", UI, | ||
uih_batchrender, uih_batchrenderdialog); | ||
MENUSEPARATOR_I("file"); | ||
MENUNOP_I("file", NULL, TR("Menu", "Load random example"), "loadexample", | ||
MENUFLAG_INTERRUPT, uih_loadexample); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters