Re: [Gimp-developer] calling a procedure in a plugin

2007-10-19 Thread Giuseppe Pasquino

Thanks to all... Now it's work...

 You are attempting to modify a color at some random memory location, that's 
 never been allocated (you didn't initialize colore) and then  you passed 
 this  dodgy pointer to gimp_by_color_select. In most parts of the GIMP, 
 GimpRGB are statically allocated, and you see that they are used more like 
 this:
GimpRGB colore;
GimpChannelOps parametri; 
gboolean success; 
gimp_rgb_set_uchar(colore, pixel[0], pixel[1], pixel[2]); 
parametri = GIMP_CHANNEL_OP_REPLACE; 
success = gimp_by_color_select(drawable-drawable_id, 
colore, 
termogramma.scarto, 
parametri, 
FALSE, 
FALSE, 
0.0, 
FALSE);

_
Conosci Doretta? Contattala, è ora su Messenger!
http://www.doretta82.it/banner/index.html
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] calling a procedure in a plugin

2007-10-19 Thread Giuseppe Pasquino

I have modified the code as you suggested:

GimpRGB *colore;
GimpChannelOps parametri;
gboolean success;
gimp_rgb_set_uchar(colore, pixel[0], pixel[1], pixel[2]);
parametri = GIMP_CHANNEL_OP_REPLACE;
success = gimp_by_color_select(drawable-drawable_id,
   colore,
   termogramma.scarto,
   parametri,
   FALSE,
   FALSE,
   0.0,
   FALSE);

The compiler returns me no error but when I execute the gimp return a fatal 
error: segmentation fault. I think the problem is in one of this line but, 
with my few experience, I can't find it...
 Hi, 
 I think I already pointed you to the API reference for GimpRGB and 
 gimp_rgb_set_uchar() in particular. GimpChannelOps is an enum and the
 possible values are listed in the API reference. Just follow the link.
 You can also save yourself the hassle of working with pixel regions if
 all you want to do is to get the color of a single pixel. There's 
 gimp_drawable_get_pixel() for that purpose.
 Sven

_
Crea i tuoi biglietti da visita con Windows Live Messenger!
http://www.messenger.it/biglietti_da_visita.html
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] calling a procedure in a plugin

2007-10-19 Thread David Gowers
On 10/19/07, Giuseppe Pasquino [EMAIL PROTECTED] wrote:

 I have modified the code as you suggested:

 GimpRGB *colore;
 GimpChannelOps parametri;
 gboolean success;
 gimp_rgb_set_uchar(colore, pixel[0], pixel[1], pixel[2]);
 parametri = GIMP_CHANNEL_OP_REPLACE;
 success = gimp_by_color_select(drawable-drawable_id,
colore,
termogramma.scarto,
parametri,
FALSE,
FALSE,
0.0,
FALSE);

 The compiler returns me no error but when I execute the gimp return a fatal 
 error: segmentation fault. I think the problem is in one of this line but, 
 with my few experience, I can't find it...

You are attempting to modify a color at some random memory location,
that's never been allocated (you didn't initialize colore) -- and then
you passed this dodgy pointer to gimp_by_color_select.

In most parts of the GIMP, GimpRGB are statically allocated, and you
see that they are used more like this:


 GimpRGB colore;
 GimpChannelOps parametri;
 gboolean success;
 gimp_rgb_set_uchar(colore, pixel[0], pixel[1], pixel[2]);
 parametri = GIMP_CHANNEL_OP_REPLACE;
 success = gimp_by_color_select(drawable-drawable_id,
colore,
termogramma.scarto,
parametri,
FALSE,
FALSE,
0.0,
FALSE);
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] calling a procedure in a plugin

2007-10-18 Thread Giuseppe Pasquino
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 plugingint 
altezza, larghezza; //numero di pixel formanti la palettegint 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 drawablegimp_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 canalichannels = gimp_drawable_bpp 
(drawable-drawable_id);//Calcolo delle dimensioni della 
palettealtezza = 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 rigadistanza = 
(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); debugdistanza = (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?
_
Crea i tuoi biglietti da visita con Windows Live Messenger!
http://www.messenger.it/biglietti_da_visita.html___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] calling a procedure in a plugin

2007-10-18 Thread Aurimas Juška
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 [EMAIL PROTECTED] 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@lists.XCF.Berkeley.EDU
 

Re: [Gimp-developer] calling a procedure in a plugin

2007-10-18 Thread Giuseppe Pasquino

Ok, I'll modify the plugin in this way:
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;
gboolean success;

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);
//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\n, termogramma.palettex1 + 
(termogramma.palettex2 - termogramma.palettex1)/2, termogramma.palettey2 - 
distanza);
}
else {//larghezza altezza
g_print(2\n);
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\n, termogramma.palettex1 + distanza, 
termogramma.palettey1 + (termogramma.palettey2 - termogramma.palettey1)/2);
}
for(i = 0; i  3; i++) {
colore[i] = pixel[i];
g_print(%i ,colore[i]);
}
return_vals = gimp_run_procedure (gimp-by-color-select,
  nreturn_vals,
  GIMP_PDB_DRAWABLE, 
drawable-drawable_id,
  GIMP_PDB_COLOR, pixel,
  GIMP_PDB_INT32, termogramma.scarto,
  GIMP_PDB_INT32, 2,
  GIMP_PDB_INT32, FALSE,
  GIMP_PDB_INT32, FALSE,
  GIMP_PDB_FLOAT, 0.0,
  GIMP_PDB_INT32, FALSE,
  GIMP_PDB_END);

