Moved GimpOldPreview from libgimp/gimpmiscui to its own not installed library.

This commit is contained in:
David Odin 2003-12-11 18:16:47 +00:00
parent 73cf6a00bc
commit 8be2e2dd7d
25 changed files with 742 additions and 541 deletions

View File

@ -1,3 +1,35 @@
2003-12-11 DindinX <david@dindinx.org>
* libgimp/gimpmiscui.c:
* libgimp/gimpmiscui.h: removed GimpOld preview...
* plug-ins/libgimpoldpreview/Makefile.am:
* plug-ins/libgimpoldpreview/gimpoldpreview.c:
* plug-ins/libgimpoldpreview/gimpoldpreview.h: ... and added it there
as a noinst library, so foreign plug-ins won't use it.
* configure.in:
* plug-ins/Makefile.am:
* plug-ins/common/Makefile.am:
* plug-ins/common/AlienMap.c:
* plug-ins/common/AlienMap2.c:
* plug-ins/common/blinds.c:
* plug-ins/common/flarefx.c:
* plug-ins/common/glasstile.c:
* plug-ins/common/grid.c:
* plug-ins/common/illusion.c:
* plug-ins/common/jigsaw.c:
* plug-ins/common/max_rgb.c:
* plug-ins/common/nlfilt.c:
* plug-ins/common/noisify.c:
* plug-ins/common/nova.c:
* plug-ins/common/plasma.c:
* plug-ins/common/polar.c:
* plug-ins/common/waves.c:
* plug-ins/common/wind.c: Changed accordingly.
2003-12-11 Michael Natterer <mitch@gimp.org>
* app/widgets/gimphistogramview.[ch]: added properties "border-width"

View File

@ -1408,6 +1408,7 @@ app/xcf/Makefile
plug-ins/Makefile
plug-ins/libgck/Makefile
plug-ins/libgck/gck/Makefile
plug-ins/libgimpoldpreview/Makefile
plug-ins/dbbrowser/Makefile
plug-ins/script-fu/Makefile
plug-ins/script-fu/siod/Makefile

View File

