« Gimp filters » : différence entre les versions

De Banane Atomic
Aller à la navigationAller à la recherche
 
Aucun résumé des modifications
 
Ligne 1 : Ligne 1 :
[[Category:Logiciels]]
= Liens =
= Liens =
* [http://developer.gimp.org/writing-a-plug-in/1/ How to write a GIMP plug-in]
* [http://developer.gimp.org/writing-a-plug-in/1/ How to write a GIMP plug-in]
Ligne 111 : Ligne 112 :
     if (run_mode != GIMP_RUN_NONINTERACTIVE)
     if (run_mode != GIMP_RUN_NONINTERACTIVE)
</kode>
</kode>
{| class="wikitable wtp"  
{| class="wikitable wtp"  
! Titre colonne 1
! Titre colonne 1
Ligne 121 : Ligne 123 :
| GIMP_RUN_WITH_LAST_VALS || plug-in was executed from the "Repeat last filter" menu entry
| GIMP_RUN_WITH_LAST_VALS || plug-in was executed from the "Repeat last filter" menu entry
|}
|}
[[Category:Logiciels]]

Dernière version du 6 avril 2020 à 20:40

Liens

Template

Bash.svg
# installation du plugin / filtre
gimptool-2.0 --install mon_filtre.c
# un exécutable sera créé dans ~/.gimp-2.8/plug-ins
mon_filtre.c
#include <libgimp/gimp.h>


/*  Local function prototypes  */
static void query (void);
static void run   (
    const gchar         *name,
    gint                nparams,
    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   */
};

MAIN ()

static void query (void)
{
    static GimpParamDef args[] = {
        { GIMP_PDB_INT32,       "run-mode", "Run mode"          },
        { GIMP_PDB_IMAGE,       "image",    "Input image"       },
        { GIMP_PDB_DRAWABLE,    "drawable", "Input drawable"    }
    };

    gimp_install_procedure (
        "plug-in-hello",
        "Hello, world!",
        "Displays \"Hello, world!\" in a dialog",
        "David Neary",
        "Copyright David Neary",
        "2004",
        "_Hello world...",
        //"RGB*, GRAY*",
        "RGB*, GRAY*, INDEXED*",
        GIMP_PLUGIN,
        G_N_ELEMENTS (args), 0,
        args, NULL);

    //gimp_plugin_menu_register ("plug-in-hello", "/Filters/Misc");
    gimp_plugin_menu_register ("plug-in-hello", "<Image>/Filters/Misc/");
}

static void run (
    const gchar      *name,
    gint              n_params,
    const GimpParam  *param,
    gint             *nreturn_vals,
    GimpParam       **return_vals)
{
    static GimpParam  values[1];
    GimpPDBStatusType status = GIMP_PDB_SUCCESS;
    GimpRunMode       run_mode;
    GimpDrawable     *drawable;

    /* Setting mandatory output values */
    *nreturn_vals = 1;
    *return_vals  = values;

    values[0].type = GIMP_PDB_STATUS;
    values[0].data.d_status = status;

    /* Getting run_mode - we won't display a dialog if we are in NONINTERACTIVE mode */
    run_mode = param[0].data.d_int32;

    if (run_mode != GIMP_RUN_NONINTERACTIVE)
      g_message("Hello, world!\n");
    
    /*  Get the specified drawable  */
    drawable = gimp_drawable_get (param[2].data.d_drawable);

    gimp_progress_init ("Modification de l'image...");
    /* appel d'une fonction qui contient le code qui va modifier l'image */
    modification (drawable);

    gimp_displays_flush ();
    gimp_drawable_detach (drawable);
}

run mode

C.svg
static void run (
    const gchar      *name,
    gint              n_params,
    const GimpParam  *param,
    gint             *nreturn_vals,
    GimpParam       **return_vals)
{
    /* Getting run_mode */
    run_mode = param[0].data.d_int32;

    /* test si l'utilisateur a exécuté le filtre */
    if (run_mode != GIMP_RUN_NONINTERACTIVE)
Titre colonne 1 Titre colonne 2
GIMP_RUN_INTERACTIVE plug-in was executed from The GIMP
GIMP_RUN_NONINTERACTIVE plug-in was executed from a script
GIMP_RUN_WITH_LAST_VALS plug-in was executed from the "Repeat last filter" menu entry