[Gimp-developer] Is ~30 seconds for 750 × 1200 pixels slow or fast?

2009-12-28 Thread Louise Hoffman
Dear developers,

I am now more or less finished with my plugin which draws spectrograms
from audio signals.

It takes about 30 seconds to draw 750 × 1200 pixels on my 3Ghz.

Is that slow or fast?

The code that does the drawing is this one:

  gboolean s;
  guint8 pixel[] = { 0x00 };

  double d;
  for (int n = 0; n  data-width; n++) {
for (int m = 0; m  data-height; m++) {
  /* make coef_db start from zero */
  d = (data-coef_db)[m+n*data-M] + data-coef_db_min;
  /* quantize so values are from 0 to 255 */
  /* The absolut value of min is added to max */
  pixel[0] = quantize(d, fabs(data-coef_db_min) + data-coef_db_max);
  /* set the pixel */
  /* coef_db have x=0,y=0 at buttom left corner and gimp have 0,0
at top left corner */
  s = gimp_drawable_set_pixel(data-layer, n, data-height - m, 1,
(guint8 *)pixel );
}
  }

  data-display = gimp_display_new(data-image);


...

/* quantize double to 8bit int */
unsigned char quantize(double d, double max) {
  return (unsigned char)((d / max) * 255.0);
}


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


Re: [Gimp-developer] Plugin that can open a drawable on screen. What am I doing wrong?

2009-12-27 Thread Louise Hoffman
 No you got an error. 0, or FALSE, means error which you can read in the
 documentation for the function:

 http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpdrawable.html#gimp-drawable-set-pixel

Now I see =) And now I get my red pixel as I wanted =)

  gboolean s;
  guint8 pixel[] = { 0xff, 0, 0, 0xff };
  s = gimp_drawable_set_pixel (layer, 5, 5, 4, (guint8 *)pixel );
  printf (Was the pixel set?: %i, s);

Full source at
http://pastebin.com/m35f95e3e

 There you can also read that the num_channels parameter shall be the The
 number of channels for the pixel.. You try to pass the number of bits, 24.
 Even that is wrong since you create the layer with an alpha channel, so the
 correct wrong thing to pass would be 32.

The thing is, what I would really like is to be able to plot 16bit
(doubles), but I can't figure out, how to put that in, when in my
case, pixel[], is guint8.

So if I set bpp to 32, and I have a 16bit value. How should I put that in?
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Plugin that can open a drawable on screen. What am I doing wrong?

2009-12-27 Thread Louise Hoffman
 I strongly suggest that you read the tutorial on developer.gimp.org
 then:

  http://developer.gimp.org/writing-a-plug-in/1/index.html

I read that one, and it was from that, I copied a lot of the code. I
was why I had all this pointer and structs at first =)

 and perhaps study the code of a plug-in that does something similar to
 what you want to achieve. Writing a plug-in without any idea of how the
 GIMP API works is not going to be a fun experience.

hehe =) Yes, it is pretty tough, but you guys have helped me out a
lot, so now I am very close to my goal =)

I guess the biggest problem right now is, how I plot a 16bit value.

Searching I find some that say GEGL will first be usable in GIMP 2.10.

Have you had any experience with plotting 16 bit (doubles)? Can it be done?
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


[Gimp-developer] Plugin that can open a drawable on screen. What am I doing wrong?

2009-12-26 Thread Louise Hoffman
Dear developers,

I am trying to make a GIMP plugin that can open a new drawable on the
screen. Just like when you make one from File-New.

It should be 800x600 24bit greyscale.

The code I have written is attached with Makefile.

When I select the plugin in GIMP I get these errors:

Calling error for procedure 'gimp-drawable-width': Procedure
'gimp-drawable-width' has been called with an invalid ID for argument
'drawable'. Most likely a plug-in is trying to work on a layer that
doesn't exist any longer.

Calling error for procedure 'gimp-drawable-height': Procedure
'gimp-drawable-height' has been called with an invalid ID for argument
'drawable'. Most likely a plug-in is trying to work on a layer that
doesn't exist any longer.

Calling error for procedure 'gimp-drawable-bpp': Procedure
'gimp-drawable-bpp' has been called with an invalid ID for argument
'drawable'. Most likely a plug-in is trying to work on a layer that
doesn't exist any longer.

