Re: Problem refreshing GimpPreviewArea

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

 



>
> 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).


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

[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