@ -38,476 +38,6 @@
#include "libgimp-intl.h"
#define PREVIEW_SIZE 128
#define PREVIEW_BPP 3
static void
gimp_old_preview_put_in_frame (GimpOldPreview* preview)
{
GtkWidget *frame, *abox;
preview->frame = gtk_frame_new (_("Preview"));
gtk_widget_show (preview->frame);
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (abox), 4);
gtk_container_add (GTK_CONTAINER (preview->frame), abox);
gtk_widget_show (abox);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (abox), frame);
gtk_widget_show (frame);
gtk_container_add (GTK_CONTAINER (frame), preview->widget);
}
GimpOldPreview*
gimp_old_preview_new (GimpDrawable *drawable,
gboolean has_frame)
{
GimpOldPreview *preview = g_new0 (GimpOldPreview, 1);
preview->widget = gtk_preview_new (GTK_PREVIEW_COLOR);
preview->is_gray = FALSE;
if (drawable)
gimp_old_preview_fill_with_thumb (preview, drawable->drawable_id);
if (has_frame)
gimp_old_preview_put_in_frame (preview);
return preview;
}
void
gimp_old_preview_free (GimpOldPreview *preview)
{
g_free (preview->cmap);
g_free (preview->even);
g_free (preview->odd);
g_free (preview->cache);
g_free (preview);
}
GimpOldPreview*
gimp_old_preview_new2 (GimpImageType drawable_type,
gboolean has_frame)
{
GimpOldPreview *preview;
guchar *buf = NULL;
gint y;
preview = g_new0 (GimpOldPreview, 1);
switch (drawable_type)
{
case GIMP_GRAY_IMAGE:
case GIMP_GRAYA_IMAGE:
preview->widget = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
buf = g_malloc0 (PREVIEW_SIZE);
preview->is_gray = TRUE;
break;
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
preview->widget = gtk_preview_new (GTK_PREVIEW_COLOR);
buf = g_malloc0 (PREVIEW_SIZE * 3);
preview->is_gray = FALSE;
break;
default:
g_assert_not_reached ();
break;
}
gtk_preview_size (GTK_PREVIEW (preview->widget), PREVIEW_SIZE, PREVIEW_SIZE);
for (y = 0; y < PREVIEW_SIZE; y++)
gtk_preview_draw_row (GTK_PREVIEW (preview->widget), buf, 0, y,
PREVIEW_SIZE);
g_free (buf);
if (has_frame)
gimp_old_preview_put_in_frame (preview);
preview->buffer = GTK_PREVIEW (preview->widget)->buffer;
preview->width = GTK_PREVIEW (preview->widget)->buffer_width;
preview->height = GTK_PREVIEW (preview->widget)->buffer_height;
preview->rowstride = preview->width * ((preview->is_gray) ? 1 : 3);
return preview;
}
void
gimp_old_preview_put_pixel (GimpOldPreview *preview,
gint x,
gint y,
const guchar *pixel)
{
guchar *dest;
g_return_if_fail (x >= 0 && x < PREVIEW_SIZE);
g_return_if_fail (y >= 0 && y < PREVIEW_SIZE);
dest = preview->buffer + y * preview->rowstride;
if (preview->is_gray)
{
dest += x;
dest[0] = pixel[0];
}
else
{
dest += x * 3;
dest[0] = pixel[0];
dest[1] = pixel[1];
dest[2] = pixel[2];
}
}
void
gimp_old_preview_get_pixel (GimpOldPreview *preview,
gint x,
gint y,
guchar *pixel)
{
const guchar *src;
g_return_if_fail (x >= 0 && x < PREVIEW_SIZE);
g_return_if_fail (y >= 0 && y < PREVIEW_SIZE);
src = preview->buffer + y * preview->rowstride;
if (preview->is_gray)
{
src += x;
pixel[0] = src[0];
}
else
{
src += x * 3;
pixel[0] = src[0];
pixel[1] = src[1];
pixel[2] = src[2];
}
}
void
gimp_old_preview_do_row (GimpOldPreview *preview,
gint row,
gint width,
const guchar *src)
{
gint x;
guchar *p0 = preview->even;
guchar *p1 = preview->odd;
gint bpp = preview->bpp;
gint r, g, b, a;
gint c0, c1;
for (x = 0; x < width; x++)
{
switch (bpp)
{
case 4:
r = src[x * 4 + 0];
g = src[x * 4 + 1];
b = src[x * 4 + 2];
a = src[x * 4 + 3];
break;
case 3:
r = src[x*3 + 0];
g = src[x*3 + 1];
b = src[x*3 + 2];
a = 255;
break;
default:
if (preview->cmap)
{
gint index = MIN (src[x*bpp], preview->ncolors - 1);
r = preview->cmap[index * 3 + 0];
g = preview->cmap[index * 3 + 1];
b = preview->cmap[index * 3 + 2];
}
else
{
g = b = r = src[x * bpp + 0];
}
if (bpp == 2)
a = src[x*2 + 1];
else
a = 255;
break;
}
if ((x / GIMP_CHECK_SIZE_SM) & 1)
{
c0 = GIMP_CHECK_LIGHT * 255;
c1 = GIMP_CHECK_DARK * 255;
}
else
{
c0 = GIMP_CHECK_DARK * 255;
c1 = GIMP_CHECK_LIGHT * 255;
}
*p0++ = c0 + (r - c0) * a / 255;
*p0++ = c0 + (g - c0) * a / 255;
*p0++ = c0 + (b - c0) * a / 255;
*p1++ = c1 + (r - c1) * a / 255;
*p1++ = c1 + (g - c1) * a / 255;
*p1++ = c1 + (b - c1) * a / 255;
}
if ((row / GIMP_CHECK_SIZE_SM) & 1)
{
gtk_preview_draw_row (GTK_PREVIEW (preview->widget),
preview->odd, 0, row, width);
}
else
{
gtk_preview_draw_row (GTK_PREVIEW (preview->widget),
preview->even, 0, row, width);
}
}
void
gimp_old_preview_update (GimpOldPreview *preview,
GimpOldPreviewFunc func,
gpointer data)
{
guchar *buffer;
gint x, y;
gint bpp;
bpp = preview->bpp;
buffer = g_new (guchar, preview->rowstride);
for (y = 0; y < preview->height; y++)
{
const guchar *src = preview->cache + y * preview->rowstride;
guchar *dest = buffer;
for (x = 0; x < preview->width; x++)
{
func (src, dest, bpp, data);
src += bpp;
dest += bpp;
}
gimp_old_preview_do_row (preview, y, preview->width, buffer);
}
gtk_widget_queue_draw (preview->widget);
g_free (buffer);
}
void
gimp_old_preview_fill_with_thumb (GimpOldPreview *preview,
gint32 drawable_ID)
{
const guchar *src;
gint bpp;
gint y;
gint width = PREVIEW_SIZE;
gint height = PREVIEW_SIZE;
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;
if (gimp_drawable_is_indexed (drawable_ID))
{
gint32 image_ID = gimp_drawable_get_image (drawable_ID);
preview->cmap = gimp_image_get_cmap (image_ID, &preview->ncolors);
}
else
{
preview->cmap = NULL;
}
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_old_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_old_preview_fill (GimpOldPreview *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);
if (gimp_drawable_is_indexed (drawable->drawable_id))
{
gint32 image_ID = gimp_drawable_get_image (drawable->drawable_id);
preview->cmap = gimp_image_get_cmap (image_ID, &preview->ncolors);
}
else
{
preview->cmap = NULL;
}
gtk_preview_size (GTK_PREVIEW (preview->widget), width, height);
gimp_pixel_rgn_init (&srcPR, drawable, x1, y1, width, height, 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_old_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);
}
void
gimp_old_preview_fill_scaled (GimpOldPreview *preview,
GimpDrawable *drawable)
{
gint bpp;
gint x1, y1, x2, y2;
gint sel_width, sel_height;
gint width, height;
gdouble px, py;
gdouble dx, dy;
gint x, y;
guchar *dest;
GimpPixelFetcher *pft;
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
sel_width = x2 - x1;
sel_height = y2 - y1;
/* Calculate preview size */
if (sel_width > sel_height)
{
width = MIN (sel_width, PREVIEW_SIZE);
height = sel_height * width / sel_width;
}
else
{
height = MIN(sel_height, PREVIEW_SIZE);
width = sel_width * height / sel_height;
}
if (width < 2) width = 2;
if (height < 2) height = 2;
bpp = gimp_drawable_bpp (drawable->drawable_id);
if (gimp_drawable_is_indexed (drawable->drawable_id))
{
gint32 image_ID = gimp_drawable_get_image (drawable->drawable_id);
preview->cmap = gimp_image_get_cmap (image_ID, &preview->ncolors);
}
else
{
preview->cmap = NULL;
}
gtk_preview_size (GTK_PREVIEW (preview->widget), width, height);
preview->even = g_malloc (width * 3);
preview->odd = g_malloc (width * 3);
preview->cache = g_malloc (width * bpp * height);
preview->rowstride = width * bpp;
preview->bpp = bpp;
dx = (gdouble) (x2 - x1 - 1) / (width - 1);
dy = (gdouble) (y2 - y1 - 1) / (height - 1);
py = y1;
pft = gimp_pixel_fetcher_new (drawable);
for (y = 0; y < height; y++)
{
dest = preview->cache + y * preview->rowstride;
px = x1;
for (x = 0; x < width; x++)
{
gimp_pixel_fetcher_get_pixel (pft, (gint) px, (gint) py, dest);
dest += bpp;
px += dx;
}
gimp_old_preview_do_row (preview, y, width, dest);
py += dy;
}
gimp_pixel_fetcher_destroy (pft);
preview->buffer = GTK_PREVIEW (preview->widget)->buffer;
preview->width = GTK_PREVIEW (preview->widget)->buffer_width;
preview->height = GTK_PREVIEW (preview->widget)->buffer_height;
}
gchar *
gimp_plug_in_get_path (const gchar *path_name,
const gchar *dir_name)

