mirror of https://github.com/GNOME/gimp.git
Moved a lot of generic preview code to the new files gimpmiscui.[ch] so it will be easier later to port these plug-ins to the new (not yet finished) effect preview widget.
This commit is contained in:
parent
8513998e5c
commit
978e0f76f1
16
ChangeLog
16
ChangeLog
|
@ -18,6 +18,22 @@
|
|||
* libgimpwidgets/gimpdatafiles.c: s/S_ISLINK/S_ISNLK/ (was never
|
||||
compiled before Hans fixed the #ifdef).
|
||||
|
||||
2002-11-30 Maurits Rijk <lpeek.mrijk@consunet.nl>
|
||||
|
||||
* plug-ins/common/flarefx.c:
|
||||
* plug-ins/common/jigsaw.c:
|
||||
* plug-ins/common/nova.c
|
||||
* plug-ins/common/wind.c
|
||||
* plug-ins/common/illusion.c
|
||||
* plug-ins/common/glasstile.c
|
||||
* plug-ins/common/max_rgb.c: replace preview code by calls to libgimp
|
||||
|
||||
* libgimp/Makefile.am: added gimpmiscui.[ch]
|
||||
* libgimp/gimpmiscui.[ch]: new files. For now contain effect preview
|
||||
stuff collected from several plug-ins. Warning: this is NOT the new
|
||||
effect preview widget I'm writing, just a first step to cleaning up a
|
||||
lot of plug-ins.
|
||||
|
||||
2002-11-30 Hans Breuer <hans@breuer.org>
|
||||
|
||||
* */makefile.msc */*/makefile.msc : updated
|
||||
|
|
|
@ -134,6 +134,8 @@ libgimpui_1_3_la_SOURCES = \
|
|||
gimpuitypes.h \
|
||||
gimpmenu.c \
|
||||
gimpmenu.h \
|
||||
gimpmiscui.c \
|
||||
gimpmiscui.h \
|
||||
gimpbrushmenu.c \
|
||||
gimpgradientmenu.c \
|
||||
gimppatternmenu.c \
|
||||
|
@ -157,6 +159,7 @@ gimpinclude_HEADERS = \
|
|||
gimptile.h \
|
||||
gimpexport.h \
|
||||
gimpintl.h \
|
||||
gimpmiscui.h \
|
||||
gimpui.h \
|
||||
gimpuitypes.h \
|
||||
gimpmenu.h
|
||||
|
|
|
@ -268,8 +268,8 @@ typedef enum
|
|||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_PIXELS,
|
||||
GIMP_POINTS
|
||||
GIMP_SIZE_PIXELS,
|
||||
GIMP_SIZE_POINTS
|
||||
} GimpSizeType;
|
||||
|
||||
|
||||
|
|
|
@ -27,9 +27,17 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpmisc.h"
|
||||
|
||||
GimpPixelFetcher *
|
||||
gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
||||
|
|
|
@ -0,0 +1,237 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpmiscui.c
|
||||
* Contains all kinds of miscellaneous routines factored out from different
|
||||
* plug-ins. They stay here until their API has crystalized a bit and we can
|
||||
* put them into the file where they belong (Maurits Rijk
|
||||
* <lpeek.mrijk@consunet.nl> if you want to blame someone for this mess)
|
||||
*
|
||||
* 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
|
||||
* Library 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.
|
||||
*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpmiscui.h"
|
||||
|
||||
#define PREVIEW_SIZE 128
|
||||
|
||||
GimpFixMePreview*
|
||||
gimp_fixme_preview_new (GimpDrawable *drawable)
|
||||
{
|
||||
GimpFixMePreview *preview = g_new (GimpFixMePreview, 1);
|
||||
|
||||
preview->widget = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
|
||||
if (drawable)
|
||||
gimp_fixme_preview_fill_with_thumb (preview, drawable->drawable_id);
|
||||
|
||||
return preview;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_fixme_preview_free (GimpFixMePreview *preview)
|
||||
{
|
||||
g_free (preview->even);
|
||||
g_free (preview->odd);
|
||||
g_free (preview->cache);
|
||||
g_free (preview);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_fixme_preview_do_row (GimpFixMePreview *preview,
|
||||
gint row,
|
||||
gint width,
|
||||
guchar *src)
|
||||
{
|
||||
gint x;
|
||||
guchar *p0 = preview->even;
|
||||
guchar *p1 = preview->odd;
|
||||
gdouble r, g, b, a;
|
||||
gdouble c0, c1;
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
switch (preview->bpp)
|
||||
{
|
||||
case 4:
|
||||
r = ((gdouble) src[x*4]) / 255.0;
|
||||
g = ((gdouble) src[x*4 + 1]) / 255.0;
|
||||
b = ((gdouble) src[x*4 + 2]) / 255.0;
|
||||
a = ((gdouble) src[x*4 + 3]) / 255.0;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
r = ((gdouble) src[x*3]) / 255.0;
|
||||
g = ((gdouble) src[x*3 + 1]) / 255.0;
|
||||
b = ((gdouble) src[x*3 + 2]) / 255.0;
|
||||
a = 1.0;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
r = ((gdouble)src[x*2]) / 255.0;
|
||||
g = b = r;
|
||||
a = ((gdouble)src[x*2 + 1]) / 255.0;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
r = ((gdouble)src[x*2]) / 255.0;
|
||||
g = b = r;
|
||||
a = 1.0;
|
||||
break;
|
||||
|
||||
default:
|
||||
r = g = b = a = 1.0; /* just to please the compiler */
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
if ((x / GIMP_CHECK_SIZE_SM) & 1)
|
||||
{
|
||||
c0 = GIMP_CHECK_LIGHT;
|
||||
c1 = GIMP_CHECK_DARK;
|
||||
}
|
||||
else
|
||||
{
|
||||
c0 = GIMP_CHECK_DARK;
|
||||
c1 = GIMP_CHECK_LIGHT;
|
||||
}
|
||||
|
||||
*p0++ = (c0 + (r - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (g - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (b - c0) * a) * 255.0;
|
||||
|
||||
*p1++ = (c1 + (r - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (g - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (b - c1) * a) * 255.0;
|
||||
}
|
||||
|
||||
if ((row / GIMP_CHECK_SIZE_SM) & 1)
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview->widget),
|
||||
(guchar *) preview->odd, 0, row, width);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview->widget),
|
||||
(guchar *) preview->even, 0, row, width);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_fixme_preview_fill_with_thumb (GimpFixMePreview *preview,
|
||||
gint32 drawable_ID)
|
||||
{
|
||||
gint bpp;
|
||||
gint y;
|
||||
gint width = PREVIEW_SIZE;
|
||||
gint height = PREVIEW_SIZE;
|
||||
guchar *src;
|
||||
|
||||
preview->cache =
|
||||
gimp_drawable_get_thumbnail_data (drawable_ID, &width, &height, &bpp);
|
||||
|
||||
if (width < 1 || height < 1)
|
||||
return;
|
||||
|
||||
preview->rowstride = width * bpp;
|
||||
preview->bpp = bpp;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (preview->widget), width, height);
|
||||
|
||||
preview->scale_x =
|
||||
(gdouble) width / (gdouble) gimp_drawable_width (drawable_ID);
|
||||
preview->scale_y =
|
||||
(gdouble) height / (gdouble) gimp_drawable_height (drawable_ID);
|
||||
|
||||
src = preview->cache;
|
||||
preview->even = g_malloc (width * 3);
|
||||
preview->odd = g_malloc (width * 3);
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
gimp_fixme_preview_do_row (preview, y, width, src);
|
||||
src += width * bpp;
|
||||
}
|
||||
|
||||
preview->buffer = GTK_PREVIEW (preview->widget)->buffer;
|
||||
preview->width = GTK_PREVIEW (preview->widget)->buffer_width;
|
||||
preview->height = GTK_PREVIEW (preview->widget)->buffer_height;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_fixme_preview_fill (GimpFixMePreview *preview,
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
GimpPixelRgn srcPR;
|
||||
gint width;
|
||||
gint height;
|
||||
gint x1, x2, y1, y2;
|
||||
gint bpp;
|
||||
gint y;
|
||||
guchar *src;
|
||||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||
|
||||
if (x2 - x1 > PREVIEW_SIZE)
|
||||
x2 = x1 + PREVIEW_SIZE;
|
||||
|
||||
if (y2 - y1 > PREVIEW_SIZE)
|
||||
y2 = y1 + PREVIEW_SIZE;
|
||||
|
||||
width = x2 - x1;
|
||||
height = y2 - y1;
|
||||
bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (preview->widget), width, height);
|
||||
|
||||
gimp_pixel_rgn_init (&srcPR, drawable, x1, y1, x2, y2, FALSE, FALSE);
|
||||
|
||||
preview->even = g_malloc (width * 3);
|
||||
preview->odd = g_malloc (width * 3);
|
||||
src = g_malloc (width * bpp);
|
||||
preview->cache = g_malloc(width * bpp * height);
|
||||
preview->rowstride = width * bpp;
|
||||
preview->bpp = bpp;
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
gimp_pixel_rgn_get_row (&srcPR, src, x1, y + y1, width);
|
||||
memcpy(preview->cache + (y * width * bpp), src, width * bpp);
|
||||
}
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
gimp_fixme_preview_do_row(preview, y, width,
|
||||
preview->cache + (y * width * bpp));
|
||||
}
|
||||
|
||||
preview->buffer = GTK_PREVIEW (preview->widget)->buffer;
|
||||
preview->width = GTK_PREVIEW (preview->widget)->buffer_width;
|
||||
preview->height = GTK_PREVIEW (preview->widget)->buffer_height;
|
||||
|
||||
g_free (src);
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpmiscui.h
|
||||
* Contains all kinds of miscellaneous routines factored out from different
|
||||
* plug-ins. They stay here until their API has crystalized a bit and we can
|
||||
* put them into the file where they belong (Maurits Rijk
|
||||
* <lpeek.mrijk@consunet.nl> if you want to blame someone for this mess)
|
||||
*
|
||||
* 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_MISCUI_H__
|
||||
#define __GIMP_MISCUI_H__
|
||||
|
||||
#include <libgimp/gimptypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
/* Preview stuff. WARNING: don't use this in new code!!!!!!!
|
||||
* It's just here to extract some general preview stuff from plug-ins so
|
||||
* that it will be easier to change them when we have a real effect preview
|
||||
* widget.
|
||||
* Don't say I didn't warn you (Maurits).
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
GtkWidget *widget;
|
||||
guchar *cache;
|
||||
guchar *even;
|
||||
guchar *odd;
|
||||
guchar *buffer;
|
||||
gint width;
|
||||
gint height;
|
||||
gint rowstride;
|
||||
gint bpp;
|
||||
gdouble scale_x;
|
||||
gdouble scale_y;
|
||||
} GimpFixMePreview;
|
||||
|
||||
GimpFixMePreview *gimp_fixme_preview_new (GimpDrawable *drawable);
|
||||
void gimp_fixme_preview_free (GimpFixMePreview *preview);
|
||||
void gimp_fixme_preview_fill_with_thumb (GimpFixMePreview *preview,
|
||||
gint32 drawable_ID);
|
||||
void gimp_fixme_preview_fill (GimpFixMePreview *preview,
|
||||
GimpDrawable *drawable);
|
||||
void gimp_fixme_preview_do_row (GimpFixMePreview *preview,
|
||||
gint row,
|
||||
gint width,
|
||||
guchar *src);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_MISCUI_H__ */
|
|
@ -27,9 +27,17 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpmisc.h"
|
||||
|
||||
GimpPixelFetcher *
|
||||
gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
||||
|
|
|
@ -27,9 +27,17 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpmisc.h"
|
||||
|
||||
GimpPixelFetcher *
|
||||
gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <libgimp/gimpexport.h>
|
||||
#include <libgimp/gimpmenu.h>
|
||||
#include <libgimp/gimpmiscui.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
|
@ -49,11 +49,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -64,7 +59,6 @@
|
|||
|
||||
/* --- Defines --- */
|
||||
#define ENTRY_WIDTH 75
|
||||
#define PREVIEW_SIZE 128
|
||||
#define PREVIEW_MASK (GDK_EXPOSURE_MASK | \
|
||||
GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK)
|
||||
|
@ -73,15 +67,6 @@
|
|||
#define CURSOR 0x2
|
||||
#define ALL 0xf
|
||||
|
||||
#if 0
|
||||
#define DEBUG1 printf
|
||||
#else
|
||||
#define DEBUG1 dummy_printf
|
||||
static void
|
||||
dummy_printf (gchar *fmt, ...) {}
|
||||
#endif
|
||||
|
||||
|
||||
/* --- Typedefs --- */
|
||||
typedef struct
|
||||
{
|
||||
|
@ -134,10 +119,6 @@ static void run (gchar *name,
|
|||
|
||||
static void FlareFX (GimpDrawable *drawable,
|
||||
gint preview_mode);
|
||||
static void fill_preview_with_thumb (GtkWidget *preview_widget,
|
||||
gint32 drawable_ID);
|
||||
static GtkWidget *preview_widget (GimpDrawable *drawable);
|
||||
|
||||
static gint flare_dialog (GimpDrawable *drawable);
|
||||
static void flare_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
@ -192,10 +173,7 @@ static gint xs, ys;
|
|||
static gint numref;
|
||||
static RGBfloat color, glow, inner, outer, halo;
|
||||
static Reflect ref1[19];
|
||||
static guchar *preview_bits;
|
||||
static GtkWidget *preview;
|
||||
static gdouble preview_scale_x;
|
||||
static gdouble preview_scale_y;
|
||||
static GimpFixMePreview *preview;
|
||||
static gboolean show_cursor = FALSE;
|
||||
|
||||
/* --- Functions --- */
|
||||
|
@ -305,7 +283,6 @@ run (gchar *name,
|
|||
/* Store data */
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||
gimp_set_data ("plug_in_flarefx", &fvals, sizeof (FlareValues));
|
||||
g_free(preview_bits);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -396,12 +373,12 @@ FlareFX (GimpDrawable *drawable,
|
|||
|
||||
if (preview_mode)
|
||||
{
|
||||
width = GTK_PREVIEW (preview)->buffer_width;
|
||||
height = GTK_PREVIEW (preview)->buffer_height;
|
||||
bytes = GTK_PREVIEW (preview)->bpp;
|
||||
width = preview->width;
|
||||
height = preview->height;
|
||||
bytes = preview->bpp;
|
||||
|
||||
xs = (gdouble)fvals.posx * preview_scale_x;
|
||||
ys = (gdouble)fvals.posy * preview_scale_y;
|
||||
xs = (gdouble)fvals.posx * preview->scale_x;
|
||||
ys = (gdouble)fvals.posy * preview->scale_y;
|
||||
|
||||
x1 = y1 = 0;
|
||||
x2 = width;
|
||||
|
@ -422,8 +399,8 @@ FlareFX (GimpDrawable *drawable,
|
|||
|
||||
if (preview_mode)
|
||||
{
|
||||
cur_row = g_new (guchar, GTK_PREVIEW (preview)->rowstride);
|
||||
dest = g_new (guchar, GTK_PREVIEW (preview)->rowstride);
|
||||
cur_row = g_new (guchar, preview->rowstride);
|
||||
dest = g_new (guchar, preview->rowstride);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -454,8 +431,8 @@ FlareFX (GimpDrawable *drawable,
|
|||
{
|
||||
if (preview_mode)
|
||||
memcpy (cur_row,
|
||||
preview_bits + GTK_PREVIEW (preview)->rowstride * row,
|
||||
GTK_PREVIEW (preview)->rowstride);
|
||||
preview->cache + preview->rowstride * row,
|
||||
preview->rowstride);
|
||||
else
|
||||
gimp_pixel_rgn_get_row (&srcPR, cur_row, x1, row, x2-x1);
|
||||
|
||||
|
@ -491,9 +468,8 @@ FlareFX (GimpDrawable *drawable,
|
|||
}
|
||||
if (preview_mode)
|
||||
{
|
||||
memcpy (GTK_PREVIEW (preview)->buffer + GTK_PREVIEW (preview)->rowstride * row,
|
||||
cur_row,
|
||||
GTK_PREVIEW (preview)->rowstride);
|
||||
memcpy (preview->buffer + preview->rowstride * row, cur_row,
|
||||
preview->rowstride);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -507,7 +483,7 @@ FlareFX (GimpDrawable *drawable,
|
|||
|
||||
if (preview_mode)
|
||||
{
|
||||
gtk_widget_queue_draw (preview);
|
||||
gtk_widget_queue_draw (preview->widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -839,17 +815,17 @@ flare_center_create (GimpDrawable *drawable)
|
|||
gtk_table_attach (GTK_TABLE (table), pframe, 0, 4, 1, 2, 0, 0, 0, 0);
|
||||
|
||||
/* PREVIEW */
|
||||
preview = preview_widget (drawable);
|
||||
gtk_widget_set_events (GTK_WIDGET (preview), PREVIEW_MASK);
|
||||
gtk_container_add (GTK_CONTAINER (pframe), preview);
|
||||
gtk_widget_show (preview);
|
||||
preview = gimp_fixme_preview_new (drawable);
|
||||
gtk_widget_set_events (GTK_WIDGET (preview->widget), PREVIEW_MASK);
|
||||
gtk_container_add (GTK_CONTAINER (pframe), preview->widget);
|
||||
gtk_widget_show (preview->widget);
|
||||
|
||||
g_object_set_data (G_OBJECT (preview), "center", center);
|
||||
g_object_set_data (G_OBJECT (preview->widget), "center", center);
|
||||
|
||||
g_signal_connect_after (G_OBJECT (preview), "expose_event",
|
||||
g_signal_connect_after (G_OBJECT (preview->widget), "expose_event",
|
||||
G_CALLBACK (flare_center_preview_expose),
|
||||
center);
|
||||
g_signal_connect (G_OBJECT (preview), "event",
|
||||
g_signal_connect (G_OBJECT (preview->widget), "event",
|
||||
G_CALLBACK (flare_center_preview_events),
|
||||
center);
|
||||
|
||||
|
@ -879,9 +855,6 @@ flare_center_create (GimpDrawable *drawable)
|
|||
|
||||
FlareFX (drawable, TRUE);
|
||||
|
||||
DEBUG1 ("fvals center=%d,%d\n", fvals.posx, fvals.posy);
|
||||
DEBUG1 ("center cur=%d,%d\n", center->curx, center->cury);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
@ -893,125 +866,6 @@ flare_center_destroy (GtkWidget *widget,
|
|||
g_free (center);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize preview
|
||||
* Draw the contents into the internal buffer of the preview widget
|
||||
*/
|
||||
|
||||
static GtkWidget *
|
||||
preview_widget (GimpDrawable *drawable)
|
||||
{
|
||||
GtkWidget *preview;
|
||||
gint size;
|
||||
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
fill_preview_with_thumb (preview, drawable->drawable_id);
|
||||
size = GTK_PREVIEW (preview)->rowstride * GTK_PREVIEW (preview)->buffer_height;
|
||||
preview_bits = g_malloc (size);
|
||||
memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size);
|
||||
|
||||
return preview;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_preview_with_thumb (GtkWidget *widget,
|
||||
gint32 drawable_ID)
|
||||
{
|
||||
guchar *drawable_data;
|
||||
gint bpp;
|
||||
gint x,y;
|
||||
gint width = PREVIEW_SIZE;
|
||||
gint height = PREVIEW_SIZE;
|
||||
guchar *src;
|
||||
gdouble r, g, b, a;
|
||||
gdouble c0, c1;
|
||||
guchar *p0, *p1;
|
||||
guchar *even, *odd;
|
||||
|
||||
bpp = 0; /* Only returned */
|
||||
|
||||
drawable_data =
|
||||
gimp_drawable_get_thumbnail_data (drawable_ID, &width, &height, &bpp);
|
||||
|
||||
if (width < 1 || height < 1)
|
||||
return;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (widget), width, height);
|
||||
preview_scale_x = (gdouble)width / (gdouble)gimp_drawable_width (drawable_ID);
|
||||
preview_scale_y = (gdouble)height / (gdouble)gimp_drawable_height (drawable_ID);
|
||||
|
||||
even = g_malloc (width * 3);
|
||||
odd = g_malloc (width * 3);
|
||||
src = drawable_data;
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
p0 = even;
|
||||
p1 = odd;
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
if (bpp == 4)
|
||||
{
|
||||
r = ((gdouble)src[x*4+0]) / 255.0;
|
||||
g = ((gdouble)src[x*4+1]) / 255.0;
|
||||
b = ((gdouble)src[x*4+2]) / 255.0;
|
||||
a = ((gdouble)src[x*4+3]) / 255.0;
|
||||
}
|
||||
else if (bpp == 3)
|
||||
{
|
||||
r = ((gdouble)src[x*3+0]) / 255.0;
|
||||
g = ((gdouble)src[x*3+1]) / 255.0;
|
||||
b = ((gdouble)src[x*3+2]) / 255.0;
|
||||
a = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = ((gdouble)src[x*bpp+0]) / 255.0;
|
||||
g = b = r;
|
||||
if(bpp == 2)
|
||||
a = ((gdouble)src[x*bpp+1]) / 255.0;
|
||||
else
|
||||
a = 1.0;
|
||||
}
|
||||
|
||||
if ((x / GIMP_CHECK_SIZE_SM) & 1)
|
||||
{
|
||||
c0 = GIMP_CHECK_LIGHT;
|
||||
c1 = GIMP_CHECK_DARK;
|
||||
}
|
||||
else
|
||||
{
|
||||
c0 = GIMP_CHECK_DARK;
|
||||
c1 = GIMP_CHECK_LIGHT;
|
||||
}
|
||||
|
||||
*p0++ = (c0 + (r - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (g - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (b - c0) * a) * 255.0;
|
||||
|
||||
*p1++ = (c1 + (r - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (g - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (b - c1) * a) * 255.0;
|
||||
|
||||
} /* for */
|
||||
|
||||
if ((y / GIMP_CHECK_SIZE_SM) & 1)
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (widget), (guchar *)odd, 0, y, width);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (widget), (guchar *)even, 0, y, width);
|
||||
}
|
||||
src += width * bpp;
|
||||
}
|
||||
|
||||
g_free (even);
|
||||
g_free (odd);
|
||||
g_free (drawable_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* Drawing CenterFrame
|
||||
* if update & PREVIEW, draw preview
|
||||
|
@ -1022,44 +876,42 @@ static void
|
|||
flare_center_draw (FlareCenter *center,
|
||||
gint update)
|
||||
{
|
||||
GtkWidget *prvw = preview->widget;
|
||||
|
||||
if (update & PREVIEW)
|
||||
{
|
||||
center->cursor = FALSE;
|
||||
DEBUG1 ("draw-preview\n");
|
||||
}
|
||||
|
||||
if (update & CURSOR)
|
||||
{
|
||||
DEBUG1 ("draw-cursor %d old=%d,%d cur=%d,%d\n",
|
||||
center->cursor,
|
||||
center->oldx, center->oldy, center->curx, center->cury);
|
||||
gdk_gc_set_function (preview->style->black_gc, GDK_INVERT);
|
||||
gdk_gc_set_function (prvw->style->black_gc, GDK_INVERT);
|
||||
|
||||
if (show_cursor)
|
||||
{
|
||||
if (center->cursor)
|
||||
{
|
||||
gdk_draw_line (preview->window,
|
||||
preview->style->black_gc,
|
||||
gdk_draw_line (prvw->window,
|
||||
prvw->style->black_gc,
|
||||
center->oldx, 1,
|
||||
center->oldx,
|
||||
GTK_PREVIEW (preview)->buffer_height - 1);
|
||||
gdk_draw_line (preview->window,
|
||||
preview->style->black_gc,
|
||||
preview->height - 1);
|
||||
gdk_draw_line (prvw->window,
|
||||
prvw->style->black_gc,
|
||||
1, center->oldy,
|
||||
GTK_PREVIEW (preview)->buffer_width - 1,
|
||||
preview->width - 1,
|
||||
center->oldy);
|
||||
}
|
||||
|
||||
gdk_draw_line (preview->window,
|
||||
preview->style->black_gc,
|
||||
gdk_draw_line (prvw->window,
|
||||
prvw->style->black_gc,
|
||||
center->curx, 1,
|
||||
center->curx,
|
||||
GTK_PREVIEW (preview)->buffer_height - 1);
|
||||
gdk_draw_line (preview->window,
|
||||
preview->style->black_gc,
|
||||
preview->height - 1);
|
||||
gdk_draw_line (prvw->window,
|
||||
prvw->style->black_gc,
|
||||
1, center->cury,
|
||||
GTK_PREVIEW (preview)->buffer_width - 1,
|
||||
preview->width - 1,
|
||||
center->cury);
|
||||
}
|
||||
|
||||
|
@ -1068,7 +920,7 @@ flare_center_draw (FlareCenter *center,
|
|||
center->oldy = center->cury;
|
||||
center->cursor = TRUE;
|
||||
|
||||
gdk_gc_set_function (preview->style->black_gc, GDK_COPY);
|
||||
gdk_gc_set_function (prvw->style->black_gc, GDK_COPY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1103,20 +955,11 @@ flare_center_adjustment_update (GtkAdjustment *adjustment,
|
|||
static void
|
||||
flare_center_cursor_update (FlareCenter *center)
|
||||
{
|
||||
center->curx =
|
||||
fvals.posx * GTK_PREVIEW (preview)->buffer_width / center->dwidth;
|
||||
center->cury =
|
||||
fvals.posy * GTK_PREVIEW (preview)->buffer_height / center->dheight;
|
||||
center->curx = fvals.posx * preview->width / center->dwidth;
|
||||
center->cury = fvals.posy * preview->height / center->dheight;
|
||||
|
||||
if ( center->curx < 0)
|
||||
center->curx = 0;
|
||||
else if (center->curx >= GTK_PREVIEW (preview)->buffer_width)
|
||||
center->curx = GTK_PREVIEW (preview)->buffer_width - 1;
|
||||
|
||||
if (center->cury < 0)
|
||||
center->cury = 0;
|
||||
else if (center->cury >= GTK_PREVIEW (preview)->buffer_height)
|
||||
center->cury = GTK_PREVIEW (preview)->buffer_height - 1;
|
||||
center->curx = CLAMP (center->curx, 0, preview->width - 1);
|
||||
center->cury = CLAMP (center->cury, 0, preview->height - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1133,7 +976,6 @@ flare_center_preview_expose (GtkWidget *widget,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Handle other events on the preview
|
||||
*/
|
||||
|
@ -1170,10 +1012,10 @@ flare_center_preview_events (GtkWidget *widget,
|
|||
center->in_call = TRUE;
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (center->xadj),
|
||||
center->curx * center->dwidth /
|
||||
GTK_PREVIEW (preview)->buffer_width);
|
||||
preview->width);
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (center->yadj),
|
||||
center->cury * center->dheight /
|
||||
GTK_PREVIEW (preview)->buffer_height);
|
||||
preview->height);
|
||||
center->in_call = FALSE;
|
||||
FlareFX(center->drawable, 1);
|
||||
break;
|
||||
|
|
|
@ -43,11 +43,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -55,9 +50,6 @@
|
|||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
|
||||
#define PREVIEW_SIZE 128
|
||||
|
||||
/* --- Typedefs --- */
|
||||
typedef struct
|
||||
{
|
||||
|
@ -82,17 +74,6 @@ static gint glass_dialog (GimpDrawable *drawable);
|
|||
static void glass_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static void fill_preview_with_thumb (GtkWidget *preview_widget,
|
||||
gint32 drawable_ID);
|
||||
|
||||
static void preview_do_row (gint row,
|
||||
gint width,
|
||||
guchar *even,
|
||||
guchar *odd,
|
||||
guchar *src);
|
||||
|
||||
static GtkWidget * preview_widget (GimpDrawable *drawable);
|
||||
|
||||
static void glasstile (GimpDrawable *drawable,
|
||||
gboolean preview_mode);
|
||||
|
||||
|
@ -114,14 +95,7 @@ static GlassInterface gt_int =
|
|||
FALSE /* run */
|
||||
};
|
||||
|
||||
/* preview */
|
||||
static GtkWidget *preview;
|
||||
static gdouble preview_scale_x;
|
||||
static gdouble preview_scale_y;
|
||||
static guchar *preview_cache;
|
||||
static gint preview_cache_rowstride;
|
||||
static gint preview_cache_bpp;
|
||||
|
||||
static GimpFixMePreview *preview;
|
||||
|
||||
/* --- Functions --- */
|
||||
|
||||
|
@ -236,7 +210,7 @@ run (gchar *name,
|
|||
{
|
||||
gimp_set_data ("plug_in_glasstile", >vals,
|
||||
sizeof (GlassValues));
|
||||
g_free (preview_cache);
|
||||
gimp_fixme_preview_free (preview);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -298,10 +272,10 @@ glass_dialog (GimpDrawable *drawable)
|
|||
gtk_container_add (GTK_CONTAINER (abox), frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
preview = preview_widget (drawable);
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview);
|
||||
preview = gimp_fixme_preview_new (drawable);
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview->widget);
|
||||
glasstile (drawable, TRUE); /* filter routine, initial pass */
|
||||
gtk_widget_show (preview);
|
||||
gtk_widget_show (preview->widget);
|
||||
|
||||
/* Parameter settings */
|
||||
frame = gtk_frame_new (_("Parameter Settings"));
|
||||
|
@ -363,141 +337,6 @@ glass_ok_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (GTK_WIDGET (data));
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
preview_widget (GimpDrawable *drawable)
|
||||
{
|
||||
GtkWidget *preview;
|
||||
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
|
||||
fill_preview_with_thumb (preview, drawable->drawable_id);
|
||||
|
||||
return preview;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_preview_with_thumb (GtkWidget *widget,
|
||||
gint32 drawable_ID)
|
||||
{
|
||||
gint bpp;
|
||||
gint y;
|
||||
gint width = PREVIEW_SIZE;
|
||||
gint height = PREVIEW_SIZE;
|
||||
guchar *src;
|
||||
guchar *even;
|
||||
guchar *odd;
|
||||
|
||||
preview_cache =
|
||||
gimp_drawable_get_thumbnail_data (drawable_ID, &width, &height, &bpp);
|
||||
|
||||
if (width < 1 || height < 1)
|
||||
return;
|
||||
|
||||
preview = widget;
|
||||
preview_cache_rowstride = width * bpp;
|
||||
preview_cache_bpp = bpp;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (widget), width, height);
|
||||
preview_scale_x =
|
||||
(gdouble) width / (gdouble) gimp_drawable_width (drawable_ID);
|
||||
preview_scale_y =
|
||||
(gdouble) height / (gdouble) gimp_drawable_height (drawable_ID);
|
||||
|
||||
src = preview_cache;
|
||||
even = g_malloc (width * 3);
|
||||
odd = g_malloc (width * 3);
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
preview_do_row (y, width, even, odd, src);
|
||||
src += width * bpp;
|
||||
}
|
||||
|
||||
g_free (even);
|
||||
g_free (odd);
|
||||
}
|
||||
|
||||
static void
|
||||
preview_do_row (gint row,
|
||||
gint width,
|
||||
guchar *even,
|
||||
guchar *odd,
|
||||
guchar *src)
|
||||
{
|
||||
gint x;
|
||||
guchar *p0 = even;
|
||||
guchar *p1 = odd;
|
||||
gdouble r, g, b, a;
|
||||
gdouble c0, c1;
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
switch (preview_cache_bpp)
|
||||
{
|
||||
case 4:
|
||||
r = ((gdouble) src[x*4]) / 255.0;
|
||||
g = ((gdouble) src[x*4 + 1]) / 255.0;
|
||||
b = ((gdouble) src[x*4 + 2]) / 255.0;
|
||||
a = ((gdouble) src[x*4 + 3]) / 255.0;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
r = ((gdouble) src[x*3]) / 255.0;
|
||||
g = ((gdouble) src[x*3 + 1]) / 255.0;
|
||||
b = ((gdouble) src[x*3 + 2]) / 255.0;
|
||||
a = 1.0;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
r = ((gdouble)src[x*2]) / 255.0;
|
||||
g = b = r;
|
||||
a = ((gdouble)src[x*2 + 1]) / 255.0;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
r = ((gdouble)src[x*2]) / 255.0;
|
||||
g = b = r;
|
||||
a = 1.0;
|
||||
break;
|
||||
|
||||
default:
|
||||
r = g = b = a = 1.0; /* just to please the compiler */
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
if ((x / GIMP_CHECK_SIZE) & 1)
|
||||
{
|
||||
c0 = GIMP_CHECK_LIGHT;
|
||||
c1 = GIMP_CHECK_DARK;
|
||||
}
|
||||
else
|
||||
{
|
||||
c0 = GIMP_CHECK_DARK;
|
||||
c1 = GIMP_CHECK_LIGHT;
|
||||
}
|
||||
|
||||
*p0++ = (c0 + (r - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (g - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (b - c0) * a) * 255.0;
|
||||
|
||||
*p1++ = (c1 + (r - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (g - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (b - c1) * a) * 255.0;
|
||||
}
|
||||
|
||||
if ((row / GIMP_CHECK_SIZE) & 1)
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview),
|
||||
(guchar *) odd, 0, row, width);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview),
|
||||
(guchar *) even, 0, row, width);
|
||||
}
|
||||
}
|
||||
|
||||
/* - Filter function - I wish all filter functions had a pmode :) */
|
||||
static void
|
||||
glasstile (GimpDrawable *drawable,
|
||||
|
@ -511,9 +350,6 @@ glasstile (GimpDrawable *drawable,
|
|||
gint row, col, i, iwidth;
|
||||
gint x1, y1, x2, y2;
|
||||
|
||||
guchar *odd = NULL;
|
||||
guchar *even = NULL;
|
||||
|
||||
gint rutbredd, xpixel1, xpixel2;
|
||||
gint ruthojd , ypixel2;
|
||||
gint xhalv, xoffs, xmitt, xplus;
|
||||
|
@ -522,16 +358,13 @@ glasstile (GimpDrawable *drawable,
|
|||
|
||||
if (preview_mode)
|
||||
{
|
||||
width = GTK_PREVIEW (preview)->buffer_width;
|
||||
height = GTK_PREVIEW (preview)->buffer_height;
|
||||
bytes = preview_cache_bpp;
|
||||
width = preview->width;
|
||||
height = preview->height;
|
||||
bytes = preview->bpp;
|
||||
|
||||
x1 = y1 = 0;
|
||||
x2 = width;
|
||||
y2 = height;
|
||||
|
||||
even = g_malloc (width * 3);
|
||||
odd = g_malloc (width * 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -547,8 +380,8 @@ glasstile (GimpDrawable *drawable,
|
|||
/* initialize the pixel regions */
|
||||
if (preview_mode)
|
||||
{
|
||||
rutbredd = gtvals.xblock * preview_scale_x;
|
||||
ruthojd = gtvals.yblock * preview_scale_y;
|
||||
rutbredd = gtvals.xblock * preview->scale_x;
|
||||
ruthojd = gtvals.yblock * preview->scale_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -586,12 +419,12 @@ glasstile (GimpDrawable *drawable,
|
|||
{
|
||||
if (ypixel2 < height)
|
||||
memcpy (cur_row,
|
||||
preview_cache + (ypixel2 * preview_cache_rowstride),
|
||||
preview_cache_rowstride);
|
||||
preview->cache + (ypixel2 * preview->rowstride),
|
||||
preview->rowstride);
|
||||
else
|
||||
memcpy (cur_row,
|
||||
preview_cache + ((y2 - 1) * preview_cache_rowstride),
|
||||
preview_cache_rowstride);
|
||||
preview->cache + ((y2 - 1) * preview->rowstride),
|
||||
preview->rowstride);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -642,7 +475,7 @@ glasstile (GimpDrawable *drawable,
|
|||
/* Store the dest */
|
||||
if (preview_mode)
|
||||
{
|
||||
preview_do_row (row, width, even, odd, dest);
|
||||
gimp_fixme_preview_do_row (preview, row, width, dest);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -653,13 +486,10 @@ glasstile (GimpDrawable *drawable,
|
|||
}
|
||||
}
|
||||
|
||||
g_free (even);
|
||||
g_free (odd);
|
||||
|
||||
/* Update region */
|
||||
if (preview_mode)
|
||||
{
|
||||
gtk_widget_queue_draw (preview);
|
||||
gtk_widget_queue_draw (preview->widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -30,11 +30,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -46,9 +41,6 @@
|
|||
#define PLUG_IN_NAME "plug_in_illusion"
|
||||
#define PLUG_IN_VERSION "v0.8 (May 14 2000)"
|
||||
|
||||
#define PREVIEW_SIZE 128
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
|
@ -59,12 +51,8 @@ static void run (gchar *name,
|
|||
|
||||
static void filter (GimpDrawable *drawable);
|
||||
static void filter_preview (void);
|
||||
static void fill_preview_with_thumb (GtkWidget *preview_widget,
|
||||
gint32 drawable_ID);
|
||||
static gboolean dialog (GimpDrawable *drawable);
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint32 division;
|
||||
|
@ -72,8 +60,6 @@ typedef struct
|
|||
gint type2;
|
||||
} IllValues;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
NULL, /* init_proc */
|
||||
|
@ -90,17 +76,12 @@ static IllValues parameters =
|
|||
};
|
||||
|
||||
|
||||
static GtkWidget *preview;
|
||||
static guchar *preview_cache;
|
||||
static gint preview_cache_rowstride;
|
||||
static gint preview_cache_bpp;
|
||||
static GimpFixMePreview *preview;
|
||||
static gboolean dialog_status = FALSE;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
MAIN ()
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
static void
|
||||
query (void)
|
||||
{
|
||||
|
@ -126,8 +107,6 @@ query (void)
|
|||
args, NULL);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
static void
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
|
@ -157,7 +136,7 @@ run (gchar *name,
|
|||
if (! dialog(drawable))
|
||||
return;
|
||||
gimp_set_data (PLUG_IN_NAME, ¶meters, sizeof (IllValues));
|
||||
g_free(preview_cache);
|
||||
gimp_fixme_preview_free (preview);
|
||||
break;
|
||||
|
||||
case GIMP_RUN_NONINTERACTIVE:
|
||||
|
@ -209,8 +188,6 @@ run (gchar *name,
|
|||
gimp_drawable_detach (drawable);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
static void
|
||||
filter (GimpDrawable *drawable)
|
||||
{
|
||||
|
@ -221,7 +198,6 @@ filter (GimpDrawable *drawable)
|
|||
gint image_width;
|
||||
gint image_height;
|
||||
gint image_bpp;
|
||||
gint image_has_alpha;
|
||||
gint x1;
|
||||
gint y1;
|
||||
gint x2;
|
||||
|
@ -239,7 +215,6 @@ filter (GimpDrawable *drawable)
|
|||
image_width = gimp_drawable_width (drawable->drawable_id);
|
||||
image_height = gimp_drawable_height (drawable->drawable_id);
|
||||
image_bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
image_has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id,&x1, &y1, &x2, &y2);
|
||||
select_width = x2 - x1;
|
||||
select_height = y2 - y1;
|
||||
|
@ -286,15 +261,8 @@ filter (GimpDrawable *drawable)
|
|||
yy = y - offset * cos (angle);
|
||||
}
|
||||
|
||||
if (xx < 0)
|
||||
xx = 0;
|
||||
else if (image_width <= xx)
|
||||
xx = image_width - 1;
|
||||
|
||||
if (yy < 0)
|
||||
yy = 0;
|
||||
else if (image_height <= yy)
|
||||
yy = image_height - 1;
|
||||
xx = CLAMP (xx, 0, image_width - 1);
|
||||
yy = CLAMP (yy, 0, image_height - 1);
|
||||
|
||||
for (b = 0; b < image_bpp; b++)
|
||||
destpixels[y][x*image_bpp+b] =
|
||||
|
@ -316,84 +284,11 @@ filter (GimpDrawable *drawable)
|
|||
g_free (destpixels);
|
||||
}
|
||||
|
||||
static void
|
||||
preview_do_row(gint row,
|
||||
gint width,
|
||||
guchar *even,
|
||||
guchar *odd,
|
||||
guchar *src)
|
||||
{
|
||||
gint x;
|
||||
|
||||
guchar *p0 = even;
|
||||
guchar *p1 = odd;
|
||||
|
||||
gdouble r, g, b, a;
|
||||
gdouble c0, c1;
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
if (preview_cache_bpp == 4)
|
||||
{
|
||||
r = ((gdouble)src[x*4+0]) / 255.0;
|
||||
g = ((gdouble)src[x*4+1]) / 255.0;
|
||||
b = ((gdouble)src[x*4+2]) / 255.0;
|
||||
a = ((gdouble)src[x*4+3]) / 255.0;
|
||||
}
|
||||
else if (preview_cache_bpp == 3)
|
||||
{
|
||||
r = ((gdouble)src[x*3+0]) / 255.0;
|
||||
g = ((gdouble)src[x*3+1]) / 255.0;
|
||||
b = ((gdouble)src[x*3+2]) / 255.0;
|
||||
a = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = ((gdouble)src[x*preview_cache_bpp+0]) / 255.0;
|
||||
g = b = r;
|
||||
if (preview_cache_bpp == 2)
|
||||
a = ((gdouble)src[x*preview_cache_bpp+1]) / 255.0;
|
||||
else
|
||||
a = 1.0;
|
||||
}
|
||||
|
||||
if ((x / GIMP_CHECK_SIZE) & 1)
|
||||
{
|
||||
c0 = GIMP_CHECK_LIGHT;
|
||||
c1 = GIMP_CHECK_DARK;
|
||||
}
|
||||
else
|
||||
{
|
||||
c0 = GIMP_CHECK_DARK;
|
||||
c1 = GIMP_CHECK_LIGHT;
|
||||
}
|
||||
|
||||
*p0++ = (c0 + (r - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (g - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (b - c0) * a) * 255.0;
|
||||
|
||||
*p1++ = (c1 + (r - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (g - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (b - c1) * a) * 255.0;
|
||||
|
||||
} /* for */
|
||||
|
||||
if ((row / GIMP_CHECK_SIZE) & 1)
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview), (guchar *)odd, 0, row, width);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview), (guchar *)even, 0, row, width);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
filter_preview (void)
|
||||
{
|
||||
guchar **pixels;
|
||||
guchar **destpixels;
|
||||
guchar *even, *odd;
|
||||
|
||||
gint image_width;
|
||||
gint image_height;
|
||||
|
@ -406,25 +301,22 @@ filter_preview (void)
|
|||
gint yy = 0;
|
||||
gdouble scale, radius, cx, cy, angle, offset;
|
||||
|
||||
image_width = GTK_PREVIEW (preview)->buffer_width;
|
||||
image_height = GTK_PREVIEW (preview)->buffer_height;
|
||||
image_bpp = preview_cache_bpp;
|
||||
image_width = preview->width;
|
||||
image_height = preview->height;
|
||||
image_bpp = preview->bpp;
|
||||
center_x = (gdouble)image_width / 2;
|
||||
center_y = (gdouble)image_height / 2;
|
||||
|
||||
pixels = g_new (guchar *, image_height);
|
||||
destpixels = g_new (guchar *, image_height);
|
||||
|
||||
even = g_malloc (image_width * 3);
|
||||
odd = g_malloc (image_width * 3);
|
||||
|
||||
for (y = 0; y < image_height; y++)
|
||||
{
|
||||
pixels[y] = g_new (guchar, preview_cache_rowstride);
|
||||
destpixels[y] = g_new (guchar, preview_cache_rowstride);
|
||||
pixels[y] = g_new (guchar, preview->rowstride);
|
||||
destpixels[y] = g_new (guchar, preview->rowstride);
|
||||
memcpy (pixels[y],
|
||||
preview_cache + preview_cache_rowstride * y,
|
||||
preview_cache_rowstride);
|
||||
preview->cache + preview->rowstride * y,
|
||||
preview->rowstride);
|
||||
}
|
||||
|
||||
scale = sqrt (image_width * image_width + image_height * image_height) / 2;
|
||||
|
@ -452,15 +344,8 @@ filter_preview (void)
|
|||
yy = y - offset * cos (angle);
|
||||
}
|
||||
|
||||
if (xx < 0)
|
||||
xx = 0;
|
||||
else if (image_width <= xx)
|
||||
xx = image_width - 1;
|
||||
|
||||
if (yy < 0)
|
||||
yy = 0;
|
||||
else if (image_height <= yy)
|
||||
yy = image_height - 1;
|
||||
xx = CLAMP (xx, 0, image_width - 1);
|
||||
yy = CLAMP (yy, 0, image_height - 1);
|
||||
|
||||
for (b = 0; b < image_bpp; b++)
|
||||
destpixels[y][x*image_bpp+b] =
|
||||
|
@ -468,11 +353,7 @@ filter_preview (void)
|
|||
+ radius * pixels[yy][xx * image_bpp + b];
|
||||
}
|
||||
|
||||
preview_do_row(y,
|
||||
image_width,
|
||||
even,
|
||||
odd,
|
||||
destpixels[y]);
|
||||
gimp_fixme_preview_do_row (preview, y, image_width, destpixels[y]);
|
||||
}
|
||||
|
||||
for (y = 0; y < image_height; y++)
|
||||
|
@ -483,64 +364,9 @@ filter_preview (void)
|
|||
g_free (destpixels[y]);
|
||||
g_free (destpixels);
|
||||
|
||||
g_free (even);
|
||||
g_free (odd);
|
||||
|
||||
gtk_widget_queue_draw (preview);
|
||||
gtk_widget_queue_draw (preview->widget);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
preview_widget (GimpDrawable *drawable)
|
||||
{
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
fill_preview_with_thumb (preview, drawable->drawable_id);
|
||||
|
||||
return preview;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_preview_with_thumb (GtkWidget *widget,
|
||||
gint32 drawable_ID)
|
||||
{
|
||||
guchar *drawable_data;
|
||||
gint bpp;
|
||||
gint y;
|
||||
gint width = PREVIEW_SIZE;
|
||||
gint height = PREVIEW_SIZE;
|
||||
guchar *src;
|
||||
guchar *even, *odd;
|
||||
|
||||
bpp = 0; /* Only returned */
|
||||
|
||||
drawable_data =
|
||||
gimp_drawable_get_thumbnail_data (drawable_ID, &width, &height, &bpp);
|
||||
|
||||
if (width < 1 || height < 1)
|
||||
return;
|
||||
|
||||
preview_cache = drawable_data;
|
||||
preview_cache_rowstride = width * bpp;
|
||||
preview_cache_bpp = bpp;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (widget), width, height);
|
||||
|
||||
even = g_malloc (width * 3);
|
||||
odd = g_malloc (width * 3);
|
||||
src = drawable_data;
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
preview_do_row(y,width,even,odd,preview_cache + (y*width*bpp));
|
||||
}
|
||||
|
||||
g_free (even);
|
||||
g_free (odd);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
static gboolean dialog_status = FALSE;
|
||||
|
||||
static void
|
||||
dialog_ok_handler (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
@ -550,8 +376,6 @@ dialog_ok_handler (GtkWidget *widget,
|
|||
gtk_widget_destroy (GTK_WIDGET (data));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
static gboolean
|
||||
dialog (GimpDrawable *mangle)
|
||||
{
|
||||
|
@ -607,10 +431,10 @@ dialog (GimpDrawable *mangle)
|
|||
gtk_container_add (GTK_CONTAINER (abox), frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
preview = preview_widget (mangle);
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview);
|
||||
preview = gimp_fixme_preview_new (mangle);
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview->widget);
|
||||
filter_preview();
|
||||
gtk_widget_show (preview);
|
||||
gtk_widget_show (preview->widget);
|
||||
|
||||
frame = gtk_frame_new (_("Parameter Settings"));
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
|
|
|
@ -39,11 +39,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -51,10 +46,6 @@
|
|||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
|
||||
#define PREVIEW_SIZE 128
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BEZIER_1,
|
||||
|
@ -81,10 +72,6 @@ static gint jigsaw (gboolean preview_mode);
|
|||
|
||||
static void jigsaw_radio_button_update (GtkWidget *widget, gpointer data);
|
||||
static void dialog_box (void);
|
||||
static void fill_preview_with_thumb (GtkWidget *preview_widget,
|
||||
gint32 drawable_ID);
|
||||
static GtkWidget *preview_widget (GimpDrawable *drawable);
|
||||
|
||||
static void run_callback (GtkWidget *widget, gpointer data);
|
||||
static void check_button_callback (GtkWidget *widget, gpointer data);
|
||||
|
||||
|
@ -368,8 +355,7 @@ static globals_t globals =
|
|||
};
|
||||
|
||||
/* preview globals */
|
||||
static guchar *preview_bits;
|
||||
static GtkWidget *preview;
|
||||
static GimpFixMePreview *preview;
|
||||
|
||||
MAIN ()
|
||||
|
||||
|
@ -429,7 +415,7 @@ run (gchar *name,
|
|||
config.style = param[5].data.d_int32;
|
||||
config.blend_lines = param[6].data.d_int32;
|
||||
config.blend_amount = param[7].data.d_float;
|
||||
if (jigsaw(0) == -1)
|
||||
if (jigsaw(FALSE) == -1)
|
||||
{
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
|
@ -451,7 +437,7 @@ run (gchar *name,
|
|||
break;
|
||||
}
|
||||
gimp_progress_init( _("Assembling Jigsaw"));
|
||||
if (jigsaw(0) == -1)
|
||||
if (jigsaw(FALSE) == -1)
|
||||
{
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
break;
|
||||
|
@ -460,13 +446,12 @@ run (gchar *name,
|
|||
gimp_set_data(PLUG_IN_STORAGE, &globals.tooltips,
|
||||
sizeof(globals.tooltips));
|
||||
gimp_displays_flush();
|
||||
g_free(preview_bits);
|
||||
break;
|
||||
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
INIT_I18N();
|
||||
gimp_get_data("plug_in_jigsaw", &config);
|
||||
if (jigsaw(0) == -1)
|
||||
if (jigsaw(FALSE) == -1)
|
||||
{
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
gimp_message("An execution error occured.");
|
||||
|
@ -501,10 +486,10 @@ jigsaw (gboolean preview_mode)
|
|||
|
||||
if (preview_mode)
|
||||
{
|
||||
width = GTK_PREVIEW (preview)->buffer_width;
|
||||
height = GTK_PREVIEW (preview)->buffer_height;
|
||||
bytes = GTK_PREVIEW (preview)->bpp;
|
||||
buffer_size = GTK_PREVIEW (preview)->rowstride * height;
|
||||
width = preview->width;
|
||||
height = preview->height;
|
||||
bytes = preview->bpp;
|
||||
buffer_size = preview->rowstride * height;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -519,7 +504,7 @@ jigsaw (gboolean preview_mode)
|
|||
|
||||
if (preview_mode)
|
||||
{
|
||||
memcpy (buffer, preview_bits, buffer_size);
|
||||
memcpy (buffer, preview->cache, buffer_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -540,8 +525,8 @@ jigsaw (gboolean preview_mode)
|
|||
/* cleanup */
|
||||
if (preview_mode)
|
||||
{
|
||||
memcpy (GTK_PREVIEW (preview)->buffer, buffer, buffer_size);
|
||||
gtk_widget_queue_draw (preview);
|
||||
memcpy (preview->buffer, buffer, buffer_size);
|
||||
gtk_widget_queue_draw (preview->widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -912,7 +897,7 @@ draw_vertical_line (guchar *buffer,
|
|||
gint index;
|
||||
gint length;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
index = px[0] * bytes + rowstride * py[0];
|
||||
length = py[1] - py[0] + 1;
|
||||
|
||||
|
@ -937,7 +922,7 @@ draw_horizontal_line (guchar *buffer,
|
|||
gint index;
|
||||
gint length;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
index = px[0] * bytes + rowstride * py[0];
|
||||
length = px[1] - px[0] + 1;
|
||||
|
||||
|
@ -962,7 +947,7 @@ draw_right_bump (guchar *buffer,
|
|||
gint index;
|
||||
gint rowstride;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -992,7 +977,7 @@ draw_left_bump (guchar *buffer,
|
|||
gint index;
|
||||
gint rowstride;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -1022,7 +1007,7 @@ draw_up_bump (guchar *buffer,
|
|||
gint index;
|
||||
gint rowstride;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -1052,7 +1037,7 @@ draw_down_bump (guchar *buffer,
|
|||
gint index;
|
||||
gint rowstride;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -1521,7 +1506,7 @@ darken_vertical_line (guchar *buffer,
|
|||
gint length;
|
||||
gint temp;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
index = px[0] * bytes + py[0] * rowstride;
|
||||
length = py[1] - py[0] + 1;
|
||||
|
||||
|
@ -1549,7 +1534,7 @@ lighten_vertical_line (guchar *buffer,
|
|||
gint length;
|
||||
gint temp;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
index = px[0] * bytes + py[0] * rowstride;
|
||||
length = py[1] - py[0] + 1;
|
||||
|
||||
|
@ -1577,7 +1562,7 @@ darken_horizontal_line (guchar *buffer,
|
|||
gint length;
|
||||
gint temp;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
index = px[0] * bytes + py[0] * rowstride;
|
||||
length = px[1] - px[0] + 1;
|
||||
|
||||
|
@ -1605,7 +1590,7 @@ lighten_horizontal_line (guchar *buffer,
|
|||
gint length;
|
||||
gint temp;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
index = px[0] * bytes + py[0] * rowstride;
|
||||
length = px[1] - px[0] + 1;
|
||||
|
||||
|
@ -1636,7 +1621,7 @@ darken_right_bump (guchar *buffer,
|
|||
gint temp;
|
||||
gint j = counter;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -1691,7 +1676,7 @@ lighten_right_bump (guchar *buffer,
|
|||
gint temp;
|
||||
gint j = counter;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -1746,7 +1731,7 @@ darken_left_bump (guchar *buffer,
|
|||
gint temp;
|
||||
gint j = counter;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -1801,7 +1786,7 @@ lighten_left_bump (guchar *buffer,
|
|||
gint temp;
|
||||
gint j = counter;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -1856,7 +1841,7 @@ darken_up_bump (guchar *buffer,
|
|||
gint temp;
|
||||
gint j = counter;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -1911,7 +1896,7 @@ lighten_up_bump (guchar *buffer,
|
|||
gint temp;
|
||||
gint j = counter;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -1966,7 +1951,7 @@ darken_down_bump (guchar *buffer,
|
|||
gint temp;
|
||||
gint j = counter;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -2021,7 +2006,7 @@ lighten_down_bump (guchar *buffer,
|
|||
gint temp;
|
||||
gint j = counter;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -2070,7 +2055,7 @@ draw_bezier_line (guchar *buffer,
|
|||
gint index;
|
||||
gint rowstride;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -2100,7 +2085,7 @@ darken_bezier_line (guchar *buffer,
|
|||
gint rowstride;
|
||||
gint temp;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -2134,7 +2119,7 @@ lighten_bezier_line (guchar *buffer,
|
|||
gint rowstride;
|
||||
gint temp;
|
||||
|
||||
rowstride = preview_mode ? GTK_PREVIEW (preview)->rowstride : bytes * width;
|
||||
rowstride = preview_mode ? preview->rowstride : bytes * width;
|
||||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
|
@ -2521,10 +2506,10 @@ dialog_box (void)
|
|||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_container_add (GTK_CONTAINER (abox), frame);
|
||||
gtk_widget_show (frame);
|
||||
preview = preview_widget (drawable); /* we are here */
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview);
|
||||
jigsaw(1); /* render preview */
|
||||
gtk_widget_show (preview);
|
||||
preview = gimp_fixme_preview_new (drawable);
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview->widget);
|
||||
jigsaw(TRUE); /* render preview */
|
||||
gtk_widget_show (preview->widget);
|
||||
|
||||
main_vbox = gtk_vbox_new (FALSE, 4);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6);
|
||||
|
@ -2658,8 +2643,6 @@ dialog_box (void)
|
|||
gtk_main ();
|
||||
gimp_help_free ();
|
||||
gdk_flush ();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/***************************************************
|
||||
|
@ -2699,115 +2682,3 @@ jigsaw_radio_button_update (GtkWidget *widget,
|
|||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
jigsaw (TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* preview library */
|
||||
|
||||
static GtkWidget *
|
||||
preview_widget (GimpDrawable *drawable)
|
||||
{
|
||||
gint size;
|
||||
GtkWidget *preview;
|
||||
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
fill_preview_with_thumb (preview, drawable->drawable_id);
|
||||
size = GTK_PREVIEW (preview)->rowstride * GTK_PREVIEW (preview)->buffer_height;
|
||||
preview_bits = g_malloc (size);
|
||||
memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size);
|
||||
|
||||
return preview;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_preview_with_thumb (GtkWidget *widget,
|
||||
gint32 drawable_ID)
|
||||
{
|
||||
guchar *drawable_data;
|
||||
gint bpp;
|
||||
gint x,y;
|
||||
gint width = PREVIEW_SIZE;
|
||||
gint height = PREVIEW_SIZE;
|
||||
guchar *src;
|
||||
gdouble r, g, b, a;
|
||||
gdouble c0, c1;
|
||||
guchar *p0, *p1;
|
||||
guchar *even, *odd;
|
||||
|
||||
bpp = 0; /* Only returned */
|
||||
|
||||
drawable_data =
|
||||
gimp_drawable_get_thumbnail_data (drawable_ID, &width, &height, &bpp);
|
||||
|
||||
if (width < 1 || height < 1)
|
||||
return;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (widget), width, height);
|
||||
|
||||
even = g_malloc (width * 3);
|
||||
odd = g_malloc (width * 3);
|
||||
src = drawable_data;
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
p0 = even;
|
||||
p1 = odd;
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
if (bpp == 4)
|
||||
{
|
||||
r = ((gdouble)src[x*4+0]) / 255.0;
|
||||
g = ((gdouble)src[x*4+1]) / 255.0;
|
||||
b = ((gdouble)src[x*4+2]) / 255.0;
|
||||
a = ((gdouble)src[x*4+3]) / 255.0;
|
||||
}
|
||||
else if (bpp == 3)
|
||||
{
|
||||
r = ((gdouble)src[x*3+0]) / 255.0;
|
||||
g = ((gdouble)src[x*3+1]) / 255.0;
|
||||
b = ((gdouble)src[x*3+2]) / 255.0;
|
||||
a = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = ((gdouble)src[x*bpp+0]) / 255.0;
|
||||
g = b = r;
|
||||
if (bpp == 2)
|
||||
a = ((gdouble)src[x*bpp+1]) / 255.0;
|
||||
else
|
||||
a = 1.0;
|
||||
}
|
||||
|
||||
if ((x / GIMP_CHECK_SIZE_SM) & 1)
|
||||
{
|
||||
c0 = GIMP_CHECK_LIGHT;
|
||||
c1 = GIMP_CHECK_DARK;
|
||||
}
|
||||
else
|
||||
{
|
||||
c0 = GIMP_CHECK_DARK;
|
||||
c1 = GIMP_CHECK_LIGHT;
|
||||
}
|
||||
|
||||
*p0++ = (c0 + (r - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (g - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (b - c0) * a) * 255.0;
|
||||
|
||||
*p1++ = (c1 + (r - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (g - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (b - c1) * a) * 255.0;
|
||||
|
||||
} /* for */
|
||||
|
||||
if ((y / GIMP_CHECK_SIZE_SM) & 1)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (widget), (guchar *)odd, 0, y, width);
|
||||
else
|
||||
gtk_preview_draw_row (GTK_PREVIEW (widget), (guchar *)even, 0, y, width);
|
||||
|
||||
src += width * bpp;
|
||||
}
|
||||
|
||||
g_free (even);
|
||||
g_free (odd);
|
||||
g_free (drawable_data);
|
||||
}
|
||||
|
|
|
@ -31,11 +31,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -48,7 +43,6 @@
|
|||
#define PLUG_IN_NAME "plug_in_max_rgb"
|
||||
#define SHORT_NAME "max_rgb"
|
||||
#define PROGRESS_UPDATE_NUM 100
|
||||
#define PREVIEW_SIZE 128
|
||||
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
|
@ -57,10 +51,6 @@ static void run (gchar *name,
|
|||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
|
||||
static void fill_preview_with_thumb (GtkWidget *preview_widget,
|
||||
gint32 drawable_id);
|
||||
static GtkWidget *preview_widget (GimpDrawable *drawable);
|
||||
|
||||
static GimpPDBStatusType main_function (GimpDrawable *drawable,
|
||||
gboolean preview_mode);
|
||||
|
||||
|
@ -105,8 +95,7 @@ static Interface interface =
|
|||
FALSE
|
||||
};
|
||||
|
||||
static guchar *preview_bits;
|
||||
static GtkWidget *preview;
|
||||
static GimpFixMePreview *preview;
|
||||
|
||||
MAIN ()
|
||||
|
||||
|
@ -188,7 +177,6 @@ run (gchar *name,
|
|||
gimp_displays_flush ();
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE && status == GIMP_PDB_SUCCESS)
|
||||
gimp_set_data (PLUG_IN_NAME, &pvals, sizeof (ValueType));
|
||||
g_free(preview_bits);
|
||||
|
||||
values[0].data.d_status = status;
|
||||
}
|
||||
|
@ -211,10 +199,10 @@ main_function (GimpDrawable *drawable,
|
|||
if (preview_mode)
|
||||
{
|
||||
x1 = y1 = 0;
|
||||
x2 = GTK_PREVIEW (preview)->buffer_width;
|
||||
y2 = GTK_PREVIEW (preview)->buffer_height;
|
||||
x2 = preview->width;
|
||||
y2 = preview->height;
|
||||
gap = 0; /* no alpha on preview */
|
||||
bpp = GTK_PREVIEW (preview)->bpp;
|
||||
bpp = preview->bpp;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -234,19 +222,16 @@ main_function (GimpDrawable *drawable,
|
|||
return GIMP_PDB_EXECUTION_ERROR;
|
||||
|
||||
if (preview_mode)
|
||||
{ /* preview mode. here we go again. see nova.c
|
||||
I just don't want to write a prev_pixel_rgn_process
|
||||
and then find out someone else coded a much cooler
|
||||
preview widget / functions for GIMP */
|
||||
src_data = g_malloc (GTK_PREVIEW (preview)->rowstride * y2);
|
||||
memcpy (src_data, preview_bits, GTK_PREVIEW (preview)->rowstride * y2);
|
||||
dest_data = g_malloc (GTK_PREVIEW (preview)->rowstride * y2);
|
||||
{
|
||||
src_data = g_malloc (preview->rowstride * y2);
|
||||
memcpy (src_data, preview->cache, preview->rowstride * y2);
|
||||
dest_data = g_malloc (preview->rowstride * y2);
|
||||
save_dest = dest_data;
|
||||
|
||||
for (y = 0; y < y2; y++)
|
||||
{
|
||||
src = src_data + y * GTK_PREVIEW (preview)->rowstride;
|
||||
dest = dest_data + y * GTK_PREVIEW (preview)->rowstride;
|
||||
src = src_data + y * preview->rowstride;
|
||||
dest = dest_data + y * preview->rowstride;
|
||||
|
||||
for (x = 0; x < x2; x++)
|
||||
{
|
||||
|
@ -276,8 +261,8 @@ main_function (GimpDrawable *drawable,
|
|||
}
|
||||
}
|
||||
|
||||
memcpy (GTK_PREVIEW (preview)->buffer, save_dest, GTK_PREVIEW (preview)->rowstride * y2);
|
||||
gtk_widget_queue_draw (preview);
|
||||
memcpy (preview->buffer, save_dest, preview->rowstride * y2);
|
||||
gtk_widget_queue_draw (preview->widget);
|
||||
}
|
||||
else
|
||||
{ /* normal mode */
|
||||
|
@ -380,10 +365,10 @@ dialog (GimpDrawable *drawable)
|
|||
gtk_container_add (GTK_CONTAINER (abox), frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
preview = preview_widget (drawable);
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview);
|
||||
preview = gimp_fixme_preview_new (drawable);
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview->widget);
|
||||
main_function (drawable, TRUE);
|
||||
gtk_widget_show (preview);
|
||||
gtk_widget_show (preview->widget);
|
||||
|
||||
frame = gimp_radio_group_new2 (TRUE, _("Parameter Settings"),
|
||||
G_CALLBACK (radio_callback),
|
||||
|
@ -416,12 +401,11 @@ static void
|
|||
radio_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
|
||||
gimp_radio_button_update (widget, data);
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
drawable = g_object_get_data (G_OBJECT (widget), "drawable");
|
||||
main_function (drawable, TRUE);
|
||||
}
|
||||
|
@ -435,112 +419,3 @@ ok_callback (GtkWidget *widget,
|
|||
|
||||
gtk_widget_destroy (GTK_WIDGET (data));
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
preview_widget (GimpDrawable *drawable)
|
||||
{
|
||||
gint size;
|
||||
GtkWidget *preview;
|
||||
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
fill_preview_with_thumb (preview, drawable->drawable_id);
|
||||
size = GTK_PREVIEW (preview)->rowstride * GTK_PREVIEW (preview)->buffer_height;
|
||||
preview_bits = g_malloc (size);
|
||||
memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size);
|
||||
|
||||
return preview;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_preview_with_thumb (GtkWidget *widget,
|
||||
gint32 drawable_ID)
|
||||
{
|
||||
guchar *drawable_data;
|
||||
gint bpp;
|
||||
gint x,y;
|
||||
gint width = PREVIEW_SIZE;
|
||||
gint height = PREVIEW_SIZE;
|
||||
guchar *src;
|
||||
gdouble r, g, b, a;
|
||||
gdouble c0, c1;
|
||||
guchar *p0, *p1;
|
||||
guchar *even, *odd;
|
||||
|
||||
bpp = 0; /* Only returned */
|
||||
|
||||
drawable_data =
|
||||
gimp_drawable_get_thumbnail_data (drawable_ID, &width, &height, &bpp);
|
||||
|
||||
if (width < 1 || height < 1)
|
||||
return;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (widget), width, height);
|
||||
|
||||
even = g_malloc (width * 3);
|
||||
odd = g_malloc (width * 3);
|
||||
src = drawable_data;
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
p0 = even;
|
||||
p1 = odd;
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
if(bpp == 4)
|
||||
{
|
||||
r = ((gdouble)src[x*4+0])/255.0;
|
||||
g = ((gdouble)src[x*4+1])/255.0;
|
||||
b = ((gdouble)src[x*4+2])/255.0;
|
||||
a = ((gdouble)src[x*4+3])/255.0;
|
||||
}
|
||||
else if(bpp == 3)
|
||||
{
|
||||
r = ((gdouble)src[x*3+0])/255.0;
|
||||
g = ((gdouble)src[x*3+1])/255.0;
|
||||
b = ((gdouble)src[x*3+2])/255.0;
|
||||
a = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = ((gdouble)src[x*bpp+0])/255.0;
|
||||
g = b = r;
|
||||
if(bpp == 2)
|
||||
a = ((gdouble)src[x*bpp+1])/255.0;
|
||||
else
|
||||
a = 1.0;
|
||||
}
|
||||
|
||||
if ((x / GIMP_CHECK_SIZE_SM) & 1)
|
||||
{
|
||||
c0 = GIMP_CHECK_LIGHT;
|
||||
c1 = GIMP_CHECK_DARK;
|
||||
}
|
||||
else
|
||||
{
|
||||
c0 = GIMP_CHECK_DARK;
|
||||
c1 = GIMP_CHECK_LIGHT;
|
||||
}
|
||||
|
||||
*p0++ = (c0 + (r - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (g - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (b - c0) * a) * 255.0;
|
||||
|
||||
*p1++ = (c1 + (r - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (g - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (b - c1) * a) * 255.0;
|
||||
|
||||
} /* for */
|
||||
|
||||
if ((y / GIMP_CHECK_SIZE_SM) & 1)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (widget), (guchar *)odd, 0, y, width);
|
||||
else
|
||||
gtk_preview_draw_row (GTK_PREVIEW (widget), (guchar *)even, 0, y, width);
|
||||
|
||||
src += width * bpp;
|
||||
}
|
||||
|
||||
g_free (even);
|
||||
g_free (odd);
|
||||
g_free (drawable_data);
|
||||
}
|
||||
|
|
|
@ -66,11 +66,6 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -83,20 +78,9 @@
|
|||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
/* Some useful macros */
|
||||
|
||||
#if 0
|
||||
#define DEBUG1 printf
|
||||
#else
|
||||
#define DEBUG1 dummy_printf
|
||||
static void dummy_printf(char *fmt, ...) {}
|
||||
#endif
|
||||
|
||||
#define ENTRY_WIDTH 50
|
||||
#define SCALE_WIDTH 125
|
||||
#define TILE_CACHE_SIZE 16
|
||||
#define PREVIEW_SIZE 128
|
||||
|
||||
|
||||
#define PREVIEW 0x1
|
||||
#define CURSOR 0x2
|
||||
|
@ -106,10 +90,7 @@ static void dummy_printf(char *fmt, ...) {}
|
|||
GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK)
|
||||
|
||||
static guchar *preview_bits;
|
||||
static GtkWidget *preview;
|
||||
static gdouble preview_scale_x;
|
||||
static gdouble preview_scale_y;
|
||||
static GimpFixMePreview *preview;
|
||||
static gboolean show_cursor = FALSE;
|
||||
|
||||
typedef struct
|
||||
|
@ -151,10 +132,6 @@ static void run (gchar *name,
|
|||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
|
||||
static void fill_preview_with_thumb (GtkWidget *preview_widget,
|
||||
gint32 drawable_ID);
|
||||
static GtkWidget *preview_widget (GimpDrawable *drawable);
|
||||
|
||||
static void nova (GimpDrawable *drawable,
|
||||
gboolean preview_mode);
|
||||
|
||||
|
@ -321,7 +298,6 @@ run (gchar *name,
|
|||
/* Store data */
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||
gimp_set_data ("plug_in_nova", &pvals, sizeof (NovaValues));
|
||||
g_free(preview_bits); /* this is allocated during preview render */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -335,135 +311,6 @@ run (gchar *name,
|
|||
gimp_drawable_detach (drawable);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
preview_widget (GimpDrawable *drawable)
|
||||
{
|
||||
gint size;
|
||||
GtkWidget *preview;
|
||||
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
fill_preview_with_thumb (preview, drawable->drawable_id);
|
||||
|
||||
size = GTK_PREVIEW (preview)->rowstride *
|
||||
GTK_PREVIEW (preview)->buffer_height;
|
||||
|
||||
preview_bits = g_malloc (size);
|
||||
memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size);
|
||||
|
||||
return preview;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_preview_with_thumb (GtkWidget *widget,
|
||||
gint32 drawable_ID)
|
||||
{
|
||||
guchar *drawable_data;
|
||||
gint bpp;
|
||||
gint x,y;
|
||||
gint width = PREVIEW_SIZE;
|
||||
gint height = PREVIEW_SIZE;
|
||||
guchar *src;
|
||||
GimpRGB color;
|
||||
gdouble c0, c1;
|
||||
guchar *p0, *p1;
|
||||
guchar *even, *odd;
|
||||
|
||||
bpp = 0; /* Only returned */
|
||||
|
||||
drawable_data =
|
||||
gimp_drawable_get_thumbnail_data (drawable_ID, &width, &height, &bpp);
|
||||
|
||||
if (width < 1 || height < 1)
|
||||
return;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (widget), width, height);
|
||||
preview_scale_x =
|
||||
(gdouble) width / (gdouble) gimp_drawable_width (drawable_ID);
|
||||
preview_scale_y =
|
||||
(gdouble) height / (gdouble) gimp_drawable_height (drawable_ID);
|
||||
|
||||
even = g_malloc (width * 3);
|
||||
odd = g_malloc (width * 3);
|
||||
src = drawable_data;
|
||||
|
||||
gimp_rgba_set (&color, 1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
p0 = even;
|
||||
p1 = odd;
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
switch (bpp)
|
||||
{
|
||||
case 4:
|
||||
gimp_rgba_set_uchar (&color,
|
||||
src[x*4+0],
|
||||
src[x*4+1],
|
||||
src[x*4+2],
|
||||
src[x*4+3]);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
gimp_rgb_set_uchar (&color,
|
||||
src[x*3+0],
|
||||
src[x*3+1],
|
||||
src[x*3+2]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
gimp_rgba_set_uchar (&color,
|
||||
src[x*2+0],
|
||||
src[x*2+0],
|
||||
src[x*2+0],
|
||||
src[x*2+1]);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
gimp_rgb_set_uchar (&color,
|
||||
src[x*2+0],
|
||||
src[x*2+0],
|
||||
src[x*2+0]);
|
||||
}
|
||||
|
||||
if ((x / GIMP_CHECK_SIZE_SM) & 1)
|
||||
{
|
||||
c0 = GIMP_CHECK_LIGHT;
|
||||
c1 = GIMP_CHECK_DARK;
|
||||
}
|
||||
else
|
||||
{
|
||||
c0 = GIMP_CHECK_DARK;
|
||||
c1 = GIMP_CHECK_LIGHT;
|
||||
}
|
||||
|
||||
*p0++ = (c0 + (color.r - c0) * color.a) * 255.0;
|
||||
*p0++ = (c0 + (color.g - c0) * color.a) * 255.0;
|
||||
*p0++ = (c0 + (color.b - c0) * color.a) * 255.0;
|
||||
|
||||
*p1++ = (c1 + (color.r - c1) * color.a) * 255.0;
|
||||
*p1++ = (c1 + (color.g - c1) * color.a) * 255.0;
|
||||
*p1++ = (c1 + (color.b - c1) * color.a) * 255.0;
|
||||
|
||||
} /* for */
|
||||
|
||||
if ((y / GIMP_CHECK_SIZE_SM) & 1)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (widget),
|
||||
(guchar *)odd, 0, y, width);
|
||||
else
|
||||
gtk_preview_draw_row (GTK_PREVIEW (widget),
|
||||
(guchar *)even, 0, y, width);
|
||||
|
||||
src += width * bpp;
|
||||
}
|
||||
|
||||
g_free (even);
|
||||
g_free (odd);
|
||||
g_free (drawable_data);
|
||||
}
|
||||
|
||||
|
||||
/*******************/
|
||||
/* Main Dialog */
|
||||
/*******************/
|
||||
|
@ -683,15 +530,15 @@ nova_center_create (GimpDrawable *drawable)
|
|||
0, 0, 0, 0);
|
||||
|
||||
/* PREVIEW */
|
||||
preview = preview_widget (center->drawable);
|
||||
gtk_widget_set_events (GTK_WIDGET (preview), PREVIEW_MASK);
|
||||
gtk_container_add (GTK_CONTAINER (pframe), preview);
|
||||
gtk_widget_show (preview);
|
||||
preview = gimp_fixme_preview_new (center->drawable);
|
||||
gtk_widget_set_events (preview->widget, PREVIEW_MASK);
|
||||
gtk_container_add (GTK_CONTAINER (pframe), preview->widget);
|
||||
gtk_widget_show (preview->widget);
|
||||
|
||||
g_signal_connect_after (G_OBJECT (preview), "expose_event",
|
||||
g_signal_connect_after (G_OBJECT (preview->widget), "expose_event",
|
||||
G_CALLBACK (nova_center_preview_expose),
|
||||
center);
|
||||
g_signal_connect (G_OBJECT (preview), "event",
|
||||
g_signal_connect (G_OBJECT (preview->widget), "event",
|
||||
G_CALLBACK (nova_center_preview_events),
|
||||
center);
|
||||
|
||||
|
@ -721,9 +568,6 @@ nova_center_create (GimpDrawable *drawable)
|
|||
center->in_call = FALSE; /* End of initialization */
|
||||
nova (drawable, TRUE);
|
||||
|
||||
DEBUG1("pvals center=%d,%d\n", pvals.xcenter, pvals.ycenter);
|
||||
DEBUG1("center cur=%d,%d\n", center->curx, center->cury);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
@ -735,7 +579,6 @@ nova_center_destroy (GtkWidget *widget,
|
|||
g_free (center);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Drawing CenterFrame
|
||||
* if update & PREVIEW, draw preview
|
||||
|
@ -746,47 +589,45 @@ static void
|
|||
nova_center_draw (NovaCenter *center,
|
||||
gint update)
|
||||
{
|
||||
GtkWidget *prvw = preview->widget;
|
||||
|
||||
if (update & PREVIEW)
|
||||
{
|
||||
center->cursor = FALSE;
|
||||
DEBUG1 ("draw-preview\n");
|
||||
}
|
||||
|
||||
if (update & CURSOR)
|
||||
{
|
||||
DEBUG1 ("draw-cursor %d old=%d,%d cur=%d,%d\n",
|
||||
center->cursor, center->oldx, center->oldy,
|
||||
center->curx, center->cury);
|
||||
gdk_gc_set_function (preview->style->black_gc, GDK_INVERT);
|
||||
gdk_gc_set_function (prvw->style->black_gc, GDK_INVERT);
|
||||
if (show_cursor)
|
||||
{
|
||||
if (center->cursor)
|
||||
{
|
||||
gdk_draw_line (preview->window,
|
||||
preview->style->black_gc,
|
||||
gdk_draw_line (prvw->window,
|
||||
prvw->style->black_gc,
|
||||
center->oldx, 1, center->oldx,
|
||||
(GTK_PREVIEW (preview)->buffer_height) - 1);
|
||||
gdk_draw_line (preview->window,
|
||||
preview->style->black_gc,
|
||||
preview->height - 1);
|
||||
gdk_draw_line (prvw->window,
|
||||
prvw->style->black_gc,
|
||||
1, center->oldy,
|
||||
(GTK_PREVIEW (preview)->buffer_width) - 1, center->oldy);
|
||||
preview->width - 1, center->oldy);
|
||||
}
|
||||
|
||||
gdk_draw_line (preview->window,
|
||||
preview->style->black_gc,
|
||||
gdk_draw_line (prvw->window,
|
||||
prvw->style->black_gc,
|
||||
center->curx, 1, center->curx,
|
||||
(GTK_PREVIEW (preview)->buffer_height) - 1);
|
||||
gdk_draw_line (preview->window,
|
||||
preview->style->black_gc,
|
||||
preview->height - 1);
|
||||
gdk_draw_line (prvw->window,
|
||||
prvw->style->black_gc,
|
||||
1, center->cury,
|
||||
(GTK_PREVIEW (preview)->buffer_width) - 1, center->cury);
|
||||
preview->width - 1, center->cury);
|
||||
}
|
||||
|
||||
/* current position of cursor is updated */
|
||||
center->oldx = center->curx;
|
||||
center->oldy = center->cury;
|
||||
center->cursor = TRUE;
|
||||
gdk_gc_set_function (preview->style->black_gc, GDK_COPY);
|
||||
gdk_gc_set_function (prvw->style->black_gc, GDK_COPY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -820,20 +661,11 @@ nova_center_adjustment_update (GtkAdjustment *adjustment,
|
|||
static void
|
||||
nova_center_cursor_update (NovaCenter *center)
|
||||
{
|
||||
center->curx = pvals.xcenter *
|
||||
GTK_PREVIEW (preview)->buffer_width / center->dwidth;
|
||||
center->cury = pvals.ycenter *
|
||||
GTK_PREVIEW (preview)->buffer_height / center->dheight;
|
||||
center->curx = pvals.xcenter * preview->width / center->dwidth;
|
||||
center->cury = pvals.ycenter * preview->height / center->dheight;
|
||||
|
||||
if (center->curx < 0)
|
||||
center->curx = 0;
|
||||
else if (center->curx >= GTK_PREVIEW (preview)->buffer_width)
|
||||
center->curx = GTK_PREVIEW (preview)->buffer_width - 1;
|
||||
|
||||
if (center->cury < 0)
|
||||
center->cury = 0;
|
||||
else if (center->cury >= GTK_PREVIEW (preview)->buffer_height)
|
||||
center->cury = GTK_PREVIEW (preview)->buffer_height - 1;
|
||||
center->curx = CLAMP (center->curx, 0, preview->width - 1);
|
||||
center->cury = CLAMP (center->cury, 0, preview->height - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -844,11 +676,7 @@ nova_center_preview_expose (GtkWidget *widget,
|
|||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
NovaCenter *center;
|
||||
|
||||
center = (NovaCenter *) data;
|
||||
nova_center_draw (center, ALL);
|
||||
|
||||
nova_center_draw ((NovaCenter*) data, ALL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -889,10 +717,10 @@ nova_center_preview_events (GtkWidget *widget,
|
|||
center->in_call = TRUE;
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (center->xadj),
|
||||
center->curx * center->dwidth /
|
||||
GTK_PREVIEW (preview)->buffer_width);
|
||||
preview->width);
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (center->yadj),
|
||||
center->cury * center->dheight /
|
||||
GTK_PREVIEW (preview)->buffer_height);
|
||||
preview->height);
|
||||
center->in_call = FALSE;
|
||||
nova (center->drawable, 1);
|
||||
break;
|
||||
|
@ -900,7 +728,6 @@ nova_center_preview_events (GtkWidget *widget,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -978,13 +805,13 @@ nova (GimpDrawable *drawable,
|
|||
|
||||
if (preview_mode)
|
||||
{
|
||||
xc = (gdouble) pvals.xcenter * preview_scale_x;
|
||||
yc = (gdouble) pvals.ycenter * preview_scale_y;
|
||||
xc = (gdouble) pvals.xcenter * preview->scale_x;
|
||||
yc = (gdouble) pvals.ycenter * preview->scale_y;
|
||||
|
||||
x1 = y1 = 0;
|
||||
x2 = GTK_PREVIEW (preview)->buffer_width;
|
||||
y2 = GTK_PREVIEW (preview)->buffer_height;
|
||||
bpp = GTK_PREVIEW (preview)->bpp;
|
||||
x2 = preview->width;
|
||||
y2 = preview->height;
|
||||
bpp = preview->bpp;
|
||||
has_alpha = FALSE;
|
||||
alpha = bpp;
|
||||
}
|
||||
|
@ -1008,10 +835,10 @@ nova (GimpDrawable *drawable,
|
|||
|
||||
if (preview_mode)
|
||||
{
|
||||
src_row = g_malloc (y2 * GTK_PREVIEW (preview)->rowstride);
|
||||
memcpy (src_row, preview_bits, y2 * GTK_PREVIEW (preview)->rowstride);
|
||||
src_row = g_malloc (y2 * preview->rowstride);
|
||||
memcpy (src_row, preview->cache, y2 * preview->rowstride);
|
||||
|
||||
dest_row = g_malloc (GTK_PREVIEW (preview)->rowstride);
|
||||
dest_row = g_malloc (preview->rowstride);
|
||||
|
||||
for (row = 0, y = 0; row < y2; row++, y++)
|
||||
{
|
||||
|
@ -1020,8 +847,8 @@ nova (GimpDrawable *drawable,
|
|||
|
||||
for (col = 0, x = 0; col < x2; col++, x++)
|
||||
{
|
||||
u = (gdouble) (x - xc) / (pvals.radius * preview_scale_x);
|
||||
v = (gdouble) (y - yc) / (pvals.radius * preview_scale_y);
|
||||
u = (gdouble) (x - xc) / (pvals.radius * preview->scale_x);
|
||||
v = (gdouble) (y - yc) / (pvals.radius * preview->scale_y);
|
||||
l = sqrt (u * u + v * v);
|
||||
|
||||
/* This algorithm is still under construction. */
|
||||
|
@ -1068,12 +895,12 @@ nova (GimpDrawable *drawable,
|
|||
dest += bpp;
|
||||
}
|
||||
|
||||
src_row += GTK_PREVIEW (preview)->rowstride;
|
||||
src_row += preview->rowstride;
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview), dest_row, 0, row, y2);
|
||||
gimp_fixme_preview_do_row (preview, row, y2, dest_row);
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (preview);
|
||||
gtk_widget_queue_draw (preview->widget);
|
||||
}
|
||||
else
|
||||
{ /* normal mode */
|
||||
|
|
|
@ -33,11 +33,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -55,7 +50,6 @@
|
|||
#define MAX_THRESHOLD 50
|
||||
#define MIN_STRENGTH 1
|
||||
#define MAX_STRENGTH 50
|
||||
#define PREVIEW_SIZE 128
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -135,11 +129,6 @@ static void reverse_buffer (guchar *buffer,
|
|||
gint length,
|
||||
gint bytes);
|
||||
|
||||
static void fill_preview (GtkWidget *preview_widget,
|
||||
GimpDrawable *drawable);
|
||||
static GtkWidget *preview_widget (GimpDrawable *drawable);
|
||||
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
NULL, /* init_proc */
|
||||
|
@ -178,10 +167,7 @@ config_t config =
|
|||
LEADING /* abs(derivative); */
|
||||
};
|
||||
|
||||
static guchar *preview_cache;
|
||||
static GtkWidget *preview;
|
||||
static gint preview_cache_rowstride;
|
||||
static gint preview_cache_bpp;
|
||||
static GimpFixMePreview *preview;
|
||||
|
||||
MAIN ()
|
||||
|
||||
|
@ -264,7 +250,6 @@ run (gchar *name,
|
|||
status = GIMP_PDB_CALLING_ERROR;
|
||||
break;
|
||||
}
|
||||
g_free(preview_cache);
|
||||
gimp_set_data("plug_in_wind", &config, sizeof(config_t));
|
||||
gimp_displays_flush();
|
||||
break;
|
||||
|
@ -289,8 +274,6 @@ run (gchar *name,
|
|||
*return_vals = values;
|
||||
values[0].type = GIMP_PDB_STATUS;
|
||||
values[0].data.d_status = status;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static gint
|
||||
|
@ -310,78 +293,6 @@ render_effect (GimpDrawable *drawable,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
preview_do_row(gint row,
|
||||
gint width,
|
||||
guchar *even,
|
||||
guchar *odd,
|
||||
guchar *src)
|
||||
{
|
||||
gint x;
|
||||
|
||||
guchar *p0 = even;
|
||||
guchar *p1 = odd;
|
||||
|
||||
gdouble r, g, b, a;
|
||||
gdouble c0, c1;
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
if (preview_cache_bpp == 4)
|
||||
{
|
||||
r = ((gdouble)src[x*4+0]) / 255.0;
|
||||
g = ((gdouble)src[x*4+1]) / 255.0;
|
||||
b = ((gdouble)src[x*4+2]) / 255.0;
|
||||
a = ((gdouble)src[x*4+3]) / 255.0;
|
||||
}
|
||||
else if (preview_cache_bpp == 3)
|
||||
{
|
||||
r = ((gdouble)src[x*3+0]) / 255.0;
|
||||
g = ((gdouble)src[x*3+1]) / 255.0;
|
||||
b = ((gdouble)src[x*3+2]) / 255.0;
|
||||
a = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = ((gdouble)src[x*preview_cache_bpp+0]) / 255.0;
|
||||
g = b = r;
|
||||
if (preview_cache_bpp == 2)
|
||||
a = ((gdouble)src[x*preview_cache_bpp+1]) / 255.0;
|
||||
else
|
||||
a = 1.0;
|
||||
}
|
||||
|
||||
if ((x / GIMP_CHECK_SIZE) & 1)
|
||||
{
|
||||
c0 = GIMP_CHECK_LIGHT;
|
||||
c1 = GIMP_CHECK_DARK;
|
||||
}
|
||||
else
|
||||
{
|
||||
c0 = GIMP_CHECK_DARK;
|
||||
c1 = GIMP_CHECK_LIGHT;
|
||||
}
|
||||
|
||||
*p0++ = (c0 + (r - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (g - c0) * a) * 255.0;
|
||||
*p0++ = (c0 + (b - c0) * a) * 255.0;
|
||||
|
||||
*p1++ = (c1 + (r - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (g - c1) * a) * 255.0;
|
||||
*p1++ = (c1 + (b - c1) * a) * 255.0;
|
||||
|
||||
} /* for */
|
||||
|
||||
if ((row / GIMP_CHECK_SIZE) & 1)
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview), (guchar *)odd, 0, row, width);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview), (guchar *)even, 0, row, width);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
render_blast (GimpDrawable *drawable,
|
||||
gint threshold,
|
||||
|
@ -400,22 +311,18 @@ render_blast (GimpDrawable *drawable,
|
|||
gint row_stride;
|
||||
gint marker = 0;
|
||||
gint lpi;
|
||||
guchar *odd = NULL;
|
||||
guchar *even = NULL;
|
||||
|
||||
if (preview_mode)
|
||||
{
|
||||
width = GTK_PREVIEW (preview)->buffer_width;
|
||||
height = GTK_PREVIEW (preview)->buffer_height;
|
||||
bytes = preview_cache_bpp;
|
||||
width = preview->width;
|
||||
height = preview->height;
|
||||
bytes = preview->bpp;
|
||||
|
||||
x1 = y1 = 0;
|
||||
x2 = width;
|
||||
y2 = height;
|
||||
|
||||
row_stride = preview_cache_rowstride;
|
||||
even = g_malloc (width * 3);
|
||||
odd = g_malloc (width * 3);
|
||||
row_stride = preview->rowstride;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -438,7 +345,7 @@ render_blast (GimpDrawable *drawable,
|
|||
for (row = y1; row < y2; row++)
|
||||
{
|
||||
if (preview_mode)
|
||||
memcpy (buffer, preview_cache + (row * row_stride), row_stride);
|
||||
memcpy (buffer, preview->cache + (row * row_stride), row_stride);
|
||||
else
|
||||
gimp_pixel_rgn_get_row (&src_region, buffer, x1, row, width);
|
||||
|
||||
|
@ -456,7 +363,7 @@ render_blast (GimpDrawable *drawable,
|
|||
|
||||
if (preview_mode)
|
||||
{
|
||||
preview_do_row(row,width,even,odd,buffer);
|
||||
gimp_fixme_preview_do_row(preview, row, width, buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -476,8 +383,8 @@ render_blast (GimpDrawable *drawable,
|
|||
{
|
||||
if (preview_mode)
|
||||
{
|
||||
memcpy (buffer, preview_cache + (row * row_stride), row_stride);
|
||||
preview_do_row(row,width,even,odd,buffer);
|
||||
memcpy (buffer, preview->cache + (row * row_stride), row_stride);
|
||||
gimp_fixme_preview_do_row(preview, row, width, buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -490,18 +397,12 @@ render_blast (GimpDrawable *drawable,
|
|||
}
|
||||
}
|
||||
|
||||
if(even)
|
||||
g_free(even);
|
||||
|
||||
if(odd)
|
||||
g_free(odd);
|
||||
|
||||
g_free(buffer);
|
||||
|
||||
/* update the region */
|
||||
if (preview_mode)
|
||||
{
|
||||
gtk_widget_queue_draw (preview);
|
||||
gtk_widget_queue_draw (preview->widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -509,8 +410,6 @@ render_blast (GimpDrawable *drawable,
|
|||
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
||||
gimp_drawable_update (drawable->drawable_id, x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -531,22 +430,18 @@ render_wind (GimpDrawable *drawable,
|
|||
guchar *sb;
|
||||
gint lpi;
|
||||
gint x1, y1, x2, y2;
|
||||
guchar *odd = NULL;
|
||||
guchar *even = NULL;
|
||||
|
||||
if (preview_mode)
|
||||
{
|
||||
width = GTK_PREVIEW (preview)->buffer_width;
|
||||
height = GTK_PREVIEW (preview)->buffer_height;
|
||||
bytes = preview_cache_bpp;
|
||||
width = preview->width;
|
||||
height = preview->height;
|
||||
bytes = preview->bpp;
|
||||
|
||||
x1 = y1 = 0;
|
||||
x2 = width;
|
||||
y2 = height;
|
||||
|
||||
row_stride = preview_cache_rowstride;
|
||||
even = g_malloc (width * 3);
|
||||
odd = g_malloc (width * 3);
|
||||
row_stride = preview->rowstride;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -571,7 +466,7 @@ render_wind (GimpDrawable *drawable,
|
|||
for (row = y1; row < y2; row++)
|
||||
{
|
||||
if (preview_mode)
|
||||
memcpy (sb, preview_cache + (row * row_stride), row_stride);
|
||||
memcpy (sb, preview->cache + (row * row_stride), row_stride);
|
||||
else
|
||||
gimp_pixel_rgn_get_row (&src_region, sb, x1, row, width);
|
||||
|
||||
|
@ -585,7 +480,7 @@ render_wind (GimpDrawable *drawable,
|
|||
|
||||
if (preview_mode)
|
||||
{
|
||||
preview_do_row(row,width,even,odd,sb);
|
||||
gimp_fixme_preview_do_row(preview, row, width, sb);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -594,18 +489,12 @@ render_wind (GimpDrawable *drawable,
|
|||
}
|
||||
}
|
||||
|
||||
if(even)
|
||||
g_free(even);
|
||||
|
||||
if(odd)
|
||||
g_free(odd);
|
||||
|
||||
g_free(sb);
|
||||
|
||||
/* update the region */
|
||||
if (preview_mode)
|
||||
{
|
||||
gtk_widget_queue_draw (preview);
|
||||
gtk_widget_queue_draw (preview->widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -613,8 +502,6 @@ render_wind (GimpDrawable *drawable,
|
|||
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
||||
gimp_drawable_update (drawable->drawable_id, x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static gint
|
||||
|
@ -831,7 +718,6 @@ render_wind_row (guchar *sb,
|
|||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static gint
|
||||
|
@ -911,7 +797,6 @@ get_derivative (guchar *pixel_R1,
|
|||
{
|
||||
/* no change needed */
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -967,12 +852,11 @@ static void
|
|||
radio_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
|
||||
gimp_radio_button_update (widget, data);
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
drawable = g_object_get_data (G_OBJECT (widget), "drawable");
|
||||
|
||||
if (drawable != NULL)
|
||||
|
@ -1036,10 +920,11 @@ dialog_box (GimpDrawable *drawable)
|
|||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_container_add (GTK_CONTAINER (abox), frame);
|
||||
gtk_widget_show (frame);
|
||||
preview = preview_widget (drawable); /* we are here */
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview);
|
||||
render_effect (drawable, TRUE); /* render preview image */
|
||||
gtk_widget_show (preview);
|
||||
preview = gimp_fixme_preview_new (NULL);
|
||||
gimp_fixme_preview_fill (preview, drawable);
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview->widget);
|
||||
render_effect (drawable, TRUE);
|
||||
gtk_widget_show (preview->widget);
|
||||
|
||||
frame = gtk_frame_new (_("Parameter Settings"));
|
||||
gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
|
||||
|
@ -1192,72 +1077,3 @@ dialog_box (GimpDrawable *drawable)
|
|||
gimp_help_free ();
|
||||
gdk_flush ();
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
preview_widget (GimpDrawable *drawable)
|
||||
{
|
||||
gint size;
|
||||
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
fill_preview (preview, drawable);
|
||||
size = GTK_PREVIEW (preview)->rowstride * GTK_PREVIEW (preview)->buffer_height;
|
||||
|
||||
return preview;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_preview (GtkWidget *widget,
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
GimpPixelRgn srcPR;
|
||||
gint width;
|
||||
gint height;
|
||||
gint x1, x2, y1, y2;
|
||||
gint bpp;
|
||||
gint y;
|
||||
guchar *src;
|
||||
guchar *even, *odd;
|
||||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||
|
||||
if (x2 - x1 > PREVIEW_SIZE)
|
||||
x2 = x1 + PREVIEW_SIZE;
|
||||
|
||||
if (y2 - y1 > PREVIEW_SIZE)
|
||||
y2 = y1 + PREVIEW_SIZE;
|
||||
|
||||
width = x2 - x1;
|
||||
height = y2 - y1;
|
||||
bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
|
||||
if (width < 1 || height < 1)
|
||||
return;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (widget), width, height);
|
||||
|
||||
gimp_pixel_rgn_init (&srcPR, drawable, x1, y1, x2, y2, FALSE, FALSE);
|
||||
|
||||
even = g_malloc (width * 3);
|
||||
odd = g_malloc (width * 3);
|
||||
src = g_malloc (width * bpp);
|
||||
preview_cache = g_malloc(width * bpp * height);
|
||||
preview_cache_rowstride = width * bpp;
|
||||
preview_cache_bpp = bpp;
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
gimp_pixel_rgn_get_row (&srcPR, src, x1, y + y1, width);
|
||||
memcpy(preview_cache + (y*width*bpp),src,width*bpp);
|
||||
}
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
preview_do_row(y,width,even,odd,preview_cache + (y*width*bpp));
|
||||
}
|
||||
|
||||
|
||||
g_free (even);
|
||||
g_free (odd);
|
||||
g_free (src);
|
||||
}
|
||||
|
|
|
@ -231,8 +231,8 @@ init_generated_constants (void)
|
|||
setvar (cintern ("VERTICAL"), flocons (1), NIL);
|
||||
setvar (cintern ("UNKNOWN"), flocons (2), NIL);
|
||||
|
||||
setvar (cintern ("PIXELS"), flocons (0), NIL);
|
||||
setvar (cintern ("POINTS"), flocons (1), NIL);
|
||||
setvar (cintern ("SIZE-PIXELS"), flocons (0), NIL);
|
||||
setvar (cintern ("SIZE-POINTS"), flocons (1), NIL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue