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

Reply via email to