View File

@ -26,75 +26,10 @@
#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;
GtkWidget *frame;
guchar *cache;
guchar *even;
guchar *odd;
guchar *buffer;
gint width;
gint height;
gint rowstride;
gint bpp; /* bpp of the drawable */
guchar *cmap;
gint ncolors;
gdouble scale_x;
gdouble scale_y;
gboolean is_gray;
} GimpOldPreview;
typedef void (*GimpOldPreviewFunc) (const guchar *src,
guchar *dest,
gint bpp,
gpointer data);
GimpOldPreview * gimp_old_preview_new (GimpDrawable *drawable,
gboolean has_frame);
GimpOldPreview * gimp_old_preview_new2 (GimpImageType drawable_type,
gboolean has_frame);
void gimp_old_preview_free (GimpOldPreview *preview);
void gimp_old_preview_update (GimpOldPreview *preview,
GimpOldPreviewFunc func,
gpointer data);
void gimp_old_preview_fill_with_thumb (GimpOldPreview *preview,
gint32 drawable_ID);
void gimp_old_preview_fill (GimpOldPreview *preview,
GimpDrawable *drawable);
void gimp_old_preview_fill_scaled (GimpOldPreview *preview,
GimpDrawable *drawable);
void gimp_old_preview_do_row (GimpOldPreview *preview,
gint row,
gint width,
const guchar *src);
void gimp_old_preview_put_pixel (GimpOldPreview *preview,
gint x,
gint y,
const guchar *pixel);
void gimp_old_preview_get_pixel (GimpOldPreview *preview,
gint x,
gint y,
guchar *pixel);
gchar * gimp_plug_in_get_path (const gchar *path_name,
const gchar *dir_name);

View File

@ -28,6 +28,7 @@ endif
SUBDIRS = \
libgck \
libgimpoldpreview \
dbbrowser \
script-fu \
FractalExplorer \

View File

@ -47,6 +47,7 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
#define RESPONSE_ABOUT 1

View File

@ -42,6 +42,7 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
#define RESPONSE_ABOUT 1

View File

@ -14,6 +14,7 @@ EXTRA_DIST = \
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/plug-ins/libgimpoldpreview \
@GTK_CFLAGS@ \
@X_CFLAGS@ \
@EXIF_CFLAGS@ \
@ -195,6 +196,7 @@ AlienMap_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -207,6 +209,7 @@ AlienMap2_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -322,6 +325,7 @@ blinds_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -679,6 +683,7 @@ flarefx_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -809,6 +814,7 @@ glasstile_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -845,6 +851,7 @@ grid_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -925,6 +932,7 @@ illusion_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -949,6 +957,7 @@ jigsaw_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -1024,6 +1033,7 @@ max_rgb_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -1085,6 +1095,7 @@ nlfilt_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -1097,6 +1108,7 @@ noisify_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -1119,6 +1131,7 @@ nova_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -1203,6 +1216,7 @@ plasma_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -1252,6 +1266,7 @@ polar_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -1701,6 +1716,7 @@ waves_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@
@ -1748,6 +1764,7 @@ wind_LDADD = \
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
@GTK_LIBS@ \
@INTLLIBS@

View File

@ -61,6 +61,7 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
/***** Magic numbers *****/

View File

@ -56,6 +56,7 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
/* --- Defines --- */
#define ENTRY_WIDTH 75

View File

@ -50,6 +50,8 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
/* --- Typedefs --- */
typedef struct
{

View File

@ -50,6 +50,7 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
#define SPIN_BUTTON_WIDTH 8
#define COLOR_BUTTON_WIDTH 55

View File

@ -37,6 +37,7 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
#define PLUG_IN_NAME "plug_in_illusion"
#define PLUG_IN_VERSION "v0.8 (May 14 2000)"

View File

@ -46,6 +46,8 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
typedef enum
{
BEZIER_1,

View File

@ -37,6 +37,7 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
/* Replace them with the right ones */
#define PLUG_IN_NAME "plug_in_max_rgb"

View File

@ -46,6 +46,8 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
typedef struct
{
gint32 img;

View File

@ -45,6 +45,7 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
#define SCALE_WIDTH 125
#define TILE_CACHE_SIZE 16

View File

@ -73,6 +73,7 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
#ifdef RCSID
static char rcsid[] = "$Id$";

View File

@ -67,6 +67,7 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
/* Some useful macros */

View File

@ -70,6 +70,7 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
#define WITHIN(a, b, c) ((((a) <= (b)) && ((b) <= (c))) ? 1 : 0)

View File

@ -38,6 +38,7 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
enum
{

View File

@ -40,6 +40,7 @@
#include "libgimp/stdplugins-intl.h"
#include "gimpoldpreview.h"
#define PLUG_IN_NAME "wind"

View File

@ -0,0 +1,15 @@
## Process this file with automake to produce Makefile.in
noinst_LIBRARIES = libgimpoldpreview.a
libgimpoldpreview_a_SOURCES = \
gimpoldpreview.c \
gimpoldpreview.h
INCLUDES = \
-I.. \
-I$(srcdir)/.. \
-I$(top_srcdir) \
-I$(top_srcdir)/libgimp \
$(GTK_CFLAGS) \
-I$(includedir)

View File

@ -0,0 +1,548 @@
/* 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.
*/
#include "config.h"
#include <string.h>
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h>
#include "gimp.h"
#include "gimpoldpreview.h"
#include "libgimp-intl.h"
#define PREVIEW_SIZE 128
#define PREVIEW_BPP 3
static void
gimp_old_preview_put_in_frame (GimpOldPreview* preview)
{
GtkWidget *frame, *abox;
preview->frame = gtk_frame_new (_("Preview"));
gtk_widget_show (preview->frame);
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (abox), 4);
gtk_container_add (GTK_CONTAINER (preview->frame), abox);
gtk_widget_show (abox);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (abox), frame);
gtk_widget_show (frame);
gtk_container_add (GTK_CONTAINER (frame), preview->widget);
}
GimpOldPreview*
gimp_old_preview_new (GimpDrawable *drawable,
gboolean has_frame)
{
GimpOldPreview *preview = g_new0 (GimpOldPreview, 1);
preview->widget = gtk_preview_new (GTK_PREVIEW_COLOR);
preview->is_gray = FALSE;
if (drawable)
gimp_old_preview_fill_with_thumb (preview, drawable->drawable_id);
if (has_frame)
gimp_old_preview_put_in_frame (preview);
return preview;
}
void
gimp_old_preview_free (GimpOldPreview *preview)
{
g_free (preview->cmap);
g_free (preview->even);
g_free (preview->odd);
g_free (preview->cache);
g_free (preview);
}
GimpOldPreview*
gimp_old_preview_new2 (GimpImageType drawable_type,
gboolean has_frame)
{
GimpOldPreview *preview;
guchar *buf = NULL;
gint y;
preview = g_new0 (GimpOldPreview, 1);
switch (drawable_type)
{
case GIMP_GRAY_IMAGE:
case GIMP_GRAYA_IMAGE:
preview->widget = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
buf = g_malloc0 (PREVIEW_SIZE);
preview->is_gray = TRUE;
break;
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
preview->widget = gtk_preview_new (GTK_PREVIEW_COLOR);
buf = g_malloc0 (PREVIEW_SIZE * 3);
preview->is_gray = FALSE;
break;
default:
g_assert_not_reached ();
break;
}
gtk_preview_size (GTK_PREVIEW (preview->widget), PREVIEW_SIZE, PREVIEW_SIZE);
for (y = 0; y < PREVIEW_SIZE; y++)
gtk_preview_draw_row (GTK_PREVIEW (preview->widget), buf, 0, y,
PREVIEW_SIZE);
g_free (buf);
if (has_frame)
gimp_old_preview_put_in_frame (preview);
preview->buffer = GTK_PREVIEW (preview->widget)->buffer;
preview->width = GTK_PREVIEW (preview->widget)->buffer_width;
preview->height = GTK_PREVIEW (preview->widget)->buffer_height;
preview->rowstride = preview->width * ((preview->is_gray) ? 1 : 3);
return preview;
}
void
gimp_old_preview_put_pixel (GimpOldPreview *preview,
gint x,
gint y,
const guchar *pixel)
{
guchar *dest;
g_return_if_fail (x >= 0 && x < PREVIEW_SIZE);
g_return_if_fail (y >= 0 && y < PREVIEW_SIZE);
dest = preview->buffer + y * preview->rowstride;
if (preview->is_gray)
{
dest += x;
dest[0] = pixel[0];
}
else
{
dest += x * 3;
dest[0] = pixel[0];
dest[1] = pixel[1];
dest[2] = pixel[2];
}
}
void
gimp_old_preview_get_pixel (GimpOldPreview *preview,
gint x,
gint y,
guchar *pixel)
{
const guchar *src;
g_return_if_fail (x >= 0 && x < PREVIEW_SIZE);
g_return_if_fail (y >= 0 && y < PREVIEW_SIZE);
src = preview->buffer + y * preview->rowstride;
if (preview->is_gray)
{
src += x;
pixel[0] = src[0];
}
else
{
src += x * 3;
pixel[0] = src[0];
pixel[1] = src[1];
pixel[2] = src[2];
}
}
void
gimp_old_preview_do_row (GimpOldPreview *preview,
gint row,
gint width,
const guchar *src)
{
gint x;
guchar *p0 = preview->even;
guchar *p1 = preview->odd;
gint bpp = preview->bpp;
gint r, g, b, a;
gint c0, c1;
for (x = 0; x < width; x++)
{
switch (bpp)
{
case 4:
r = src[x * 4 + 0];
g = src[x * 4 + 1];
b = src[x * 4 + 2];
a = src[x * 4 + 3];
break;
case 3:
r = src[x*3 + 0];
g = src[x*3 + 1];
b = src[x*3 + 2];
a = 255;
break;
default:
if (preview->cmap)
{
gint index = MIN (src[x*bpp], preview->ncolors - 1);
r = preview->cmap[index * 3 + 0];
g = preview->cmap[index * 3 + 1];
b = preview->cmap[index * 3 + 2];
}
else
{
g = b = r = src[x * bpp + 0];
}
if (bpp == 2)
a = src[x*2 + 1];
else
a = 255;
break;
}
if ((x / GIMP_CHECK_SIZE_SM) & 1)
{
c0 = GIMP_CHECK_LIGHT * 255;
c1 = GIMP_CHECK_DARK * 255;
}
else
{
c0 = GIMP_CHECK_DARK * 255;
c1 = GIMP_CHECK_LIGHT * 255;
}
*p0++ = c0 + (r - c0) * a / 255;
*p0++ = c0 + (g - c0) * a / 255;
*p0++ = c0 + (b - c0) * a / 255;
*p1++ = c1 + (r - c1) * a / 255;
*p1++ = c1 + (g - c1) * a / 255;
*p1++ = c1 + (b - c1) * a / 255;
}
if ((row / GIMP_CHECK_SIZE_SM) & 1)
{
gtk_preview_draw_row (GTK_PREVIEW (preview->widget),
preview->odd, 0, row, width);
}
else
{
gtk_preview_draw_row (GTK_PREVIEW (preview->widget),
preview->even, 0, row, width);
}
}
void
gimp_old_preview_update (GimpOldPreview *preview,
GimpOldPreviewFunc func,
gpointer data)
{
guchar *buffer;
gint x, y;
gint bpp;
bpp = preview->bpp;
buffer = g_new (guchar, preview->rowstride);
for (y = 0; y < preview->height; y++)
{
const guchar *src = preview->cache + y * preview->rowstride;
guchar *dest = buffer;
for (x = 0; x < preview->width; x++)
{
func (src, dest, bpp, data);
src += bpp;
dest += bpp;
}
gimp_old_preview_do_row (preview, y, preview->width, buffer);
}
gtk_widget_queue_draw (preview->widget);
g_free (buffer);
}
void
gimp_old_preview_fill_with_thumb (GimpOldPreview *preview,
gint32 drawable_ID)
{
const guchar *src;
gint bpp;
gint y;
gint width = PREVIEW_SIZE;
gint height = PREVIEW_SIZE;
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;
if (gimp_drawable_is_indexed (drawable_ID))
{
gint32 image_ID = gimp_drawable_get_image (drawable_ID);
preview->cmap = gimp_image_get_cmap (image_ID, &preview->ncolors);
}
else
{
preview->cmap = NULL;
}
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_old_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_old_preview_fill (GimpOldPreview *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);
if (gimp_drawable_is_indexed (drawable->drawable_id))
{
gint32 image_ID = gimp_drawable_get_image (drawable->drawable_id);
preview->cmap = gimp_image_get_cmap (image_ID, &preview->ncolors);
}
else
{
preview->cmap = NULL;
}
gtk_preview_size (GTK_PREVIEW (preview->widget), width, height);
gimp_pixel_rgn_init (&srcPR, drawable, x1, y1, width, height, 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_old_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);
}
void
gimp_old_preview_fill_scaled (GimpOldPreview *preview,
GimpDrawable *drawable)
{
gint bpp;
gint x1, y1, x2, y2;
gint sel_width, sel_height;
gint width, height;
gdouble px, py;
gdouble dx, dy;
gint x, y;
guchar *dest;
GimpPixelFetcher *pft;
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
sel_width = x2 - x1;
sel_height = y2 - y1;
/* Calculate preview size */
if (sel_width > sel_height)
{
width = MIN (sel_width, PREVIEW_SIZE);
height = sel_height * width / sel_width;
}
else
{
height = MIN(sel_height, PREVIEW_SIZE);
width = sel_width * height / sel_height;
}
if (width < 2) width = 2;
if (height < 2) height = 2;
bpp = gimp_drawable_bpp (drawable->drawable_id);
if (gimp_drawable_is_indexed (drawable->drawable_id))
{
gint32 image_ID = gimp_drawable_get_image (drawable->drawable_id);
preview->cmap = gimp_image_get_cmap (image_ID, &preview->ncolors);
}
else
{
preview->cmap = NULL;
}
gtk_preview_size (GTK_PREVIEW (preview->widget), width, height);
preview->even = g_malloc (width * 3);
preview->odd = g_malloc (width * 3);
preview->cache = g_malloc (width * bpp * height);
preview->rowstride = width * bpp;
preview->bpp = bpp;
dx = (gdouble) (x2 - x1 - 1) / (width - 1);
dy = (gdouble) (y2 - y1 - 1) / (height - 1);
py = y1;
pft = gimp_pixel_fetcher_new (drawable);
for (y = 0; y < height; y++)
{
dest = preview->cache + y * preview->rowstride;
px = x1;
for (x = 0; x < width; x++)
{
gimp_pixel_fetcher_get_pixel (pft, (gint) px, (gint) py, dest);
dest += bpp;
px += dx;
}
gimp_old_preview_do_row (preview, y, width, dest);
py += dy;
}
gimp_pixel_fetcher_destroy (pft);
preview->buffer = GTK_PREVIEW (preview->widget)->buffer;
preview->width = GTK_PREVIEW (preview->widget)->buffer_width;
preview->height = GTK_PREVIEW (preview->widget)->buffer_height;
}
gchar *
gimp_plug_in_get_path (const gchar *path_name,
const gchar *dir_name)
{
gchar *path;
g_return_val_if_fail (path_name != NULL, NULL);
g_return_val_if_fail (dir_name != NULL, NULL);
path = gimp_gimprc_query (path_name);
if (! path)
{
gchar *gimprc = gimp_personal_rc_file ("gimprc");
gchar *full_path;
gchar *esc_path;
full_path =
g_strconcat ("${gimp_dir}", G_DIR_SEPARATOR_S, dir_name,
G_SEARCHPATH_SEPARATOR_S,
"${gimp_data_dir}", G_DIR_SEPARATOR_S, dir_name,
NULL);
esc_path = g_strescape (full_path, NULL);
g_free (full_path);
g_message (_("No %s in gimprc:\n"
"You need to add an entry like\n"
"(%s \"%s\")\n"
"to your %s file."),
path_name, path_name, esc_path, gimprc);
g_free (gimprc);
g_free (esc_path);
}
return path;
}

View File

@ -0,0 +1,103 @@
/* LIBGIMPOLDPREVIEW
* 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_OLD_PREVIEW_H__
#define __GIMP_OLD_PREVIEW_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;
GtkWidget *frame;
guchar *cache;
guchar *even;
guchar *odd;
guchar *buffer;
gint width;
gint height;
gint rowstride;
gint bpp; /* bpp of the drawable */
guchar *cmap;
gint ncolors;
gdouble scale_x;
gdouble scale_y;
gboolean is_gray;
} GimpOldPreview;
typedef void (*GimpOldPreviewFunc) (const guchar *src,
guchar *dest,
gint bpp,
gpointer data);
GimpOldPreview * gimp_old_preview_new (GimpDrawable *drawable,
gboolean has_frame);
GimpOldPreview * gimp_old_preview_new2 (GimpImageType drawable_type,
gboolean has_frame);
void gimp_old_preview_free (GimpOldPreview *preview);
void gimp_old_preview_update (GimpOldPreview *preview,
GimpOldPreviewFunc func,
gpointer data);
void gimp_old_preview_fill_with_thumb (GimpOldPreview *preview,
gint32 drawable_ID);
void gimp_old_preview_fill (GimpOldPreview *preview,
GimpDrawable *drawable);
void gimp_old_preview_fill_scaled (GimpOldPreview *preview,
GimpDrawable *drawable);
void gimp_old_preview_do_row (GimpOldPreview *preview,
gint row,
gint width,
const guchar *src);
void gimp_old_preview_put_pixel (GimpOldPreview *preview,
gint x,
gint y,
const guchar *pixel);
void gimp_old_preview_get_pixel (GimpOldPreview *preview,
gint x,
gint y,
guchar *pixel);
gchar * gimp_plug_in_get_path (const gchar *path_name,
const gchar *dir_name);
G_END_DECLS
#endif /* __GIMP_OLD_PREVIEW_H__ */