Can someone see what's wrong?

Lots of love,
Louise
#include libgimp/gimp.h

typedef struct {
  gint32drawable_id;   /* drawable ID */
  guint width; /* width of drawble */
  guint height;/* height of drawble */
  guint bpp;   /* bytes per pixel of drawable */
  guint ntile_rows;/* # of tile rows */
  guint ntile_cols;/* # of tile columns */
  GimpTile *tiles; /* the normal tiles */
  GimpTile *shadow_tiles;  /* the shadow tiles */
} MyDrawable;

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...,
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);

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

static void
run (const gchar  *name,
 gint  nparams,
 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;

  /* Do I open a new drawable on the screen like this? */
  MyDrawable d;

  d.drawable_id = 0;
  d.width = 800;
  d.height = 600;
  d.bpp = 24;
  d.ntile_rows = 1;
  d.ntile_cols = 1;
  d.tiles = NULL;
  d.shadow_tiles = NULL;

  /* ??? */
  /*  Get the specified drawable  */
  drawable = gimp_drawable_get (param[2].data.d_drawable);

  if (run_mode != GIMP_RUN_NONINTERACTIVE)
g_message(Hello, world!\n);
}

GimpPlugInInfo PLUG_IN_INFO =
{
  NULL,
  NULL,
  query,
  run
};

MAIN()




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


Re: [Gimp-developer] Plugin that can open a drawable on screen. What am I doing wrong?

2009-12-26 Thread Louise Hoffman
 File-New creates a new image, not a new drawable.

Okay, I had that mixed up. A new image is really what I wanted then =)
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Plugin that can open a drawable on screen. What am I doing wrong?

2009-12-26 Thread Louise Hoffman
 You can't show a drawable by itself, it needs to be in an image. Also, an
 image can't show itself, you must create a display for that. You are also
 using the API in weird ways, for example, objects such as layers and images
 are represented by integers in the plug-in context.

 You are also saying that the plug-in takes the active image and drawable as
 parameter, but since you are creating a new image, you are not interested in
 those values (I assume) so there is no point in specifying these as
 arguments to the hello-world procedure.

This is my first attempt to write a GIMP plugin, as you probably have
guessed by now =)

 I have attached a rewritten version of main.c (called hello-world.c since
 that is a name that doesn't conflict as much) that should do what you want.
 You might also want to consider using a scripting language like Scheme or
 Python for this.

Wow. That's amazing. Thank you very much =)

What I ultimately would like to end up with is being able to set
pixels, the user makes changes to the image, and I read the pixels one
by one again.

So now I have tried to set a pixel like so


  /* Trying to set a pixel at x=5,y=5 with value 150 */
  GimpDrawable* drawable;
  drawable = gimp_drawable_get (layer);

  /* Trying to set a pixel at x=5,y=5 with value 150 in 24 bit color */
  gboolean s;
  s = gimp_drawable_set_pixel (drawable, 5, 5, 24, 150);


But when I compile I get:

hello-world.c:73: warning: passing argument 1 of
‘gimp_drawable_set_pixel’ makes integer from pointer without a cast
/usr/include/gimp-2.0/libgimp/gimpdrawable_pdb.h:89: note: expected
‘gint32’ but argument is of type ‘struct GimpDrawable *’


The code is attached. I am bit lost how to solve this.

Any help will be very appreciated =)
#include libgimp/gimp.h

