Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update resynthesizer heal selection plugin to work with recent 2.99 release #136

Open
wants to merge 8 commits into
base: deprecations
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
385 changes: 238 additions & 147 deletions PluginScripts/plugin-heal-selection.py
100644 → 100755

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/resynth-parameters.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ to the adapter from Gimp to the innermost engine.
!!! v2
*/
#if GIMP_MAJOR_VERSION == 2 && GIMP_MINOR_VERSION < 99


typedef struct GIMPAdapterParametersStructOld {

int h_tile;
Expand Down Expand Up @@ -281,6 +284,6 @@ set_parameters_to_list(
}
}


#endif


4 changes: 3 additions & 1 deletion src/resynthesizer-gui/resynth-gui.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@
#include "../resynthesizer/pluginParams.h"
#include "../resynth-parameters.h"

#if GIMP_MAJOR_VERSION == 2 && GIMP_MINOR_VERSION < 99

/* Resynthesizer GUI gtk code: ask user for parameters. */
#include "resynth-gui.h"


static void run(
const gchar * name,
gint nparams, // !!! Always 3 for INTERACTIVE, not lengthof(param)?
Expand Down Expand Up @@ -182,3 +183,4 @@ static GimpPlugInInfo PLUG_IN_INFO = {
/* Macro to define the usual plugin main function */
MAIN()

#endif
Empty file modified src/resynthesizer-gui/resynth-gui.h
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions src/resynthesizer/debug.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
void
debug(const char * message)
{
g_printerr(message);
g_printerr("\n");
g_warning(message);
g_warning("\n");
}
4 changes: 2 additions & 2 deletions src/resynthesizer/drawable.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


// hacky test that version is less than 2.99.xx
#if GIMP_MINOR_VERSION < 99
#if GIMP_MINOR_VERSION < 99 && GIMP_MAJOR_VERSION == 2


gint bpp (GimpDrawable *d) { return d->bpp; }
Expand Down Expand Up @@ -142,7 +142,7 @@ get_selection(GimpDrawable * d)
// selection is a new drawable derived from image of a drawable
// TODO this is not right for v3 ??
// return gimp_image_get_selection(gimp_item_get_image(d->drawable_id));
return gimp_image_get_selection(gimp_item_get_image(d));
return (GimpDrawable *) gimp_image_get_selection(gimp_item_get_image((GimpItem *)d));
}

gboolean
Expand Down
28 changes: 15 additions & 13 deletions src/resynthesizer/pluginParams.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


// hacky test that version is less than 2.99.xx
#if GIMP_MINOR_VERSION < 99
#if GIMP_MAJOR_VERSION == 2 && GIMP_MINOR_VERSION < 99


// in v2 gimp API, params are array of GimpParam
Expand Down Expand Up @@ -83,24 +83,26 @@ CRUFT

gboolean
get_engine_specific_parameters(
GimpValueArray *args, // IN
GimpProcedureConfig *args, // IN
TGimpAdapterParameters *pluginParameters) // OUT
{
// Fails to compile:
// g_assert( args->length() == 10 );

// args does not have prefix: run mode, image, drawable
pluginParameters->h_tile = GIMP_VALUES_GET_BOOLEAN (args, 0);
// debug("here");
pluginParameters->v_tile = GIMP_VALUES_GET_BOOLEAN (args, 1);
pluginParameters->use_border = GIMP_VALUES_GET_INT (args, 2);
pluginParameters->corpus = GIMP_VALUES_GET_DRAWABLE (args, 3);
pluginParameters->input_map = GIMP_VALUES_GET_DRAWABLE (args, 4);
pluginParameters->output_map = GIMP_VALUES_GET_DRAWABLE (args, 5);
pluginParameters->map_weight = GIMP_VALUES_GET_DOUBLE (args, 6);
pluginParameters->autism = GIMP_VALUES_GET_DOUBLE (args, 7);
pluginParameters->neighbours = GIMP_VALUES_GET_INT (args, 8);
pluginParameters->trys = GIMP_VALUES_GET_INT (args, 9);
g_object_get(
args,
"h-tile", &pluginParameters->h_tile,
"v-tile", &pluginParameters->v_tile,
"use-border", &pluginParameters->use_border,
"corpus-drawable", &pluginParameters->corpus,
"input-map", &pluginParameters->input_map,
"output-map", &pluginParameters->output_map,
"map-weight", &pluginParameters->map_weight,
"autism", &pluginParameters->autism,
"neighbours", &pluginParameters->neighbours,
"trys", &pluginParameters->trys);

return TRUE;
}

Expand Down
4 changes: 2 additions & 2 deletions src/resynthesizer/pluginParams.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ typedef struct GIMPAdapterParametersStruct {



#if GIMP_MINOR_VERSION < 99
#if GIMP_MAJOR_VERSION == 2 && GIMP_MINOR_VERSION < 99



Expand All @@ -50,7 +50,7 @@ get_engine_specific_parameters(

gboolean
get_engine_specific_parameters(
GimpValueArray *args, // IN // <<<<<
GimpProcedureConfig *args, // IN // <<<<<
TGimpAdapterParameters *pluginParameters); // OUT


Expand Down
35 changes: 19 additions & 16 deletions src/resynthesizer/resynthPDBv3.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ static GimpProcedure * resynthesizer_create_procedure (GimpPlugIn *pl
static GimpValueArray * resynthesizer_run (GimpProcedure *procedure,
GimpRunMode run_mode,
GimpImage *image,
GimpDrawable *drawable,
const GimpValueArray *args,
GimpDrawable **drawables,
GimpProcedureConfig *args,
gpointer run_data);


Expand Down Expand Up @@ -138,52 +138,52 @@ resynthesizer_create_procedure (GimpPlugIn *plug_in,
"Lloyd Konneker",
"2021");

GIMP_PROC_ARG_BOOLEAN (procedure, "h_tile",
gimp_procedure_add_boolean_argument (procedure, "h_tile",
"Create image tileable horizontally?",
"Boolean",
FALSE,
G_PARAM_READWRITE);
GIMP_PROC_ARG_BOOLEAN (procedure, "v_tile",
gimp_procedure_add_boolean_argument (procedure, "v_tile",
"Create image tileable vertically?",
"Boolean",
FALSE,
G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "use_border",
gimp_procedure_add_int_argument (procedure, "use_border",
"Enumerated order/directions of synthesis",
"See documents.",
0, 100, 1, // TODO what is the real range
G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "corpus_drawable",
gimp_procedure_add_drawable_argument (procedure, "corpus_drawable",
"Image to search",
"Usually the surroundings of target.",
TRUE,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "input_map",
gimp_procedure_add_drawable_argument (procedure, "input_map",
"Map of weightings for target.",
"Same size as target.",
TRUE,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "output_map",
gimp_procedure_add_drawable_argument (procedure, "output_map",
"Map of weightings for corpus.",
"Same size as corpus.",
TRUE,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "map_weight",
gimp_procedure_add_double_argument (procedure, "map_weight",
"Weighting for any in and out maps",
"How much to use maps while matching.",
0.0, 1.0, 0.5,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "autism",
gimp_procedure_add_double_argument (procedure, "autism",
"Sensitivity to outliers of distance measure",
"Parameter of distance measure",
0.0, 1.0, 0.117,
G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "neighbours",
gimp_procedure_add_int_argument (procedure, "neighbours",
"Count of pixels in a patch",
"More is high quality but slow",
1, 100, 9,
G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "trys",
gimp_procedure_add_int_argument (procedure, "trys",
"Max search probes per pass",
"More is high quality but slow",
1, 10000, 200,
Expand All @@ -204,7 +204,7 @@ resynthesizer_create_procedure (GimpPlugIn *plug_in,
static GError *
new_gerror_for_resynthesizer_and_string(const char * msg)
{
GQuark * domain = g_quark_from_string("Resynthesizer");
GQuark domain = g_quark_from_string("Resynthesizer");
return g_error_new_literal(domain, 0, msg);
}

Expand All @@ -222,10 +222,11 @@ resynthesizer_run (
GimpProcedure *procedure,
GimpRunMode run_mode,
GimpImage *image,
GimpDrawable *drawable,
const GimpValueArray *args,
GimpDrawable **drawables,
GimpProcedureConfig *args,
gpointer run_data)
{
GimpDrawable *drawable = drawables[0];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
const char *result; // inner result
const gchar *name = gimp_procedure_get_name (procedure);
Expand All @@ -235,7 +236,9 @@ resynthesizer_run (

// if (! strcmp (name, RECOMPOSE_PROC)) return foo

if ( ! get_engine_specific_parameters(args, &pluginParameters) )
if (drawable == NULL) {
result = _("Resynthesizer didn't get an image.");
} else if ( ! get_engine_specific_parameters(args, &pluginParameters) )
result = _("Resynthesizer failed to get parameters.");
else
result = inner_run(
Expand Down
1 change: 0 additions & 1 deletion src/resynthesizer/resynthesizer.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ inner_run(

#ifdef DEBUG
gimp_message_set_handler(1); // To console instead of GUI
start_time = clock();
#endif

// internationalization i18n
Expand Down