Re: [Gimp-developer] plug-in preview widget (another try)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think come up with a simple preview widget is the way to go. At least all people willing to
add preview's could start doing it the same way. 

What I've seen from plugin's is that they are frequently using pixel regions to render images.
If the pixel region isn't generic enough the I would start with the functionality described from the current tutorial on  the GimpPreview by Ernst which would be a little more work to implement in some plugin's.  Although I think you should be able to render a bigger
preview area than the displayed area.

Writing a callback for the preview

When the preview want the plug-in to render a new image it will call a callback function in your plug-in. In most cases you should be able to use the following:
static void
render_callback (GtkWidget * widget, GimpPreviewUpdateEvent * event,
                 gpointer data)
{
  GimpPreview *preview = GIMP_PREVIEW (widget);
  GimpDrawable *drawable = (GimpDrawable *) data;
  GimpDrawable *dest_drawable;
  GimpPreviewProgressUpdater preview_progress_updater;

  /* Get a scratch drawable */
  dest_drawable = gimp_preview_get_temp_drawable (drawable, event->image_x, event->image_y,
                                                  event->image_width, event->image_height);

  /* Initialize the GimpPreviewProgressUpdater */
  gimp_preview_progress_updater_init_for_preview (&preview_progress_updater, preview);
  /* Render to the scratch drawable */
  render (drawable, dest_drawable, event->image_x, event->image_y,
          event->image_width, event->image_height,
          &render_params,
          &preview_progress_updater);
  /* Draw the scratch drawable on the preview */
  gimp_preview_draw_unscaled_drawable (preview, dest_drawable);
  /* Delete the scratch drawable */
  gimp_preview_free_temp_drawable (dest_drawable);
}


[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux