[Gimp-developer] calling a procedure in a plugin
Aurimas Juška
aurimas.juska at gmail.com
Thu Oct 18 03:06:54 PDT 2007
gimp_run_procedure() is not properly terminated with GIMP_PDB_END (see
documentation). Again, as Sven said, use c wrappers if they are
available for procedure that you need.
On 10/18/07, Giuseppe Pasquino <giuseppepasquino at hotmail.com> wrote:
>
> Thanks to all for the useful help... I'll write this function but it return
> a fatal error (SEGMENTATION FAULT) and it don't make the selection...
> Here is the code:
>
> static void evidenzia (GimpDrawable *drawable, GimpPreview *preview)
> {
> gint width, height; //dell'immagine su cui va applicato il plugin
> gint altezza, larghezza; //numero di pixel formanti la palette
> gint x1, x2, y1, y2;
> GimpPixelRgn rgn_in, rgn_out;
> guchar pixel[4];
> guchar colore[3];
> gint i, channels;
> gint distanza;
> GimpParam *return_vals;
> gint nreturn_vals;
>
> if (preview) return;
> else gimp_progress_init ("Evidenzia Temperatura...");
> //Recupero del drawable
> gimp_drawable_mask_bounds (drawable->drawable_id,
> &x1, &y1,
> &x2, &y2);
> width = x2 - x1;
> height = y2 - y1;
> /* Inizializza due PixelRgns, uno per leggere i dati originali,
> * e l'altro per scrivere i dati modificati. Il secondo sarÃ
> * poi applicato all'immaginne alla fine attraverso la chiamata
> * gimp_drawable_merge_shadow() */
> gimp_pixel_rgn_init (&rgn_in,
> drawable,
> x1, y1,
> width, height,
> FALSE, FALSE);
> gimp_pixel_rgn_init (&rgn_out,
> drawable,
> x1, y1,
> width, height,
> preview == NULL, TRUE);
> //Recupero del numero di canali
> channels = gimp_drawable_bpp (drawable->drawable_id);
>
> //Calcolo delle dimensioni della palette
> altezza = termogramma.palettey2 - termogramma.palettey1;
> larghezza = termogramma.palettex2 - termogramma.palettex1;
> /*
> * Se l'altezza è più grande della larghezza allora vuol dire che la
> palette è disposta in verticale.
> * Se succede il contrario allora la palette è disposta in
> orizzontale
> */
> if(altezza > larghezza) {
> //g_print("1\n"); <- for debug purpose
> //Ottengo il colore alla temperatura specificata. Lo faccio
> facendo una media tra tutti i colori che si trovano sulla stessa riga
> distanza = (termogramma.tempselezionata -
> termogramma.tempmin) * altezza / (termogramma.tempmax -
> termogramma.tempmin);
> //Ottengo il pixel corrispondente (coordinate x1 + (x2 -
> x1)/2, (y2 - distanza))
> gimp_pixel_rgn_get_pixel(&rgn_in, pixel,
> termogramma.palettex1 + (termogramma.palettex2 - termogramma.palettex1)/2,
> termogramma.palettey2 - distanza);
> g_print("%i, %i", termogramma.palettex1 +
> (termogramma.palettex2 - termogramma.palettex1)/2, termogramma.palettey2 -
> distanza);
> }
> else {//larghezza > altezza
> //g_print("2\n"); debug
> distanza = (termogramma.tempselezionata -
> termogramma.tempmin) * larghezza / (termogramma.tempmax -
> termogramma.tempmin);
> //Ottengo il pixel corrispondete (coordinate (x1 +
> distanza), y1 + (y2 - y1)/2)
> gimp_pixel_rgn_get_pixel(&rgn_in, pixel,
> termogramma.palettex1 + distanza, termogramma.palettey1 +
> (termogramma.palettey2 - termogramma.palettey1)/2);
> //g_print("%i, %i", termogramma.palettex1 + distanza,
> termogramma.palettey1 + (termogramma.palettey2 - termogramma.palettey1)/2);
> debug
> }
> for(i = 0; i < 3; i++) colore[i] = pixel[i];
> return_vals =
> gimp_run_procedure("gimp_by_color_select",
> &nreturn_vals,
> GIMP_PDB_DRAWABLE,
> drawable, //drawable
> GIMP_PDB_COLOR,
> colore, //color
> GIMP_PDB_INT32,
> termogramma.scarto, //threshold
> GIMP_PDB_INT32, 2,
> //operation
> GIMP_PDB_INT32, 0,
> //antialiasing
> GIMP_PDB_INT32, 0,
> GIMP_PDB_INT32, 0,
> GIMP_PDB_FLOAT,
> 0.0,
> GIMP_PDB_INT32,
> 0);
>
> }
>
> What's wrong with this code?
>
> ________________________________
> Sfida i tuoi amici in entusiasmanti sfide con i giochi di Messenger!
> Messenger Giochi
> _______________________________________________
> Gimp-developer mailing list
> Gimp-developer at lists.XCF.Berkeley.EDU
> https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
>
>
More information about the Gimp-developer
mailing list