Removed the GimpOldPreview stuff. Die, crap, die!
* plug-ins/libgimpoldpreview/*: removed. * plug-ins/Makefile.am * plug-ins/common/Makefile.am: changed accordingly. * plug-ins/common/max_rgb.c * plug-ins/common/noisify.c * plug-ins/common/tileit.c: removed last forgotten #include "libgimpoldpreview.h".
This commit is contained in:
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
2004-08-11 DindinX <david@dindinx.org>
|
||||
|
||||
Removed the GimpOldPreview stuff. Die, crap, die!
|
||||
|
||||
* plug-ins/libgimpoldpreview/*: removed.
|
||||
|
||||
* plug-ins/Makefile.am
|
||||
* plug-ins/common/Makefile.am: changed accordingly.
|
||||
|
||||
* plug-ins/common/max_rgb.c
|
||||
* plug-ins/common/noisify.c
|
||||
* plug-ins/common/tileit.c: removed last forgotten
|
||||
#include "libgimpoldpreview.h".
|
||||
|
||||
2004-08-11 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimpcontainercombobox.[ch]
|
||||
|
||||
@ -31,7 +31,6 @@ endif
|
||||
|
||||
|
||||
SUBDIRS = \
|
||||
libgimpoldpreview \
|
||||
dbbrowser \
|
||||
script-fu \
|
||||
FractalExplorer \
|
||||
|
||||
@ -20,7 +20,6 @@ EXTRA_DIST = \
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/plug-ins/libgimpoldpreview \
|
||||
$(GTK_CFLAGS) \
|
||||
$(EXIF_CFLAGS) \
|
||||
$(SVG_CFLAGS) \
|
||||
@ -198,7 +197,6 @@ AlienMap2_SOURCES = \
|
||||
AlienMap2.c
|
||||
|
||||
AlienMap2_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -324,7 +322,6 @@ blinds_SOURCES = \
|
||||
blinds.c
|
||||
|
||||
blinds_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -723,7 +720,6 @@ flarefx_SOURCES = \
|
||||
flarefx.c
|
||||
|
||||
flarefx_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -839,7 +835,6 @@ glasstile_SOURCES = \
|
||||
glasstile.c
|
||||
|
||||
glasstile_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -890,7 +885,6 @@ grid_SOURCES = \
|
||||
grid.c
|
||||
|
||||
grid_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -965,7 +959,6 @@ illusion_SOURCES = \
|
||||
illusion.c
|
||||
|
||||
illusion_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -992,7 +985,6 @@ jigsaw_SOURCES = \
|
||||
jigsaw.c
|
||||
|
||||
jigsaw_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -1074,7 +1066,6 @@ max_rgb_SOURCES = \
|
||||
max_rgb.c
|
||||
|
||||
max_rgb_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -1141,7 +1132,6 @@ nlfilt_SOURCES = \
|
||||
nlfilt.c
|
||||
|
||||
nlfilt_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -1155,7 +1145,6 @@ noisify_SOURCES = \
|
||||
noisify.c
|
||||
|
||||
noisify_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -1180,7 +1169,6 @@ nova_SOURCES = \
|
||||
nova.c
|
||||
|
||||
nova_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -1272,7 +1260,6 @@ plasma_SOURCES = \
|
||||
plasma.c
|
||||
|
||||
plasma_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -1326,7 +1313,6 @@ polar_SOURCES = \
|
||||
polar.c
|
||||
|
||||
polar_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -1814,7 +1800,6 @@ waves_SOURCES = \
|
||||
waves.c
|
||||
|
||||
waves_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
@ -1866,7 +1851,6 @@ wind_SOURCES = \
|
||||
wind.c
|
||||
|
||||
wind_LDADD = \
|
||||
$(top_builddir)/plug-ins/libgimpoldpreview/libgimpoldpreview.a \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
|
||||
@ -37,8 +37,6 @@
|
||||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
#include "gimpoldpreview.h"
|
||||
|
||||
|
||||
#define PLUG_IN_NAME "plug_in_max_rgb"
|
||||
#define SHORT_NAME "max_rgb"
|
||||
|
||||
@ -45,8 +45,6 @@
|
||||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
#include "gimpoldpreview.h"
|
||||
|
||||
#define SCALE_WIDTH 125
|
||||
#define TILE_CACHE_SIZE 16
|
||||
|
||||
|
||||
@ -42,11 +42,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>
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@ -1,15 +0,0 @@
|
||||
## 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)
|
||||
@ -1,497 +0,0 @@
|
||||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpoldpreview.c
|
||||
* This file contains the implementation of the gimpoldpreview widget
|
||||
* which is used by a few plug-ins. This shouldn't be used by any
|
||||
* foreign plug-in, because it uses some deprecated stuff. We only
|
||||
* used it there since we do not a better preview widget for now.
|
||||
*
|
||||
* 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 "libgimp/gimp.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "gimpoldpreview.h"
|
||||
|
||||
|
||||
#define PREVIEW_SIZE 128
|
||||
#define PREVIEW_BPP 3
|
||||
|
||||
|
||||
static void
|
||||
gimp_old_preview_put_in_frame (GimpOldPreview *preview)
|
||||
{
|
||||
preview->frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (preview->frame), GTK_SHADOW_IN);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (preview->frame), preview->widget);
|
||||
gtk_widget_show (preview->widget);
|
||||
}
|
||||
|
||||
GimpOldPreview*
|
||||
gimp_old_preview_new (GimpDrawable *drawable)
|
||||
{
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
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, FALSE);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1,98 +0,0 @@
|
||||
/* LIBGIMPOLDPREVIEW
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpoldpreview.h
|
||||
* This file contains the implementation of the gimpoldpreview widget
|
||||
* which is used by a few plug-ins. This shouldn't be used by any
|
||||
* foreign plug-in, because it uses some deprecated stuff. We only
|
||||
* used it there since we do not a better preview widget for now.
|
||||
*
|
||||
* 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);
|
||||
GimpOldPreview * gimp_old_preview_new2 (GimpImageType drawable_type);
|
||||
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);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_OLD_PREVIEW_H__ */
|
||||
Reference in New Issue
Block a user