diff --git a/ChangeLog b/ChangeLog index a55770995b..5d2b8bdf5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2004-07-29 Sven Neumann + + * libgimpwidgets/Makefile.am + * libgimpwidgets/gimpwidgets.def + * libgimpwidgets/gimpwidgets.h + * libgimpwidgets/gimpwidgetstypes.h + * libgimpwidgets/gimppreviewarea.[ch]: added GimpPreviewArea, a + replacement for GtkPreview, loosely based on patches from Geert + Jordaens and David Odin. Fixes bug #144759. + + * plug-ins/common/sharpen.c: use the new widget instead of a + GtkPreview; saves about 100 lines of rather complex code :) + 2004-07-29 Michael Natterer * etc/controllerrc: changed default configuration of the keyboard diff --git a/devel-docs/libgimpwidgets/libgimpwidgets-docs.sgml b/devel-docs/libgimpwidgets/libgimpwidgets-docs.sgml index 1dde6a52e2..9a8108c408 100644 --- a/devel-docs/libgimpwidgets/libgimpwidgets-docs.sgml +++ b/devel-docs/libgimpwidgets/libgimpwidgets-docs.sgml @@ -36,6 +36,7 @@ + diff --git a/devel-docs/libgimpwidgets/libgimpwidgets-sections.txt b/devel-docs/libgimpwidgets/libgimpwidgets-sections.txt index 02009030a8..98e644609d 100644 --- a/devel-docs/libgimpwidgets/libgimpwidgets-sections.txt +++ b/devel-docs/libgimpwidgets/libgimpwidgets-sections.txt @@ -769,6 +769,24 @@ GIMP_IS_PICK_BUTTON_CLASS GIMP_PICK_BUTTON_GET_CLASS +
+gimppreviewarea +GimpPreviewArea +GimpPreviewArea +gimp_preview_area_new +gimp_preview_area_draw +gimp_preview_area_set_cmap + +GimpPreviewAreaClass +GIMP_PREVIEW_AREA +GIMP_IS_PREVIEW_AREA +GIMP_TYPE_PREVIEW_AREA +gimp_preview_area_get_type +GIMP_PREVIEW_AREA_CLASS +GIMP_IS_PREVIEW_AREA_CLASS +GIMP_PREVIEW_AREA_GET_CLASS +
+
gimpoldwidgets gimp_int_option_menu_new diff --git a/devel-docs/libgimpwidgets/libgimpwidgets.types b/devel-docs/libgimpwidgets/libgimpwidgets.types index 241fcd813e..e67996c8ee 100644 --- a/devel-docs/libgimpwidgets/libgimpwidgets.types +++ b/devel-docs/libgimpwidgets/libgimpwidgets.types @@ -29,5 +29,6 @@ gimp_offset_area_get_type gimp_path_editor_get_type gimp_pick_button_get_type gimp_pixmap_get_type +gimp_preview_area_get_type gimp_size_entry_get_type gimp_unit_menu_get_type diff --git a/devel-docs/libgimpwidgets/tmpl/gimpcellrenderercolor.sgml b/devel-docs/libgimpwidgets/tmpl/gimpcellrenderercolor.sgml index 20e34629fe..2a42bb2873 100644 --- a/devel-docs/libgimpwidgets/tmpl/gimpcellrenderercolor.sgml +++ b/devel-docs/libgimpwidgets/tmpl/gimpcellrenderercolor.sgml @@ -25,12 +25,12 @@ GimpCellRendererColor - + - + diff --git a/devel-docs/libgimpwidgets/tmpl/gimppreviewarea.sgml b/devel-docs/libgimpwidgets/tmpl/gimppreviewarea.sgml new file mode 100644 index 0000000000..2f3b12c4ee --- /dev/null +++ b/devel-docs/libgimpwidgets/tmpl/gimppreviewarea.sgml @@ -0,0 +1,57 @@ + +GimpPreviewArea + + + + + + + + + + + + + + + + + + + + + + + + + +@Returns: + + + + + + + +@area: +@x: +@y: +@width: +@height: +@type: +@buf: +@rowstride: + +@image_type: + + + + + + + +@area: +@cmap: +@num_colors: + + diff --git a/libgimpwidgets/Makefile.am b/libgimpwidgets/Makefile.am index 0bf141af5f..b23649bca2 100644 --- a/libgimpwidgets/Makefile.am +++ b/libgimpwidgets/Makefile.am @@ -118,6 +118,8 @@ libgimpwidgets_2_0_la_sources = \ gimppickbutton.h \ gimppixmap.c \ gimppixmap.h \ + gimppreviewarea.c \ + gimppreviewarea.h \ gimpquerybox.c \ gimpquerybox.h \ gimpsizeentry.c \ @@ -175,6 +177,7 @@ libgimpwidgetsinclude_HEADERS = \ gimppatheditor.h \ gimppickbutton.h \ gimppixmap.h \ + gimppreviewarea.h \ gimpquerybox.h \ gimpsizeentry.h \ gimpstock.h \ diff --git a/libgimpwidgets/gimppreviewarea.c b/libgimpwidgets/gimppreviewarea.c new file mode 100644 index 0000000000..a5611a4efa --- /dev/null +++ b/libgimpwidgets/gimppreviewarea.c @@ -0,0 +1,476 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include + +#include + +#include "libgimpbase/gimpbase.h" + +#include "gimpwidgetstypes.h" + +#include "gimppreviewarea.h" + + +#define CHECK_COLOR(row,col) \ + ((((row) & GIMP_CHECK_SIZE) ^ ((col) & GIMP_CHECK_SIZE)) ? \ + GIMP_CHECK_LIGHT * 255 : \ + GIMP_CHECK_DARK * 255) + + +static void gimp_preview_area_class_init (GimpPreviewAreaClass *klass); +static void gimp_preview_area_init (GimpPreviewArea *area); + +static void gimp_preview_area_finalize (GObject *object); + +static void gimp_preview_area_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); +static gboolean gimp_preview_area_expose (GtkWidget *widget, + GdkEventExpose *event); + + +static GtkDrawingAreaClass *parent_class = NULL; + + +GType +gimp_preview_area_get_type (void) +{ + static GType view_type = 0; + + if (! view_type) + { + static const GTypeInfo view_info = + { + sizeof (GimpPreviewAreaClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gimp_preview_area_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GimpPreviewArea), + 0, /* n_preallocs */ + (GInstanceInitFunc) gimp_preview_area_init, + }; + + view_type = g_type_register_static (GTK_TYPE_DRAWING_AREA, + "GimpPreviewArea", + &view_info, 0); + } + + return view_type; +} + +static void +gimp_preview_area_class_init (GimpPreviewAreaClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = gimp_preview_area_finalize; + + widget_class->size_allocate = gimp_preview_area_size_allocate; + widget_class->expose_event = gimp_preview_area_expose; +} + +static void +gimp_preview_area_init (GimpPreviewArea *area) +{ + area->buf = NULL; + area->cmap = NULL; + area->dither_x = 0; + area->dither_y = 0; + area->width = 0; + area->height = 0; + area->rowstride = 0; +} + +static void +gimp_preview_area_finalize (GObject *object) +{ + GimpPreviewArea *area = GIMP_PREVIEW_AREA (object); + + if (area->buf) + { + g_free (area->buf); + area->buf = NULL; + } + if (area->cmap) + { + g_free (area->cmap); + area->cmap = NULL; + } + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +gimp_preview_area_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GimpPreviewArea *area = GIMP_PREVIEW_AREA (widget); + + if (GTK_WIDGET_CLASS (parent_class)->size_allocate) + GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); + + if (widget->allocation.width != area->width || + widget->allocation.height != area->height) + { + area->width = widget->allocation.width; + area->height = widget->allocation.height; + + area->rowstride = ((area->width * 3) + 3) & ~3; + + if (area->buf) + g_free (area->buf); + + area->buf = g_new (guchar, area->rowstride * area->height); + } +} + +static gboolean +gimp_preview_area_expose (GtkWidget *widget, + GdkEventExpose *event) +{ + GimpPreviewArea *area; + guchar *buf; + + g_return_val_if_fail (GIMP_IS_PREVIEW_AREA (widget), FALSE); + + area = GIMP_PREVIEW_AREA (widget); + + if (! area->buf || ! GTK_WIDGET_DRAWABLE (widget)) + return FALSE; + + buf = area->buf + event->area.x + event->area.y * area->rowstride; + + gdk_draw_rgb_image_dithalign (widget->window, + widget->style->fg_gc[widget->state], + event->area.x, + event->area.y, + event->area.width, + event->area.height, + GDK_RGB_DITHER_MAX, + buf, + area->rowstride, + area->dither_x - event->area.x, + area->dither_y - event->area.y); + + return FALSE; +} + + +/** + * gimp_preview_area_new: + * + * Return value: a new #GimpPreviewArea widget. + * + * Since GIMP 2.2 + **/ +GtkWidget * +gimp_preview_area_new (void) +{ + return g_object_new (GIMP_TYPE_PREVIEW_AREA, NULL); +} + +/** + * gimp_preview_area_draw: + * @area: a #GimpPreviewArea widget. + * @x: x offset in preview + * @y: y offset in preview + * @width: buffer width + * @height: buffer height + * @type: the #GimpImageType of the pixels to draw + * @buf: a #guchar buffer that contains the preview pixel data. + * @rowstride: rowstride of buffer + * + * Draws @buf on @area and queues a redraw on the rectangle that + * changed. + * + * Since GIMP 2.2 + **/ +void +gimp_preview_area_draw (GimpPreviewArea *area, + gint x, + gint y, + gint width, + gint height, + GimpImageType type, + const guchar *buf, + gint rowstride) +{ + const guchar *src; + guchar *dest; + gint row; + gint col; + + g_return_if_fail (GIMP_IS_PREVIEW_AREA (area)); + g_return_if_fail (width > 0 && height > 0); + g_return_if_fail (buf != NULL); + g_return_if_fail (rowstride > 0); + + if (! area->buf) + return; + + if (x + width < 0 || x >= area->width) + return; + + if (y + height < 0 || y >= area->height) + return; + + if (x < 0) + { + gint bpp; + + switch (type) + { + case GIMP_GRAY_IMAGE: + case GIMP_INDEXED_IMAGE: + bpp = 1; + break; + case GIMP_GRAYA_IMAGE: + case GIMP_INDEXEDA_IMAGE: + bpp = 2; + break; + case GIMP_RGB_IMAGE: + bpp = 3; + break; + case GIMP_RGBA_IMAGE: + bpp = 4; + break; + default: + g_return_if_reached (); + break; + } + + buf += x * bpp; + width -= x; + x = 0; + } + + if (x + width > area->width) + width = area->width - x; + + if (y < 0) + { + buf += y * rowstride; + height -= y; + y = 0; + } + + if (y + height > area->height) + height = area->height - y; + + src = buf; + dest = area->buf + x * 3 + y * area->rowstride; + + switch (type) + { + case GIMP_RGB_IMAGE: + for (row = 0; row < height; row++) + { + memcpy (dest, src, 3 * width); + + src += rowstride; + dest += area->rowstride; + } + break; + + case GIMP_RGBA_IMAGE: + for (row = y; row < y + height; row++) + { + const guchar *s = src; + guchar *d = dest; + + for (col = x; col < x + width; col++, s += 4, d+= 3) + { + guchar check = CHECK_COLOR (row, col); + + switch (s[3]) + { + case 0: + d[0] = d[1] = d[2] = check; + break; + + case 255: + d[0] = s[0]; + d[1] = s[1]; + d[2] = s[2]; + break; + + default: + d[0] = check + (s[0] - check) * s[3] / 255; + d[1] = check + (s[1] - check) * s[3] / 255; + d[2] = check + (s[2] - check) * s[3] / 255; + break; + } + } + + src += rowstride; + dest += area->rowstride; + } + break; + + case GIMP_GRAY_IMAGE: + for (row = 0; row < height; row++) + { + const guchar *s = src; + guchar *d = dest; + + for (col = 0; col < width; col++, s++, d += 3) + { + d[0] = d[1] = d[3] = s[0]; + } + + src += rowstride; + dest += area->rowstride; + } + break; + + case GIMP_GRAYA_IMAGE: + for (row = y; row < y + height; row++) + { + const guchar *s = src; + guchar *d = dest; + + for (col = x; col < x + width; col++, s += 2, d+= 3) + { + guchar check = CHECK_COLOR (row, col); + + switch (s[1]) + { + case 0: + d[0] = d[1] = d[2] = check; + break; + + case 255: + d[0] = d[1] = d[2] = s[0]; + break; + + default: + d[0] = check + (s[0] - check) * s[1] / 255; + d[1] = d[2] = d[0]; + break; + } + } + + src += rowstride; + dest += area->rowstride; + } + break; + + case GIMP_INDEXED_IMAGE: + g_return_if_fail (area->cmap != NULL); + for (row = 0; row < height; row++) + { + const guchar *s = src; + guchar *d = dest; + + for (col = 0; col < width; col++, s++, d += 3) + { + const guchar *cmap = area->cmap + s[0]; + + d[0] = cmap[0]; + d[1] = cmap[1]; + d[2] = cmap[2]; + } + + src += rowstride; + dest += area->rowstride; + } + break; + + case GIMP_INDEXEDA_IMAGE: + g_return_if_fail (area->cmap != NULL); + for (row = y; row < y + height; row++) + { + const guchar *s = src; + guchar *d = dest; + + for (col = x; col < x + width; col++, s++, d += 3) + { + const guchar *cmap = area->cmap + s[0]; + guchar check = CHECK_COLOR (row, col); + + switch (s[1]) + { + case 0: + d[0] = d[1] = d[2] = check; + break; + + case 255: + d[0] = cmap[0]; + d[1] = cmap[1]; + d[2] = cmap[2]; + break; + + default: + d[0] = check + (cmap[0] - check) * s[1] / 255; + d[1] = check + (cmap[1] - check) * s[1] / 255; + d[2] = check + (cmap[2] - check) * s[1] / 255; + break; + } + } + + src += rowstride; + dest += area->rowstride; + } + break; + } + + gtk_widget_queue_draw_area (GTK_WIDGET (area), x, y, width, height); +} + +/** + * gimp_preview_area_set_cmap: + * @area: a #GimpPreviewArea + * @cmap: a #guchar buffer that contains the colormap + * @num_colors: the number of colors in the colormap + * + * Sets the colormap for the #GimpPreviewArea widget. You need to + * call this function before you use gimp_preview_area_draw() with + * an image type of %GIMP_INDEXED_IMAGE or %GIMP_INDEXEDA_IMAGE. + * + * Since GIMP 2.2 + **/ +void +gimp_preview_area_set_cmap (GimpPreviewArea *area, + const guchar *cmap, + gint num_colors) +{ + g_return_if_fail (GIMP_IS_PREVIEW_AREA (area)); + g_return_if_fail (cmap != NULL || num_colors == 0); + g_return_if_fail (num_colors < 0 || num_colors > 256); + + if (num_colors > 0) + { + if (! area->cmap) + area->cmap = g_new0 (guchar, 3 * 256); + + memcpy (area->cmap, cmap, 3 * num_colors); + } + else + { + g_free (area->cmap); + area->cmap = NULL; + } +} diff --git a/libgimpwidgets/gimppreviewarea.h b/libgimpwidgets/gimppreviewarea.h new file mode 100644 index 0000000000..72d7d038bc --- /dev/null +++ b/libgimpwidgets/gimppreviewarea.h @@ -0,0 +1,73 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GIMP_PREVIEW_AREA_H__ +#define __GIMP_PREVIEW_AREA_H__ + +#include + + +#define GIMP_TYPE_PREVIEW_AREA (gimp_preview_area_get_type ()) +#define GIMP_PREVIEW_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PREVIEW_AREA, GimpPreviewArea)) +#define GIMP_PREVIEW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PREVIEW_AREA, GimpPreviewAreaClass)) +#define GIMP_IS_PREVIEW_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PREVIEW_AREA)) +#define GIMP_IS_PREVIEW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PREVIEW_AREA)) +#define GIMP_PREVIEW_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PREVIEW_AREA, GimpPreviewArea)) + + +typedef struct _GimpPreviewAreaClass GimpPreviewAreaClass; + +struct _GimpPreviewArea +{ + GtkDrawingArea parent_instance; + + gint width; + gint height; + gint rowstride; + gint dither_x; + gint dither_y; + guchar *buf; + guchar *cmap; +}; + +struct _GimpPreviewAreaClass +{ + GtkDrawingAreaClass parent_class; +}; + + +GType gimp_preview_area_get_type (void) G_GNUC_CONST; + +GtkWidget * gimp_preview_area_new (void); + +void gimp_preview_area_draw (GimpPreviewArea *area, + gint x, + gint y, + gint width, + gint height, + GimpImageType type, + const guchar *buf, + gint rowstride); + +void gimp_preview_area_set_cmap (GimpPreviewArea *area, + const guchar *cmap, + gint num_colors); + + +#endif /* __GIMP_PREVIEW_AREA_H__ */ diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def index f93f1ec58e..057d11b623 100644 --- a/libgimpwidgets/gimpwidgets.def +++ b/libgimpwidgets/gimpwidgets.def @@ -149,6 +149,10 @@ EXPORTS gimp_pixmap_get_type gimp_pixmap_new gimp_pixmap_set + gimp_preview_area_draw + gimp_preview_area_get_type + gimp_preview_area_new + gimp_preview_area_set_cmap gimp_query_boolean_box gimp_query_double_box gimp_query_int_box diff --git a/libgimpwidgets/gimpwidgets.h b/libgimpwidgets/gimpwidgets.h index 8b6be665d8..c9f42206d5 100644 --- a/libgimpwidgets/gimpwidgets.h +++ b/libgimpwidgets/gimpwidgets.h @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include diff --git a/libgimpwidgets/gimpwidgetstypes.h b/libgimpwidgets/gimpwidgetstypes.h index d8622aaab8..eba01656fe 100644 --- a/libgimpwidgets/gimpwidgetstypes.h +++ b/libgimpwidgets/gimpwidgetstypes.h @@ -80,6 +80,7 @@ typedef struct _GimpMemsizeEntry GimpMemsizeEntry; typedef struct _GimpOffsetArea GimpOffsetArea; typedef struct _GimpPathEditor GimpPathEditor; typedef struct _GimpPickButton GimpPickButton; +typedef struct _GimpPreviewArea GimpPreviewArea; typedef struct _GimpPixmap GimpPixmap; typedef struct _GimpSizeEntry GimpSizeEntry; typedef struct _GimpUnitMenu GimpUnitMenu; diff --git a/plug-ins/common/sharpen.c b/plug-ins/common/sharpen.c index 089dde18de..f01d4f1b90 100644 --- a/plug-ins/common/sharpen.c +++ b/plug-ins/common/sharpen.c @@ -23,15 +23,8 @@ #include "config.h" -#include -#include #include -#ifdef __GNUC__ -#warning GTK_DISABLE_DEPRECATED -#endif -#undef GTK_DISABLE_DEPRECATED - #include #include @@ -101,6 +94,7 @@ GimpPlugInInfo PLUG_IN_INFO = static GtkWidget *preview; /* Preview widget */ static gint preview_width; /* Width of preview widget */ static gint preview_height; /* Height of preview widget */ +static gint preview_rowstride; /* Pitch of preview widget */ static gint preview_x1; /* Upper-left X of preview */ static gint preview_y1; /* Upper-left Y of preview */ static gint preview_x2; /* Lower-right X of preview */ @@ -108,7 +102,6 @@ static gint preview_y2; /* Lower-right Y of preview */ static guchar *preview_src; /* Source pixel image */ static intneg *preview_neg; /* Negative coefficient pixels */ static guchar *preview_dst; /* Destination pixel image */ -static guchar *preview_image; /* Preview RGB image */ static GtkObject *hscroll_data; /* Horizontal scrollbar data */ static GtkObject *vscroll_data; /* Vertical scrollbar data */ @@ -533,8 +526,8 @@ sharpen_dialog (void) preview_width = MIN (sel_width, PREVIEW_SIZE); preview_height = MIN (sel_height, PREVIEW_SIZE); - preview = gtk_preview_new (GTK_PREVIEW_COLOR); - gtk_preview_size (GTK_PREVIEW (preview), preview_width, preview_height); + preview = gimp_preview_area_new (); + gtk_widget_set_size_request (preview, preview_width, preview_height); gtk_container_add (GTK_CONTAINER (frame), preview); gtk_widget_show (preview); @@ -600,20 +593,17 @@ sharpen_dialog (void) static void preview_init (void) { - gint width; /* Byte width of the image */ - /* * Setup for preview filter... */ compute_luts(); - width = preview_width * img_bpp; + preview_rowstride = preview_width * img_bpp; - preview_src = g_new (guchar, width * preview_height); - preview_neg = g_new (intneg, width * preview_height); - preview_dst = g_new (guchar, width * preview_height); - preview_image = g_new (guchar, preview_width * preview_height * 3); + preview_src = g_new (guchar, preview_rowstride * preview_height); + preview_neg = g_new (intneg, preview_rowstride * preview_height); + preview_dst = g_new (guchar, preview_rowstride * preview_height); preview_x1 = sel_x1; preview_y1 = sel_y1; @@ -637,12 +627,10 @@ preview_update (void) { GimpPixelRgn src_rgn; /* Source image region */ guchar *src_ptr, /* Current source pixel */ - *dst_ptr, /* Current destination pixel */ - *image_ptr; /* Current image pixel */ + *dst_ptr; /* Current destination pixel */ intneg *neg_ptr; /* Current negative pixel */ - guchar check; /* Current check mark pixel */ gint i, /* Looping var */ - x, y, /* Current location in image */ + y, /* Current location in image */ width; /* Byte width of the image */ void (*filter)(int, guchar *, guchar *, intneg *, intneg *, intneg *); @@ -707,96 +695,11 @@ preview_update (void) (*filter)(preview_width, src_ptr, dst_ptr, neg_ptr - width, neg_ptr, neg_ptr + width); - /* - * Fill the preview image buffer... - */ - - switch (img_bpp) - { - case 1: - for (x = preview_width * preview_height, dst_ptr = preview_dst, - image_ptr = preview_image; - x > 0; - x --, dst_ptr ++, image_ptr += 3) - image_ptr[0] = image_ptr[1] = image_ptr[2] = *dst_ptr; - break; - - case 2: - for (y = preview_height, dst_ptr = preview_dst, - image_ptr = preview_image; - y > 0; - y --) - for (x = preview_width; - x > 0; - x --, dst_ptr += 2, image_ptr += 3) - if (dst_ptr[1] == 255) - image_ptr[0] = image_ptr[1] = image_ptr[2] = *dst_ptr; - else - { - if ((y & GIMP_CHECK_SIZE) ^ (x & GIMP_CHECK_SIZE)) - check = GIMP_CHECK_LIGHT * 255; - else - check = GIMP_CHECK_DARK * 255; - - if (dst_ptr[1] == 0) - image_ptr[0] = image_ptr[1] = image_ptr[2] = check; - else - image_ptr[0] = image_ptr[1] = image_ptr[2] = - check + ((dst_ptr[0] - check) * dst_ptr[1]) / 255; - }; - break; - - case 3: - memcpy (preview_image, preview_dst, preview_width * preview_height * 3); - break; - - case 4: - for (y = preview_height, dst_ptr = preview_dst, - image_ptr = preview_image; - y > 0; - y --) - for (x = preview_width; - x > 0; - x --, dst_ptr += 4, image_ptr += 3) - if (dst_ptr[3] == 255) - { - image_ptr[0] = dst_ptr[0]; - image_ptr[1] = dst_ptr[1]; - image_ptr[2] = dst_ptr[2]; - } - else - { - if ((y & GIMP_CHECK_SIZE) ^ (x & GIMP_CHECK_SIZE)) - check = GIMP_CHECK_LIGHT * 255; - else - check = GIMP_CHECK_DARK * 255; - - if (dst_ptr[3] == 0) - image_ptr[0] = image_ptr[1] = image_ptr[2] = check; - else - { - image_ptr[0] = - check + ((dst_ptr[0] - check) * dst_ptr[3]) / 255; - image_ptr[1] = - check + ((dst_ptr[1] - check) * dst_ptr[3]) / 255; - image_ptr[2] = - check + ((dst_ptr[2] - check) * dst_ptr[3]) / 255; - }; - }; - break; - }; - - /* - * Draw the preview image on the screen... - */ - - for (y = 0, image_ptr = preview_image; - y < preview_height; - y ++, image_ptr += preview_width * 3) - gtk_preview_draw_row (GTK_PREVIEW (preview), image_ptr, 0, y, - preview_width); - - gtk_widget_queue_draw (preview); + gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview), + 0, 0, preview_width, preview_height, + gimp_drawable_type (drawable->drawable_id), + preview_dst, + preview_rowstride); } static void @@ -805,7 +708,6 @@ preview_exit (void) g_free (preview_src); g_free (preview_neg); g_free (preview_dst); - g_free (preview_image); } /* dialog callbacks */