success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
//si distruggono i parametri per liberare la memoria
gimp_destroy_params (return_vals, nreturn_vals);
if(success) g_print(Fatto\n);


}
 
the variable success is TRUE after calling the procedure but it select every 
black pixel instead the values contained in the colori vector. It' is a bug 
or I'm make some mistakes?

_
Crea i tuoi biglietti da visita con Windows Live Messenger!
http://www.messenger.it/biglietti_da_visita.html
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU

Re: [Gimp-developer] calling a procedure in a plugin

2007-10-18 Thread Sven Neumann
Hi,

why don't you just do what we suggested? If you would use
gimp_by_color_select() instead of gimp_run_procedure(), the compiler
would be able to tell you that your code is buggy.


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] calling a procedure in a plugin

2007-10-18 Thread Giuseppe Pasquino

Because I have problem converting the guchar vector for the color in GimpRGB 
and I don't know how manage with GimpChannelOps...
Can you write me down an example?
 Subject: RE: RE: [Gimp-developer] 
calling a procedure in a plugin From: [EMAIL PROTECTED] To: [EMAIL 
PROTECTED] CC: gimp-developer@lists.xcf.berkeley.edu Date: Thu, 18 Oct 2007 
14:32:05 +0200 Hi, why don't you just do what we suggested? If you would 
use gimp_by_color_select() instead of gimp_run_procedure(), the compiler 
would be able to tell you that your code is buggy. Sven

_
Scarica GRATIS le emoticon della tua squadra del cuore e il calendario di serie 
A!
http://www.emoticons-livemessenger.com/pages/msnitcalcio/index.htm
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] calling a procedure in a plugin

2007-10-18 Thread Sven Neumann
Hi,

On Thu, 2007-10-18 at 15:05 +0200, Giuseppe Pasquino wrote:
 Because I have problem converting the guchar vector for the color in
 GimpRGB and I don't know how manage with GimpChannelOps...

I think I already pointed you to the API reference for GimpRGB and
gimp_rgb_set_uchar() in particular. GimpChannelOps is an enum and the
possible values are listed in the API reference. Just follow the link.

You can also save yourself the hassle of working with pixel regions if
all you want to do is to get the color of a single pixel. There's 
gimp_drawable_get_pixel() for that purpose.


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] calling a procedure in a plugin

2007-10-17 Thread Sven Neumann
Hi,

On Tue, 2007-10-16 at 13:04 +0200, Giuseppe Pasquino wrote:

 after few operations, it picks a color from the image (with che
 function gimp_pixel_rgn_get_pixel) to get the guchar value of the
 components of the related color.
 At this point, I need to call the gimp_by_color_select procedure

Just use the C wrapper. Have a look at the API reference manual, it's
all nicely documented:
http://developer.gimp.org/api/2.0/libgimp/libgimp-gimptools.html#id2678685

 How do I  manage the guchar values to convert in GimpRGB?

http://developer.gimp.org/api/2.0/libgimpcolor/libgimpcolor-GimpRGB.html#gimp-rgb-set-uchar


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] calling a procedure in a plugin

2007-10-17 Thread Sven Neumann
Hi,

On Tue, 2007-10-16 at 17:02 +0300, Aurimas Juška wrote:
 http://developer.gimp.org/api/2.0/libgimp/libgimp-gimp.html#gimp-run-procedure
 
 Procedure parameters:
 http://www.goof.com/pcg/marc/pdb/gimp_by_color_select.html

Thanks for your attempt to help. But please don't point people to the
outdated PDB documentation at Marc's website. It hasn't been updated for
ages and we have a nice API reference manual online at
http://developer.gimp.org/.


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] calling a procedure in a plugin

2007-10-16 Thread Aurimas Juška
http://developer.gimp.org/api/2.0/libgimp/libgimp-gimp.html#gimp-run-procedure

Procedure parameters:
http://www.goof.com/pcg/marc/pdb/gimp_by_color_select.html

But it is generally easier to lookup params in procedure browser.

On 10/16/07, Giuseppe Pasquino [EMAIL PROTECTED] wrote:

 Hello, I'm working on this plugin:
 after few operations, it picks a color from the image (with che function
 gimp_pixel_rgn_get_pixel) to get the guchar value of the components of the
 related color.
 At this point, I need to call the gimp_by_color_select procedure but I'm
 not sure to follow the right way... Anyone can help me?
 How do I  manage the guchar values to convert in GimpRGB?

 Thanks a lot to all and sorry for my bad English (I'm italian)...

 Giuseppe.

 
 Con Windows Live Messenger condividi file senza limiti di peso! Windows Live
 Messenger
 ___
 Gimp-developer mailing list
 Gimp-developer@lists.XCF.Berkeley.EDU
 https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] calling a procedure in a plugin

2007-10-16 Thread Giuseppe Pasquino
Thanks for your help... I have another question: how can I convert a guchar 
value taken by gimp_pixel_rgn_get_pixel to COLOR?

 Date: Tue, 16 Oct 2007 17:02:15 +0300 From: [EMAIL PROTECTED] To: [EMAIL 
 PROTECTED] Subject: Re: [Gimp-developer] calling a procedure in a plugin 
 CC: gimp-developer@lists.xcf.berkeley.edu  
 http://developer.gimp.org/api/2.0/libgimp/libgimp-gimp.html#gimp-run-procedure
   Procedure parameters: 
 http://www.goof.com/pcg/marc/pdb/gimp_by_color_select.html  But it is 
 generally easier to lookup params in procedure browser.
_
Conosci Doretta? Contattala, è ora su Messenger!
http://www.doretta82.it/banner/index.html___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer