1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
|
/* gap_onion_main.c
* 2001.11.20 hof (Wolfgang Hofer)
*
* GAP ... Gimp Animation Plugins
*
* This Module handles ONION Skin Layers in the GIMP Video Menu.
* Onion Layer(s) usually do show previous (or next) frame(s)
* of the video in the current frame.
*
* Video/OnionSkin/Configuration ... GUI to configure, create abd delete onionskin Layer(s) for framerange
* Video/OnionSkin/Create or Replace ... create or replace onionskin Layer(s) and set visible.
* Video/OnionSkin/Delete ... delete onionskin Layer(s)
* Video/OnionSkin/Toggle Visibility ... show/hide onionskin layer(s)
*
*/
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* revision history:
* version 2.1.0a; 2004/06/03 hof: added onionskin ref_mode parameter
* version 1.3.17a; 2003.07.29 hof: param types GimpPlugInInfo.run procedure
* version 1.3.16c; 2003.07.12 hof: Onionsettings scope changes from gimp-session
* to permanent per animation (stored in video_info file=.
* version 1.3.16b; 2003.07.06 hof: new parameter asc_opacity (for cross-fading support)
* version 1.3.14a; 2003.05.24 hof: integration into gimp-gap-1.3.14
* version 1.3.12a; 2003.05.03 hof: started port to gimp-1.3 / gtk+2.2
* version 1.2.2a; 2001.11.20 hof: created
*/
#include <gap_onion_main.h>
#include <gap_onion_base.h>
#include <gap_onion_worker.h>
#include <gap_onion_dialog.h>
/* ------------------------
* global gap DEBUG switch
* ------------------------
*/
/* int gap_debug = 1; */ /* print debug infos */
/* int gap_debug = 0; */ /* 0: dont print debug infos */
int gap_debug = 0;
GapOnionMainGlobalParams global_params;
static void query(void);
static void run(const gchar *name
, gint n_params
, const GimpParam *param
, gint *nreturn_vals
, GimpParam **return_vals);
GimpPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
};
static GimpParamDef args_onion_cfg[] =
{
{GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{GIMP_PDB_IMAGE, "image", "Input image (the current videoframe)"},
{GIMP_PDB_DRAWABLE, "drawable", "Input drawable (unused)"},
{GIMP_PDB_INT32, "num_olayers", "Number of Onion Layers"},
{GIMP_PDB_INT32, "ref_delta", "Reference Frame Delta: +- 1 ... n Default: -1 "},
{GIMP_PDB_INT32, "ref_cycle", "Reference is Cycle : TRUE/FALSE (TRUE .. last frame has frame 0 as next frame)"},
{GIMP_PDB_INT32, "stack_pos", "Place OnionLayer(s) on Stackposition 0..n Default: 1"},
{GIMP_PDB_INT32, "stack_top", "TRUE Stack Position is relative from TOP, FALSE relative to Bottom"},
{GIMP_PDB_FLOAT, "opacity", "OnionOpacity: 0.0..100.0%"},
{GIMP_PDB_FLOAT, "opacity_delta", "OnionOpacityDelta: 0..100% Default: 80"},
{GIMP_PDB_INT32, "ignore_botlayers", "Ignore N Bottom Sourcelayers (0 .. use full picture, 1 ignor bg layer) "},
{GIMP_PDB_INT32, "select_mode", "Mode how to identify a layer: 0-3 by layername 0=equal, 1=prefix, 2=suffix, 3=contains, 6=all visible (ignore select_string)"},
{GIMP_PDB_INT32, "select_case", "0: ignore case 1: select_string is case sensitive"},
{GIMP_PDB_INT32, "select_invert", "0: select normal 1: invert (select all unselected layers)"},
{GIMP_PDB_STRING, "select_string", "string to match with layername (how to match is defined by select_mode)"},
{GIMP_PDB_INT32, "range_from", "first affected frame (ignored if run is not 2 or 3)"},
{GIMP_PDB_INT32, "range_to", "last affected frame (ignored if run is not 2 or 3)"},
{GIMP_PDB_INT32, "run", "0 .. do nothing, 1..set params for this session, 2..set and create or replace onionlayers for selected framerange 3..delete onionlayers from selected famerange "},
{GIMP_PDB_INT32, "asc_opacity", "TRUE..farest neighbour frame has highest opacity, FALSE: nearest has highest opacity"},
{GIMP_PDB_INT32, "auto_create", "TRUE..automatic creation/replacing of onionskinlayers after GAP controlled load"},
{GIMP_PDB_INT32, "auto_delete", "TRUE..automatic delete of onionskinlayers before GAP controlled save"},
{GIMP_PDB_INT32, "ref_mode", "Reference Mode: 0:NORMAL, 1:BIDIRECTIONAL_SINGLE, 2:BIDIRECTIONAL_DOUBLE "},
};
static int nargs_onion_cfg = G_N_ELEMENTS(args_onion_cfg);
static GimpParamDef args_onion_visi[] =
{
{GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{GIMP_PDB_IMAGE, "image", "Input image (the current videoframe)"},
{GIMP_PDB_DRAWABLE, "drawable", "Input drawable (unused)"},
{GIMP_PDB_INT32, "visible_mode", "0: set invisible 1: set visible 2: toggle visibility"},
};
static int nargs_onion_visi = G_N_ELEMENTS(args_onion_visi);
static GimpParamDef args_onion_std[] =
{
{GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{GIMP_PDB_IMAGE, "image", "Input image (the current videoframe)"},
{GIMP_PDB_DRAWABLE, "drawable", "Input drawable (unused)"},
};
static int nargs_onion_std = G_N_ELEMENTS(args_onion_std);
static GimpParamDef *return_vals = NULL;
static int nreturn_vals = 0;
/* ------------------------
* MAIN query and run
* ------------------------
*/
MAIN ()
static void
query ()
{
gimp_plugin_domain_register (GETTEXT_PACKAGE, LOCALEDIR);
gimp_install_procedure(GAP_PLUGIN_NAME_ONION_CFG,
"This plugin sets Configuration for Onion Layers in Videofames",
"This plugin is the configuration GUI for Onion layers."
" Onion Layer(s) usually do show previous and/ or next frame(s)"
" of the video in the current frame, depending on ref_mode parameter"
" Onion Layers are not created automatically. You have to create or delete them manually"
" using the menu Video/OnionSkin/make or Video/OnionSkin/delete or call the Procedures "
GAP_PLUGIN_NAME_ONION_APPLY " "
GAP_PLUGIN_NAME_ONION_DEL " "
" The configuration can be saved in the gimprc parameter file.",
"Wolfgang Hofer (hof@gimp.org)",
"Wolfgang Hofer",
GAP_VERSION_WITH_DATE,
N_("Configuration..."),
"RGB*, INDEXED*, GRAY*",
GIMP_PLUGIN,
nargs_onion_cfg, nreturn_vals,
args_onion_cfg, return_vals);
gimp_install_procedure(GAP_PLUGIN_NAME_ONION_APPLY,
"This plugin creates or replaces Onionskin Layer(s)",
"This plugin creates or updates Onionskin Layers in the current Videoframe."
" Onion Layer(s) usually do show previous (or next) frame(s)"
" of the video. At 1.st call in the current frame."
" This Plugin runs NONINTERACTIVE only. It depends on the configuration settings"
" made by Video/Onionskin/Config or call of the plugin: "
GAP_PLUGIN_NAME_ONION_CFG " "
" if no configuration is found, default settings are used",
"Wolfgang Hofer (hof@gimp.org)",
"Wolfgang Hofer",
GAP_VERSION_WITH_DATE,
N_("Create or Replace"),
"RGB*, INDEXED*, GRAY*",
GIMP_PLUGIN,
nargs_onion_std, nreturn_vals,
args_onion_std, return_vals);
gimp_install_procedure(GAP_PLUGIN_NAME_ONION_DEL,
"This plugin removes OnionSkin Layer(s)",
"This plugin removes Onion Skin Layers from the current Videoframe."
" Onion Layer(s) usually do show previous (or next) frame(s)"
" of the video.",
"Wolfgang Hofer (hof@gimp.org)",
"Wolfgang Hofer",
GAP_VERSION_WITH_DATE,
N_("Delete"),
"RGB*, INDEXED*, GRAY*",
GIMP_PLUGIN,
nargs_onion_std, nreturn_vals,
args_onion_std, return_vals);
gimp_install_procedure(GAP_PLUGIN_NAME_ONION_VISI,
"This plugin toggles visibility of OnionSkin Layer(s)",
"This plugin sets visibility for all onionskin Layers in the current Videoframe.",
"Wolfgang Hofer (hof@gimp.org)",
"Wolfgang Hofer",
GAP_VERSION_WITH_DATE,
N_("Toggle Visibility"),
"RGB*, INDEXED*, GRAY*",
GIMP_PLUGIN,
nargs_onion_visi, nreturn_vals,
args_onion_visi, return_vals);
{
/* Menu names */
const char *menupath_image_video = N_("<Image>/Video/");
const char *menupath_image_video_onionskin = N_("<Image>/Video/Onionskin/");
//gimp_plugin_menu_branch_register("<Image>", "Video");
//gimp_plugin_menu_branch_register("<Image>/Video", "Onionskin");
gimp_plugin_menu_register (GAP_PLUGIN_NAME_ONION_CFG, menupath_image_video_onionskin);
gimp_plugin_menu_register (GAP_PLUGIN_NAME_ONION_APPLY, menupath_image_video_onionskin);
gimp_plugin_menu_register (GAP_PLUGIN_NAME_ONION_DEL, menupath_image_video_onionskin);
gimp_plugin_menu_register (GAP_PLUGIN_NAME_ONION_VISI, menupath_image_video_onionskin);
}
} /* end query */
/* optional: include files with GUI and some worker procedures here
* (so we can compile and install using gimptool without any makefile)
*/
#ifdef INCLUDE_ALL_C_FILES
#include "gap_match.c"
#include "gap_lib.c"
#include "gap_onion_gui.c"
#include "gap_onion_worker.c"
#endif
static void
run(const gchar *name
, gint n_params
, const GimpParam *param
, gint *nreturn_vals
, GimpParam **return_vals)
{
GapOnionMainGlobalParams *gpp;
static GimpParam values[1];
gint32 l_rc;
gint32 l_lock_image_id;
char *l_env;
gpp = &global_params;
*nreturn_vals = 1;
*return_vals = values;
l_rc = 0;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_SUCCESS;
l_env = (char*) g_getenv("GAP_DEBUG");
if(l_env != NULL)
{
if((*l_env != 'n') && (*l_env != 'N')) gap_debug = 1;
}
if(gap_debug) fprintf(stderr, "\n\ngap_onion_main: debug name = %s\n", name);
gpp->run_mode = param[0].data.d_int32;
INIT_I18N();
gap_onion_dlg_init_default_values(gpp); /* init with default values */
/* get image_ID */
gpp->image_ID = param[1].data.d_image;
l_lock_image_id = gpp->image_ID;
/* ---------------------------
* check for LOCKS
* ---------------------------
*/
if(gap_lock_check_for_lock(l_lock_image_id, gpp->run_mode))
{
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
return ;
}
/* set LOCK on current image (for all gap_plugins) */
gap_lock_set_lock(l_lock_image_id);
/* get animinfo */
gap_onion_worker_plug_in_gap_get_animinfo(gpp->image_ID, &gpp->ainfo);
gap_onion_worker_get_data_onion_cfg(gpp); /* get current params (if there are any) */
gpp->vin.onionskin_auto_enable = TRUE;
gpp->cache.count = 0; /* start with empty image cache */
gpp->image_ID = param[1].data.d_image;
gpp->range_from = gpp->ainfo.curr_frame_nr;
gpp->range_to = gpp->ainfo.last_frame_nr;
if (strcmp (name, GAP_PLUGIN_NAME_ONION_CFG) == 0)
{
/* -----------------------
* CONFIG
* -----------------------
*/
if (gpp->run_mode == GIMP_RUN_NONINTERACTIVE)
{
if (n_params != nargs_onion_cfg)
{
values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
}
else
{
gpp->vin.num_olayers = param[3].data.d_int32;
gpp->vin.ref_delta = param[4].data.d_int32;
gpp->vin.ref_cycle = param[5].data.d_int32;
gpp->vin.stack_pos = param[6].data.d_int32;
gpp->vin.stack_top = param[7].data.d_int32;
gpp->vin.opacity = param[8].data.d_float;
gpp->vin.opacity_delta = param[9].data.d_float;
gpp->vin.ignore_botlayers = param[10].data.d_int32;
gpp->vin.select_mode = param[11].data.d_int32;
gpp->vin.select_case = param[12].data.d_int32;
gpp->vin.select_invert = param[13].data.d_int32;
if (param[14].data.d_string != NULL)
{
g_snprintf(&gpp->vin.select_string[0]
, sizeof(gpp->vin.select_string)
, "%s", param[14].data.d_string
);
}
gpp->range_from = param[15].data.d_int32;
gpp->range_to = param[16].data.d_int32;
gpp->run = param[17].data.d_int32;
gpp->vin.asc_opacity = param[18].data.d_int32;
gpp->vin.auto_replace_after_load = param[19].data.d_int32;
gpp->vin.auto_delete_before_save = param[20].data.d_int32;
gpp->vin.onionskin_auto_enable = TRUE;
gpp->vin.ref_mode = param[21].data.d_int32;
}
}
else if(gpp->run_mode != GIMP_RUN_INTERACTIVE)
{
values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
}
if (values[0].data.d_status == GIMP_PDB_SUCCESS)
{
if(gpp->run_mode == GIMP_RUN_INTERACTIVE)
{
l_rc = gap_onion_dlg_onion_cfg_dialog (gpp);
if(gap_debug) printf("MAIN after gap_onion_dlg_onion_cfg_dialog ------------------\n");
}
if (l_rc >= 0)
{
if(gpp->run != GAP_ONION_RUN_CANCEL)
{
/* disable both automatic onionskin triggers by disabling
* the master switch
* while applying onionskin to a range of frames.
* (this prevents from creating onionskins twice per image.
* automatic delete is also not done in that case because it makes no
* sense when the user explicitly wants to create onionskin layers
* in the processed range)
*/
gpp->vin.onionskin_auto_enable = FALSE;
l_rc = gap_onion_worker_set_data_onion_cfg(gpp, GAP_PLUGIN_NAME_ONION_CFG);
}
if((gpp->run == GAP_ONION_RUN_APPLY)
|| (gpp->run == GAP_ONION_RUN_DELETE))
{
/* do ONIONSKIN processing for all the frames in selected Range */
l_rc = gap_onion_worker_onion_range(gpp);
gpp->vin.onionskin_auto_enable = TRUE;
l_rc = gap_onion_worker_set_data_onion_cfg(gpp, GAP_PLUGIN_NAME_ONION_CFG);
}
}
}
}
else if (strcmp (name, GAP_PLUGIN_NAME_ONION_APPLY) == 0)
{
/* -----------------------
* MAKE
* -----------------------
* store params also with name GAP_PLUGIN_NAME_ONION_APPLY
* This makes it possible, to call this plugin as filter
* for a selected range of frames.
* (using plug_in_gap_modify and selecting plug_in_onionskin_make as filter)
*/
gap_onion_worker_set_data_onion_cfg(gpp, GAP_PLUGIN_NAME_ONION_APPLY);
l_rc = gap_onion_worker_onion_apply(gpp, FALSE /* do not use_cache */ );
}
else if (strcmp (name, GAP_PLUGIN_NAME_ONION_DEL) == 0)
{
/* -----------------------
* DEL
* -----------------------
*/
gap_onion_worker_set_data_onion_cfg(gpp, GAP_PLUGIN_NAME_ONION_DEL);
l_rc = gap_onion_worker_onion_delete(gpp);
}
else if (strcmp (name, GAP_PLUGIN_NAME_ONION_VISI) == 0)
{
/* -----------------------
* VISI
* -----------------------
*/
gint32 l_visi_mode;
l_visi_mode = GAP_ONION_VISI_TOGGLE; /* interactive mode always uses toggle */
if (gpp->run_mode == GIMP_RUN_NONINTERACTIVE)
{
if (n_params != nargs_onion_visi)
{
values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
}
else
{
l_visi_mode = param[3].data.d_int32;
}
}
if (values[0].data.d_status == GIMP_PDB_SUCCESS)
{
gap_onion_worker_set_data_onion_cfg(gpp, GAP_PLUGIN_NAME_ONION_VISI);
l_rc = gap_onion_worker_onion_visibility(gpp, l_visi_mode);
}
}
else
{
values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
}
if(l_rc < 0)
{
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
}
if (gpp->run_mode != GIMP_RUN_NONINTERACTIVE)
{
gimp_displays_flush();
}
/* remove LOCK on this image for all gap_plugins */
gap_lock_remove_lock(l_lock_image_id);
} /* end run */
|