RSS/Atom feed Twitter
Site is read-only, email is disabled

Problem refreshing GimpPreviewArea

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

8 of 8 messages available
Toggle history

Please log in to manage your subscriptions.

Problem refreshing GimpPreviewArea Nicolás Serrano Martínez Santos 06 May 18:58
  Problem refreshing GimpPreviewArea Sven Neumann 06 May 23:49
   Problem refreshing GimpPreviewArea Nicolás Serrano Martínez Santos 07 May 09:27
    Problem refreshing GimpPreviewArea Sven Neumann 08 May 13:45
     Problem refreshing GimpPreviewArea Nicolás Serrano Martínez Santos 09 May 11:45
      Problem refreshing GimpPreviewArea Sven Neumann 09 May 12:36
       Problem refreshing GimpPreviewArea Nicolás Serrano Martínez Santos 09 May 12:53
        Problem refreshing GimpPreviewArea Sven Neumann 09 May 13:06
Nicolás Serrano Martínez Santos
2008-05-06 18:58:55 UTC (over 16 years ago)

Problem refreshing GimpPreviewArea

Hi! I am using GimpPreviewArea to show previews in my plugin dialog. My problem is that when the size of area changes and i draw it. It doesn't refresh the contents but if I minimize the dialog and then show it again the area is refreshed.

I've tried to use gtk_widget_queue_draw_area but it doesn't work. Any idea?

Sven Neumann
2008-05-06 23:49:00 UTC (over 16 years ago)

Problem refreshing GimpPreviewArea

Hi,

On Tue, 2008-05-06 at 18:58 +0200, Nicolás Serrano Martínez Santos wrote:

Hi! I am using GimpPreviewArea to show previews in my plugin dialog. My problem is that when the size of area changes and i draw it. It doesn't refresh the contents but if I minimize the dialog and then show it again the area is refreshed.

Can you show us some example code?

Sven

Nicolás Serrano Martínez Santos
2008-05-07 09:27:37 UTC (over 16 years ago)

Problem refreshing GimpPreviewArea

Can you show us some example code?

Of course!

-----------------------------------------------------------

(When the plugin dialog appears it creates a layer that changes when you are changing the options. This layer has variable size and I use GimpDrawablePreview in order to see it at it's real size.

....

/* clear the current preview and get the new line adjusted drawable */ gimp_image_remove_layer(m->image_id,*(m->layer)); gimp_drawable_detach(*(m->d));
*(m->layer) = gimp_layer_copy(m->back_layer); gimp_image_add_layer(m->image_id,*(m->layer),-1); width = x2-x1; height = (y2-y1;
gimp_layer_resize(*(m->layer),width,height,-x1,-y1); d_id = gimp_image_get_active_drawable(m->image_id); *(m->d) = gimp_drawable_get(d_id);

refresh_preview((GimpPreviewArea *) m->preview,*(m->d)); }

void refresh_preview(GimpPreviewArea *p, GimpDrawable *d){ gint width, height; GimpPixelRgn rgn_input; guchar *buf;

width = gimp_drawable_width(d->drawable_id); height = gimp_drawable_height(d->drawable_id); buf = g_new(guchar,width*height*3); gimp_pixel_rgn_init (&rgn_input,
d,
0,0,
width, height, FALSE, FALSE); gimp_pixel_rgn_get_rect(&rgn_input,buf,0,0,width,height); gtk_widget_set_size_request((GtkWidget *) p,width,height); gimp_preview_area_draw(p,0,0,width, height,GIMP_RGB_IMAGE,buf,3*width); /* always RGB */ g_free(buf);
}
--------------------------------------

As I commented if the size of drawable shown changes it isn't refreshed. On the other hand if immediately after a layer of the same size is shown it's refreshed (or if you minimize the dialog window).

Sven Neumann
2008-05-08 13:45:09 UTC (over 16 years ago)

Problem refreshing GimpPreviewArea

Hi,

On Wed, 2008-05-07 at 09:27 +0200, Nicolás Serrano Martínez Santos wrote:

void refresh_preview(GimpPreviewArea *p, GimpDrawable *d){ gint width, height; GimpPixelRgn rgn_input; guchar *buf;

width = gimp_drawable_width(d->drawable_id); height = gimp_drawable_height(d->drawable_id); buf = g_new(guchar,width*height*3); gimp_pixel_rgn_init (&rgn_input,
d,
0,0,
width, height, FALSE, FALSE); gimp_pixel_rgn_get_rect(&rgn_input,buf,0,0,width,height); gtk_widget_set_size_request((GtkWidget *) p,width,height); gimp_preview_area_draw(p,0,0,width, height,GIMP_RGB_IMAGE,buf,3*width); /* always RGB */ g_free(buf);
}

That's a terribly inefficient way to doing things as you are allocating a large amount of memory here to draw everything in a single call instead of iterating over the drawable on a tile-by-tile basis (which is what GimpDrawablePreview is doing). But it should work. I don't see anything obviously wrong with this code. Perhaps you can make a simple test application that we can compile and use to reproduce your problem?

Sven

Nicolás Serrano Martínez Santos
2008-05-09 11:45:46 UTC (over 16 years ago)

Problem refreshing GimpPreviewArea

Please find attached a simple plugin which consist in a dialog showing a drawable. Where you can specify the width and height that will be shown.

This dialog does not refresh the GimpPreviewArea every time you click the spin. am I missing something??

? El 08/05/2008, a las 13:45, Sven Neumann escribió:

That's a terribly inefficient way to doing things as you are allocating
a large amount of memory here to draw everything in a single call instead of iterating over the drawable on a tile-by-tile basis (which is
what GimpDrawablePreview is doing). But it should work. I don't see anything obviously wrong with this code. Perhaps you can make a simple test application that we can compile and use to reproduce your problem?

Sven Neumann
2008-05-09 12:36:12 UTC (over 16 years ago)

Problem refreshing GimpPreviewArea

Hi,

On Fri, 2008-05-09 at 11:45 +0200, Nicolás Serrano Martínez Santos wrote:

Please find attached a simple plugin which consist in a dialog showing a drawable. Where you can specify the width and height that will be shown.

This dialog does not refresh the GimpPreviewArea every time you click the spin. am I missing something??

You need to redraw the preview-area everytime it's size changes. It doesn't keep the buffer across size changes. I have attached a modified version of your test code that does the right thing.

Sven

Nicolás Serrano Martínez Santos
2008-05-09 12:53:36 UTC (over 16 years ago)

Problem refreshing GimpPreviewArea

Thanks! Now it works as it will be expected. I didn't notice that signal in the API before...

El 09/05/2008, a las 12:36, Sven Neumann escribió:

You need to redraw the preview-area everytime it's size changes. It doesn't keep the buffer across size changes. I have attached a modified
version of your test code that does the right thing.

Sven Neumann
2008-05-09 13:06:57 UTC (over 16 years ago)

Problem refreshing GimpPreviewArea

Hi,

On Fri, 2008-05-09 at 12:53 +0200, Nicolás Serrano Martínez Santos wrote:

Thanks! Now it works as it will be expected. I didn't notice that signal in the API before...

GimpPreviewArea is derived from GtkDrawingArea. It inherits all functions and signals from its parent classes, including GtkWidget::size-allocate.

Sven