static void
query (void)
{
  static GimpParamDef args[] =
  {
{
  GIMP_PDB_INT32,
  run-mode,
  Run mode
},
  };

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

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

static void
run (const gchar  *name,
 gint  nparams,
 const GimpParam  *param,
 gint *nreturn_vals,
 GimpParam   **return_vals)
{
  static GimpParam  values[1];
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;
  GimpRunMode   run_mode;
  gint32image;
  gint32layer;
  gint32display;

  /* 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;

  image = gimp_image_new (800, 600, GIMP_RGB);
  layer = gimp_layer_new (image,
  foo,
  800, 600,
  GIMP_RGBA_IMAGE,
  100.0,
  GIMP_NORMAL_MODE);
  gimp_image_add_layer (image, layer, 0);


  /* Trying to set a pixel at x=5,y=5 with value 150 */
  GimpDrawable* drawable;
  drawable = gimp_drawable_get (layer);

  /* Trying to set a pixel at x=5,y=5 with value 150 in 24 bit color */
  gboolean s;
  s = gimp_drawable_set_pixel (drawable, 5, 5, 24, 150);


  display = gimp_display_new (image);

  if (run_mode != GIMP_RUN_NONINTERACTIVE)
g_message(Hello, world!\n);
}

GimpPlugInInfo PLUG_IN_INFO =
{
  NULL,
  NULL,
  query,
  run
};

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


Re: [Gimp-developer] Plugin that can open a drawable on screen. What am I doing wrong?

2009-12-26 Thread Louise Hoffman
 Your invocation of 'gimp_install_procedure' specifies NULL for the
 image_type. This is probably what you want -- you don't need an image
 opened in order to create a new image -- but this means that you
 shouldn't be using GIMP_PDB_IMAGE and GIMP_PDB_DRAWABLE in your
 GimpParamDef (if there is no image open when you execute the plug-in,
 those parameters can't be provided).

 As a side note, I don't understand why you define your own
 'MyDrawable' struct when it is identical to the GimpDrawable struct
 already available.

I thought that was how a new image was created =)
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Plugin that can open a drawable on screen. What am I doing wrong?

2009-12-26 Thread Louise Hoffman
 As I said, in the plug-in context layers (and drawables) are identified by
 integers, not pointers. Looks like you try to use a struct pointer again.

 Plug-ins run in their own process and thus pointer-passing doesn't work.

Sorry about that.

Now I don't get any errors, but I don't see the pixel either...

  /* Trying to set a pixel at x=5,y=5 with value 150 in 24 bit color */
  const guint8 *pixel;
  pixel = (guint8 *) 150;
  gboolean s;
  s = gimp_drawable_set_pixel (layer, 5, 5, 24, pixel);
  printf (Was the pixel set?: %i, s);

and s returns 0.

Is it how I define the pixel value that is the problem?


The hello-world.c is here with my change
http://pastebin.com/m39f62a20
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Force gimp reload plugins?

2009-10-25 Thread Louise Hoffman
[snip]

Dear David and Sven

Thanks so much. That will speed up the development a lot =)

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


[Gimp-developer] Force gimp reload plugins?

2009-10-24 Thread Louise Hoffman
Dear developers

Is there a quick way to test (my) plugin when I just have compiled it?

What I do right now is:
* compile
* su
* make install
* quit gimp
* start gimp

and it takes forever.

Is there a quicker way? E.g. a way to force gimp to reload the plugins? =)

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


[Gimp-developer] Can I have tabs and Apply button in the plugin GUI?

2009-09-28 Thread Louise Hoffman
Dear developers,

Can someone tell if this GUI design is possible?

http://pastebin.com/m1ccbcd06

The reason I would like to have tabs is because of the work flow, and
the values in the Modify tab will be different depending to the loaded
audio[0] file.

If tabs is possible, can I also have the Apply button?

And if so, will the Apply button apply changes to all tabs or just the
active tab?

Hugs,
Louise





[0] The user loads audio files, and the plugin convert it to
graphics/spectrogram.
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Can I have tabs and Apply button in the plugin GUI?

2009-09-28 Thread Louise Hoffman
 Yes it's possible, you can create any GTK+ interface in plug-ins.
 To get tabs you'd use GtkNotebook. You can hook any code to an
 Apply button, including code that takes the active tab into
 account.

Hi Martin,

Thank you very much for the detailed answer. That is just perfect =)

Can I ask another question?

Right now when I start GIMP, all plugins can not be opened, because
there is no canvas. Once the user have defined an image size in
File-New all the plugins become available.

Is it possible that my plugin can be opened without a canvas?

The reason for this is, that it would be very convenient if the user
could set image size in the plugin, and once the user presses Apply,
GIMP creates the canvas.

Can that be done? And if so, do you have a link to the API's that
allow me to do that?

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


Re: [Gimp-developer] Can I have tabs and Apply button in the plugin GUI?

2009-09-28 Thread Louise Hoffman
 Yes, just pass NULL to the image_type argument to gimp_install_procedure() [1]
 That's how file plug-ins and plug-ins under File - Create for example is
 able to run without any image opened.

That's much better than I expected =)

I will start on that tomorrow.

Thanks a lot =)

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