1
1
/* LIBGIMP - The GIMP Library
2
2
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
4
* This library is free software; you can redistribute it and/or
4
* This library is free software: you can redistribute it and/or
5
5
* modify it under the terms of the GNU Lesser General Public
6
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
7
* version 3 of the License, or (at your option) any later version.
9
9
* This library is distributed in the hope that it will be useful,
10
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
* Lesser General Public License for more details.
14
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
15
* License along with this library. If not, see
16
* <http://www.gnu.org/licenses/>.
20
19
#include "config.h"
32
31
#include "libgimp/libgimp-intl.h"
35
* SECTION: gimppreviewarea
36
* @title: GimpPreviewArea
37
* @short_description: A general purpose preview widget which caches
40
* A general purpose preview widget which caches its pixel data.
221
230
GdkEventExpose *event)
223
232
GimpPreviewArea *area = GIMP_PREVIEW_AREA (widget);
233
GtkAllocation allocation;
224
235
GdkRectangle rect;
230
rect.x = (widget->allocation.width - area->width) / 2;
231
rect.y = (widget->allocation.height - area->height) / 2;
241
gtk_widget_get_allocation (widget, &allocation);
243
rect.x = (allocation.width - area->width) / 2;
244
rect.y = (allocation.height - area->height) / 2;
232
245
rect.width = area->width;
233
246
rect.height = area->height;
235
if (gdk_rectangle_intersect (&rect, &event->area, &render))
237
GtkStyle *style = gtk_widget_get_style (widget);
238
gint x = render.x - rect.x;
239
gint y = render.y - rect.y;
240
guchar *buf = area->buf + x * 3 + y * area->rowstride;
242
gdk_draw_rgb_image_dithalign (widget->window,
243
style->fg_gc[widget->state],
251
area->offset_x - render.x,
252
area->offset_y - render.y);
248
pixbuf = gdk_pixbuf_new_from_data (area->buf,
256
cr = gdk_cairo_create (gtk_widget_get_window (widget));
258
gdk_cairo_region (cr, event->region);
261
gdk_cairo_set_source_pixbuf (cr, pixbuf, rect.x, rect.y);
265
g_object_unref (pixbuf);
265
GtkWidget *widget = GTK_WIDGET (area);
267
x += (widget->allocation.width - area->width) / 2;
268
y += (widget->allocation.height - area->height) / 2;
277
GtkWidget *widget = GTK_WIDGET (area);
278
GtkAllocation allocation;
280
gtk_widget_get_allocation (widget, &allocation);
282
x += (allocation.width - area->width) / 2;
283
y += (allocation.height - area->height) / 2;
270
285
gtk_widget_queue_draw_area (widget, x, y, width, height);