From f44ffcd8497d318114f99e36328b7061d49d7260 Mon Sep 17 00:00:00 2001 From: Manish Singh Date: Fri, 21 Jan 2000 01:42:13 +0000 Subject: [PATCH] reverted previous plugin addition -Yosh --- ChangeLog | 9 +- configure.in | 1 - plug-ins/common/Makefile.am | 10 - plug-ins/common/kaleidoscope.c | 1142 ------------ plug-ins/gimp_ace/AUTHORS | 12 - plug-ins/gimp_ace/ChangeLog | 79 - plug-ins/gimp_ace/Makefile.am | 37 - plug-ins/gimp_ace/Makefile.in | 483 ----- plug-ins/gimp_ace/NEWS | 30 - plug-ins/gimp_ace/README | 29 - plug-ins/gimp_ace/TODO | 5 - plug-ins/gimp_ace/color.h | 55 - plug-ins/gimp_ace/dialog.c | 503 ------ plug-ins/gimp_ace/gimp_ace.c | 581 ------ plug-ins/gimp_ace/gimp_ace.h | 14 - plug-ins/gimp_ace/glace.c | 3079 -------------------------------- plug-ins/gimp_ace/glace.h | 987 ---------- plug-ins/gimp_ace/glaceG.c | 325 ---- plug-ins/gimp_ace/glaceInt.h | 57 - 19 files changed, 8 insertions(+), 7430 deletions(-) delete mode 100644 plug-ins/common/kaleidoscope.c delete mode 100644 plug-ins/gimp_ace/AUTHORS delete mode 100644 plug-ins/gimp_ace/ChangeLog delete mode 100644 plug-ins/gimp_ace/Makefile.am delete mode 100644 plug-ins/gimp_ace/Makefile.in delete mode 100644 plug-ins/gimp_ace/NEWS delete mode 100644 plug-ins/gimp_ace/README delete mode 100644 plug-ins/gimp_ace/TODO delete mode 100644 plug-ins/gimp_ace/color.h delete mode 100644 plug-ins/gimp_ace/dialog.c delete mode 100644 plug-ins/gimp_ace/gimp_ace.c delete mode 100644 plug-ins/gimp_ace/gimp_ace.h delete mode 100644 plug-ins/gimp_ace/glace.c delete mode 100644 plug-ins/gimp_ace/glace.h delete mode 100644 plug-ins/gimp_ace/glaceG.c delete mode 100644 plug-ins/gimp_ace/glaceInt.h diff --git a/ChangeLog b/ChangeLog index 6c126d9b37..54b88cc486 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,13 @@ +Thu Jan 20 17:37:38 PST 2000 Manish Singh + + * configure.in + * plug-ins/gimp_ace + * plug-ins/common/Makefile.am + * plug-ins/common/kaleidoscope.c: reverted previous plugin addition + Fri Jan 21 00:24:19 CET 2000 Stanislav Brabec - plug-ins/rcm/rcm.c: Typo fix. + * plug-ins/rcm/rcm.c: Typo fix. Thu Jan 20 23:28:35 CET 2000 Stanislav Brabec diff --git a/configure.in b/configure.in index 0b154e2ac2..1a30f919b9 100644 --- a/configure.in +++ b/configure.in @@ -718,7 +718,6 @@ plug-ins/gfig/gfig-examples/Makefile plug-ins/gflare/Makefile plug-ins/gflare/gflares/Makefile plug-ins/gfli/Makefile -plug-ins/gimp_ace/Makefile plug-ins/gimpressionist/Makefile plug-ins/gimpressionist/Brushes/Makefile plug-ins/gimpressionist/Paper/Makefile diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am index 54d0c36823..b46e413347 100644 --- a/plug-ins/common/Makefile.am +++ b/plug-ins/common/Makefile.am @@ -76,7 +76,6 @@ libexec_PROGRAMS = \ iwarp \ jigsaw \ $(JPEG) \ - kaleidoscope \ laplace \ lic \ mail \ @@ -684,15 +683,6 @@ jpeg_LDADD = \ $(GTK_LIBS) \ $(INTLLIBS) -kaleidoscope_SOURCES = \ - kaleidoscope.c - -kaleidoscope_LDADD = \ - $(top_builddir)/libgimp/libgimpui.la \ - $(top_builddir)/libgimp/libgimp.la \ - $(GLIB_LIBS) \ - $(INTLLIBS) - laplace_SOURCES = \ laplace.c diff --git a/plug-ins/common/kaleidoscope.c b/plug-ins/common/kaleidoscope.c deleted file mode 100644 index a273e02306..0000000000 --- a/plug-ins/common/kaleidoscope.c +++ /dev/null @@ -1,1142 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * Kaleidoscope - * Copyright (C) 1999 Kelly Martin - * Derived from WhirlPinch - * Copyright (C) 1997 Federico Mena Quintero - * federico@nuclecu.unam.mx - * Copyright (C) 1997 Scott Goehring - * scott@poverty.bloomington.in.us - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - - -/* Version 0.01 - * - * First version. - */ - -#include -#include -#include - -#include "gtk/gtk.h" -#include "libgimp/gimp.h" - -#define PLUG_IN_NAME "plug_in_kaleidoscope" -#define PLUG_IN_VERSION "0.01 (1999/09/30)" - -/***** Magic numbers *****/ - -#define PREVIEW_SIZE 128 -#define SCALE_WIDTH 200 -#define ENTRY_WIDTH 60 - -#define CHECK_SIZE 8 -#define CHECK_DARK ((int) (1.0 / 3.0 * 255)) -#define CHECK_LIGHT ((int) (2.0 / 3.0 * 255)) - - -/***** Types *****/ - -typedef struct { - gdouble angle1; - gdouble angle2; - gint nsegs; - gdouble cen_x; - gdouble cen_y; - gdouble off_x; - gdouble off_y; -} kaleidoscope_vals_t; - -typedef struct { - GtkWidget *preview; - guchar *check_row_0; - guchar *check_row_1; - guchar *image; - guchar *dimage; - - gint run; -} kaleidoscope_interface_t; - -typedef struct { - gint col, row; - gint img_width, img_height, img_bpp, img_has_alpha; - gint tile_width, tile_height; - guchar bg_color[4]; - GDrawable *drawable; - GTile *tile; -} pixel_fetcher_t; - - -/***** Prototypes *****/ - -static void query(void); -static void run(char *name, - int nparams, - GParam *param, - int *nreturn_vals, - GParam **return_vals); - -static void kaleidoscope(void); -static int calc_undistorted_coords(double wx, double wy, - double angle1, double angle2, int nsegs, - double cen_x, double cen_y, - double off_x, double off_y, - double *x, double *y); -static guchar bilinear(double x, double y, guchar *values); - -static pixel_fetcher_t *pixel_fetcher_new(GDrawable *drawable); -static void pixel_fetcher_set_bg_color(pixel_fetcher_t *pf, guchar r, guchar g, guchar b, guchar a); -static void pixel_fetcher_get_pixel(pixel_fetcher_t *pf, int x, int y, guchar *pixel); -static void pixel_fetcher_destroy(pixel_fetcher_t *pf); - -static void build_preview_source_image(void); - -static gint kaleidoscope_dialog(void); -static void dialog_update_preview(void); -static void dialog_create_value(char *title, GtkTable *table, int row, gdouble *value, - double left, double right, double step); -static void dialog_scale_update(GtkAdjustment *adjustment, gdouble *value); -static void dialog_entry_update(GtkWidget *widget, gdouble *value); -static void dialog_create_int_value(char *title, GtkTable *table, int row, gint *value, - gint left, gint right, gint step); -static void dialog_int_scale_update(GtkAdjustment *adjustment, gint *value); -static void dialog_int_entry_update(GtkWidget *widget, gint *value); -static void dialog_close_callback(GtkWidget *widget, gpointer data); -static void dialog_ok_callback(GtkWidget *widget, gpointer data); -static void dialog_cancel_callback(GtkWidget *widget, gpointer data); - - -/***** Variables *****/ - -GPlugInInfo PLUG_IN_INFO = { - NULL, /* init_proc */ - NULL, /* quit_proc */ - query, /* query_proc */ - run /* run_proc */ -}; /* PLUG_IN_INFO */ - -static kaleidoscope_vals_t wpvals = { - 0.0, /* angle1 */ - 0.0, /* angle2 */ - 6, /* nsegs */ - 0.0, /* x center */ - 0.0, /* y center */ - 0.0, /* x offset */ - 0.0 /* y offset */ -}; /* wpvals */ - -static kaleidoscope_interface_t wpint = { - NULL, /* preview */ - NULL, /* check_row_0 */ - NULL, /* check_row_1 */ - NULL, /* image */ - NULL, /* dimage */ - FALSE /* run */ -}; /* wpint */ - -static GDrawable *drawable; - -static gint img_width, img_height, img_bpp, img_has_alpha; -static gint sel_x1, sel_y1, sel_x2, sel_y2; -static gint sel_width, sel_height; -static gint preview_width, preview_height; - -static double scale_x, scale_y; -static double radius; - - -/***** Functions *****/ - -/*****/ - -MAIN() - - - /*****/ - - static void -query(void) -{ - static GParamDef args[] = { - { PARAM_INT32, "run_mode", "Interactive, non-interactive" }, - { PARAM_IMAGE, "image", "Input image" }, - { PARAM_DRAWABLE, "drawable", "Input drawable" }, - { PARAM_FLOAT, "angle1", "Angle of leading edge of viewing slice" }, - { PARAM_FLOAT, "angle2", "Rollback angle" }, - { PARAM_INT32, "nsegs", "Number of segments" } - }; /* args */ - - static GParamDef *return_vals = NULL; - static int nargs = sizeof(args) / sizeof(args[0]); - static int nreturn_vals = 0; - - gimp_install_procedure(PLUG_IN_NAME, - "Simulate looking at an image thru a kaleidoscope", - "Simulate looking at an image thru a kaleidoscope", - "Kelly Martin", - "Kelly Martin", - PLUG_IN_VERSION, - "/Filters/Distorts/Kaleidoscope", - "RGB*, GRAY*", - PROC_PLUG_IN, - nargs, - nreturn_vals, - args, - return_vals); -} /* query */ - - -/*****/ - -static void -run(char *name, - int nparams, - GParam *param, - int *nreturn_vals, - GParam **return_vals) -{ - static GParam values[1]; - - GRunModeType run_mode; - GStatusType status; - double xhsiz, yhsiz; - int pwidth, pheight; - - status = STATUS_SUCCESS; - run_mode = param[0].data.d_int32; - - values[0].type = PARAM_STATUS; - values[0].data.d_status = status; - - *nreturn_vals = 1; - *return_vals = values; - - /* Get the active drawable info */ - - drawable = gimp_drawable_get(param[2].data.d_drawable); - - img_width = gimp_drawable_width(drawable->id); - img_height = gimp_drawable_height(drawable->id); - img_bpp = gimp_drawable_bpp(drawable->id); - img_has_alpha = gimp_drawable_has_alpha(drawable->id); - - gimp_drawable_mask_bounds(drawable->id, &sel_x1, &sel_y1, &sel_x2, &sel_y2); - - /* Calculate scaling parameters */ - - sel_width = sel_x2 - sel_x1; - sel_height = sel_y2 - sel_y1; - - xhsiz = (double) (sel_width - 1) / 2.0; - yhsiz = (double) (sel_height - 1) / 2.0; - - if (xhsiz < yhsiz) { - scale_x = yhsiz / xhsiz; - scale_y = 1.0; - } else if (xhsiz > yhsiz) { - scale_x = 1.0; - scale_y = xhsiz / yhsiz; - } else { - scale_x = 1.0; - scale_y = 1.0; - } /* else */ - - radius = MAX(xhsiz, yhsiz); - - /* Calculate preview size */ - - if (sel_width > sel_height) { - pwidth = MIN(sel_width, PREVIEW_SIZE); - pheight = sel_height * pwidth / sel_width; - } else { - pheight = MIN(sel_height, PREVIEW_SIZE); - pwidth = sel_width * pheight / sel_height; - } /* else */ - - preview_width = MAX(pwidth, 2); /* Min size is 2 */ - preview_height = MAX(pheight, 2); - - /* See how we will run */ - - switch (run_mode) { - case RUN_INTERACTIVE: - /* Possibly retrieve data */ - - gimp_get_data(PLUG_IN_NAME, &wpvals); - - /* Get information from the dialog */ - - if (!kaleidoscope_dialog()) - return; - - break; - - case RUN_NONINTERACTIVE: - /* Make sure all the arguments are present */ - - if (nparams != 10) - status = STATUS_CALLING_ERROR; - - if (status == STATUS_SUCCESS) { - wpvals.angle1 = param[3].data.d_float; - wpvals.angle2 = param[4].data.d_float; - wpvals.nsegs = param[5].data.d_int32; - wpvals.cen_x = param[6].data.d_float; - wpvals.cen_y = param[7].data.d_float; - wpvals.off_x = param[8].data.d_float; - wpvals.off_y = param[9].data.d_float; - } /* if */ - - break; - - case RUN_WITH_LAST_VALS: - /* Possibly retrieve data */ - - gimp_get_data(PLUG_IN_NAME, &wpvals); - break; - - default: - break; - } /* switch */ - - /* Distort the image */ - - if ((status == STATUS_SUCCESS) && - (gimp_drawable_color(drawable->id) || - gimp_drawable_gray(drawable->id))) { - /* Set the tile cache size */ - - gimp_tile_cache_ntiles(2 * (drawable->width + gimp_tile_width() - 1) / gimp_tile_width()); - - /* Run! */ - - kaleidoscope(); - - /* If run mode is interactive, flush displays */ - - if (run_mode != RUN_NONINTERACTIVE) - gimp_displays_flush(); - - /* Store data */ - - if (run_mode == RUN_INTERACTIVE) - gimp_set_data(PLUG_IN_NAME, &wpvals, sizeof(kaleidoscope_vals_t)); - } else if (status == STATUS_SUCCESS) - status = STATUS_EXECUTION_ERROR; - - values[0].data.d_status = status; - - gimp_drawable_detach(drawable); -} /* run */ - - -/*****/ - -static void -kaleidoscope(void) -{ - GPixelRgn dest_rgn; - gint progress, max_progress; - guchar *top_row, *bot_row; - guchar *top_p, *bot_p; - gint row, col; - guchar pixel[4][4]; - guchar values[4]; - double cx, cy; - double angle1, angle2; - int ix, iy; - int i; - guchar bg_color[4]; - pixel_fetcher_t *pft; -#if 0 - printf("Waiting... (pid %d)\n", getpid()); - kill(getpid(), SIGSTOP); -#endif - /* Initialize rows */ - - top_row = g_malloc(img_bpp * sel_width); - bot_row = g_malloc(img_bpp * sel_width); - - /* Initialize pixel region */ - - gimp_pixel_rgn_init(&dest_rgn, drawable, sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE); - - pft = pixel_fetcher_new(drawable); - - gimp_palette_get_background(&bg_color[0], &bg_color[1], &bg_color[2]); - pixel_fetcher_set_bg_color(pft, - bg_color[0], - bg_color[1], - bg_color[2], - (img_has_alpha ? 0 : 255)); - - progress = 0; - max_progress = sel_width * sel_height; - - gimp_progress_init("Kaleidoscoping..."); - - angle1 = wpvals.angle1 * G_PI / 180; - angle2 = wpvals.angle2 * G_PI / 180; - - for (row = sel_y1; row < (sel_y1 + sel_y2); row++) { - top_p = top_row; - bot_p = bot_row + img_bpp * (sel_width - 1); - - for (col = sel_x1; col < sel_x2; col++) { - if (calc_undistorted_coords(col, row, angle1, angle2, - wpvals.nsegs, - wpvals.cen_x, wpvals.cen_y, - wpvals.off_x, wpvals.off_y, - &cx, &cy)) { - /* We are inside the distortion area */ - - /* Top */ - - if (cx >= 0.0) - ix = (int) cx; - else - ix = -((int) -cx + 1); - - if (cy >= 0.0) - iy = (int) cy; - else - iy = -((int) -cy + 1); - - pixel_fetcher_get_pixel(pft, ix, iy, pixel[0]); - pixel_fetcher_get_pixel(pft, ix + 1, iy, pixel[1]); - pixel_fetcher_get_pixel(pft, ix, iy + 1, pixel[2]); - pixel_fetcher_get_pixel(pft, ix + 1, iy + 1, pixel[3]); - - for (i = 0; i < img_bpp; i++) { - values[0] = pixel[0][i]; - values[1] = pixel[1][i]; - values[2] = pixel[2][i]; - values[3] = pixel[3][i]; - - *top_p++ = bilinear(cx, cy, values); - } /* for */ - - } else { - /* We are outside the distortion area; just copy the source pixels */ - - /* Top */ - - pixel_fetcher_get_pixel(pft, col, row, pixel[0]); - - for (i = 0; i < img_bpp; i++) - *top_p++ = pixel[0][i]; - - } /* else */ - } /* for */ - - /* Paint rows to image */ - - gimp_pixel_rgn_set_row(&dest_rgn, top_row, sel_x1, row, sel_width); - - /* Update progress */ - - progress += sel_width; - gimp_progress_update((double) progress / max_progress); - } /* for */ - - pixel_fetcher_destroy(pft); - - g_free(top_row); - - gimp_drawable_flush(drawable); - gimp_drawable_merge_shadow(drawable->id, TRUE); - gimp_drawable_update(drawable->id, sel_x1, sel_y1, sel_width, sel_height); -} /* kaleidoscope */ - - -/*****/ - -static int -calc_undistorted_coords(double wx, double wy, - double angle1, double angle2, int nsegs, - double cen_x, double cen_y, - double off_x, double off_y, - double *x, double *y) -{ - double dx, dy; - double r, ang; - - double awidth = G_PI/nsegs; - double mult; - - dx = wx - cen_x; - dy = wy - cen_y; - - r = sqrt(dx*dx+dy*dy); - if (r == 0.0) { - *x = wx + off_x; - *y = wy + off_y; - return TRUE; - } - - ang = atan2(dy,dx) - angle1 - angle2; - while (ang<0.0) ang = ang + 2*G_PI; - - mult = ceil(ang/awidth) - 1; - ang = ang - mult*awidth; - if (((int) mult) % 2 == 1) ang = awidth - ang; - ang = ang + angle1; - - *x = cen_x + r*cos(ang) + off_x; - *y = cen_y + r*sin(ang) + off_y; - - return TRUE; -} /* calc_undistorted_coords */ - - -/*****/ - -static guchar -bilinear(double x, double y, guchar *values) -{ - double m0, m1; - - x = fmod(x, 1.0); - y = fmod(y, 1.0); - - if (x < 0.0) - x += 1.0; - - if (y < 0.0) - y += 1.0; - - m0 = (double) values[0] + x * ((double) values[1] - values[0]); - m1 = (double) values[2] + x * ((double) values[3] - values[2]); - - return (guchar) (m0 + y * (m1 - m0)); -} /* bilinear */ - - -/*****/ - -static pixel_fetcher_t * -pixel_fetcher_new(GDrawable *drawable) -{ - pixel_fetcher_t *pf; - - pf = g_malloc(sizeof(pixel_fetcher_t)); - - pf->col = -1; - pf->row = -1; - pf->img_width = gimp_drawable_width(drawable->id); - pf->img_height = gimp_drawable_height(drawable->id); - pf->img_bpp = gimp_drawable_bpp(drawable->id); - pf->img_has_alpha = gimp_drawable_has_alpha(drawable->id); - pf->tile_width = gimp_tile_width(); - pf->tile_height = gimp_tile_height(); - pf->bg_color[0] = 0; - pf->bg_color[1] = 0; - pf->bg_color[2] = 0; - pf->bg_color[3] = 0; - - pf->drawable = drawable; - pf->tile = NULL; - - return pf; -} /* pixel_fetcher_new */ - - -/*****/ - -static void -pixel_fetcher_set_bg_color(pixel_fetcher_t *pf, guchar r, guchar g, guchar b, guchar a) -{ - pf->bg_color[0] = r; - pf->bg_color[1] = g; - pf->bg_color[2] = b; - - if (pf->img_has_alpha) - pf->bg_color[pf->img_bpp - 1] = a; -} /* pixel_fetcher_set_bg_color */ - - -/*****/ - -static void -pixel_fetcher_get_pixel(pixel_fetcher_t *pf, int x, int y, guchar *pixel) -{ - gint col, row; - gint coloff, rowoff; - guchar *p; - int i; - - if ((x < sel_x1) || (x >= sel_x2) || - (y < sel_y1) || (y >= sel_y2)) { - for (i = 0; i < pf->img_bpp; i++) - pixel[i] = pf->bg_color[i]; - - return; - } /* if */ - - col = x / pf->tile_width; - coloff = x % pf->tile_width; - row = y / pf->tile_height; - rowoff = y % pf->tile_height; - - if ((col != pf->col) || - (row != pf->row) || - (pf->tile == NULL)) { - if (pf->tile != NULL) - gimp_tile_unref(pf->tile, FALSE); - - pf->tile = gimp_drawable_get_tile(pf->drawable, FALSE, row, col); - gimp_tile_ref(pf->tile); - - pf->col = col; - pf->row = row; - } /* if */ - - p = pf->tile->data + pf->img_bpp * (pf->tile->ewidth * rowoff + coloff); - - for (i = pf->img_bpp; i; i--) - *pixel++ = *p++; -} /* pixel_fetcher_get_pixel */ - - -/*****/ - -static void -pixel_fetcher_destroy(pixel_fetcher_t *pf) -{ - if (pf->tile != NULL) - gimp_tile_unref(pf->tile, FALSE); - - g_free(pf); -} /* pixel_fetcher_destroy */ - - -/*****/ - -static void -build_preview_source_image(void) -{ - double left, right, bottom, top; - double px, py; - double dx, dy; - int x, y; - guchar *p; - guchar pixel[4]; - pixel_fetcher_t *pf; - - wpint.check_row_0 = g_malloc(preview_width * sizeof(guchar)); - wpint.check_row_1 = g_malloc(preview_width * sizeof(guchar)); - wpint.image = g_malloc(preview_width * preview_height * 4 * sizeof(guchar)); - wpint.dimage = g_malloc(preview_width * preview_height * 3 * sizeof(guchar)); - - left = sel_x1; - right = sel_x2 - 1; - bottom = sel_y2 - 1; - top = sel_y1; - - dx = (right - left) / (preview_width - 1); - dy = (bottom - top) / (preview_height - 1); - - py = top; - - pf = pixel_fetcher_new(drawable); - - p = wpint.image; - - for (y = 0; y < preview_height; y++) { - px = left; - - for (x = 0; x < preview_width; x++) { - /* Checks */ - - if ((x / CHECK_SIZE) & 1) { - wpint.check_row_0[x] = CHECK_DARK; - wpint.check_row_1[x] = CHECK_LIGHT; - } else { - wpint.check_row_0[x] = CHECK_LIGHT; - wpint.check_row_1[x] = CHECK_DARK; - } /* else */ - - /* Thumbnail image */ - - pixel_fetcher_get_pixel(pf, (int) px, (int) py, pixel); - - if (img_bpp < 3) { - if (img_has_alpha) - pixel[3] = pixel[1]; - else - pixel[3] = 255; - - pixel[1] = pixel[0]; - pixel[2] = pixel[0]; - } else - if (!img_has_alpha) - pixel[3] = 255; - - *p++ = pixel[0]; - *p++ = pixel[1]; - *p++ = pixel[2]; - *p++ = pixel[3]; - - px += dx; - } /* for */ - - py += dy; - } /* for */ - - pixel_fetcher_destroy(pf); -} /* build_preview_source_image */ - - -/*****/ - -static gint -kaleidoscope_dialog(void) -{ - GtkWidget *dialog; - GtkWidget *top_table; - GtkWidget *frame; - GtkWidget *table; - GtkWidget *button; - gint argc; - gchar **argv; - guchar *color_cube; -#if 0 - printf("Waiting... (pid %d)\n", getpid()); - kill(getpid(), SIGSTOP); -#endif - argc = 1; - argv = g_new(gchar *, 1); - argv[0] = g_strdup("kaleidoscope"); - - gtk_init(&argc, &argv); - gtk_rc_parse (gimp_gtkrc ()); - - gdk_set_use_xshm(gimp_use_xshm()); - - gtk_preview_set_gamma(gimp_gamma()); - gtk_preview_set_install_cmap(gimp_install_cmap()); - color_cube = gimp_color_cube(); - gtk_preview_set_color_cube(color_cube[0], color_cube[1], color_cube[2], color_cube[3]); - - gtk_widget_set_default_visual(gtk_preview_get_visual()); - gtk_widget_set_default_colormap(gtk_preview_get_cmap()); - - build_preview_source_image(); - - dialog = gtk_dialog_new(); - gtk_window_set_title(GTK_WINDOW(dialog), "Kaleidoscope"); - gtk_window_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE); - gtk_container_border_width(GTK_CONTAINER(dialog), 0); - gtk_signal_connect(GTK_OBJECT(dialog), "destroy", - (GtkSignalFunc) dialog_close_callback, - NULL); - - top_table = gtk_table_new(2, 3, FALSE); - gtk_container_border_width(GTK_CONTAINER(top_table), 6); - gtk_table_set_row_spacings(GTK_TABLE(top_table), 4); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), top_table, FALSE, FALSE, 0); - gtk_widget_show(top_table); - - /* Preview */ - - frame = gtk_frame_new(NULL); - gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); - gtk_table_attach(GTK_TABLE(top_table), frame, 1, 2, 0, 1, 0, 0, 0, 0); - gtk_widget_show(frame); - - wpint.preview = gtk_preview_new(GTK_PREVIEW_COLOR); - gtk_preview_size(GTK_PREVIEW(wpint.preview), preview_width, preview_height); - gtk_container_add(GTK_CONTAINER(frame), wpint.preview); - gtk_widget_show(wpint.preview); - - /* Controls */ - - table = gtk_table_new(7, 3, FALSE); - gtk_container_border_width(GTK_CONTAINER(table), 0); - gtk_table_attach(GTK_TABLE(top_table), table, 0, 3, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); - gtk_widget_show(table); - - dialog_create_value("Angle 1", GTK_TABLE(table), 0, &wpvals.angle1, -360.0, 360.0, 1.0); - - dialog_create_value("Angle 2", GTK_TABLE(table), 1, &wpvals.angle2, -360.0, 360.0, 1.0); - - dialog_create_int_value("Number of segments", GTK_TABLE(table), 2, &wpvals.nsegs, 1, 16, 1); - - dialog_create_value("X center", GTK_TABLE(table), 3, &wpvals.cen_x, sel_x1, sel_x2, 1.0); - - dialog_create_value("Y center", GTK_TABLE(table), 4, &wpvals.cen_y, sel_y1, sel_y2, 1.0); - - dialog_create_value("X offset", GTK_TABLE(table), 5, &wpvals.off_x, -img_width, img_width, 1.0); - - dialog_create_value("Y offset", GTK_TABLE(table), 6, &wpvals.off_y, -img_height, img_height, 1.0); - - /* Buttons */ - - gtk_container_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), 6); - - button = gtk_button_new_with_label("OK"); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - (GtkSignalFunc) dialog_ok_callback, - dialog); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button, TRUE, TRUE, 0); - gtk_widget_grab_default(button); - gtk_widget_show(button); - - button = gtk_button_new_with_label("Cancel"); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - (GtkSignalFunc) dialog_cancel_callback, - dialog); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button, TRUE, TRUE, 0); - gtk_widget_show(button); - - /* Done */ - - gtk_widget_show(dialog); - dialog_update_preview(); - - gtk_main(); - gdk_flush(); - - g_free(wpint.check_row_0); - g_free(wpint.check_row_1); - g_free(wpint.image); - g_free(wpint.dimage); - - return wpint.run; -} /* kaleidoscope_dialog */ - - -/*****/ - -static void -dialog_update_preview(void) -{ - double left, right, bottom, top; - double dx, dy; - double px, py; - double cx, cy; - int ix, iy; - int x, y; - double scale_x, scale_y; - guchar *p_ul, *i, *p; - guchar *check_ul; - int check; - guchar outside[4]; - double angle1, angle2; - - gimp_palette_get_background(&outside[0], &outside[1], &outside[2]); - outside[3] = (img_has_alpha ? 0 : 255); - - if (img_bpp < 3) { - outside[1] = outside[0]; - outside[2] = outside[0]; - } /* if */ - - left = sel_x1; - right = sel_x2 - 1; - bottom = sel_y2 - 1; - top = sel_y1; - - dx = (right - left) / (preview_width - 1); - dy = (bottom - top) / (preview_height - 1); - - scale_x = (double) preview_width / (right - left + 1); - scale_y = (double) preview_height / (bottom - top + 1); - - angle1 = wpvals.angle1 * G_PI / 180; - angle2 = wpvals.angle2 * G_PI / 180; - - py = top; - - p_ul = wpint.dimage; - - for (y = 0; y < preview_height; y++) { - px = left; - - if ((y / CHECK_SIZE) & 1) - check_ul = wpint.check_row_0; - else - check_ul = wpint.check_row_1; - - for (x = 0; x < preview_width; x++) { - calc_undistorted_coords(px, py, angle1, angle2, wpvals.nsegs, - wpvals.cen_x, wpvals.cen_y, - wpvals.off_x, wpvals.off_y, - &cx, &cy); - - cx = (cx - left) * scale_x; - cy = (cy - top) * scale_y; - - ix = (int) (cx + 0.5); - iy = (int) (cy + 0.5); - - check = check_ul[x]; - - if ((ix >= 0) && (ix < preview_width) && - (iy >= 0) && (iy < preview_height)) - i = wpint.image + 4 * (preview_width * iy + ix); - else - i = outside; - - p_ul[0] = check + ((i[0] - check) * i[3]) / 255; - p_ul[1] = check + ((i[1] - check) * i[3]) / 255; - p_ul[2] = check + ((i[2] - check) * i[3]) / 255; - - p_ul += 3; - - px += dx; - } /* for */ - - py += dy; - } /* for */ - - p = wpint.dimage; - - for (y = 0; y < preview_height; y++) { - gtk_preview_draw_row(GTK_PREVIEW(wpint.preview), p, 0, y, preview_width); - - p += preview_width * 3; - } /* for */ - - gtk_widget_draw(wpint.preview, NULL); - gdk_flush(); -} /* dialog_update_preview */ - - -/*****/ - -static void -dialog_create_value(char *title, GtkTable *table, int row, gdouble *value, - double left, double right, double step) -{ - GtkWidget *label; - GtkWidget *scale; - GtkWidget *entry; - GtkObject *scale_data; - char buf[256]; - - label = gtk_label_new(title); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_table_attach(table, label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 4, 0); - gtk_widget_show(label); - - scale_data = gtk_adjustment_new(*value, left, right, - step, - step, - 0.0); - - gtk_signal_connect(GTK_OBJECT(scale_data), "value_changed", - (GtkSignalFunc) dialog_scale_update, - value); - - scale = gtk_hscale_new(GTK_ADJUSTMENT(scale_data)); - gtk_widget_set_usize(scale, SCALE_WIDTH, 0); - gtk_table_attach(table, scale, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_scale_set_draw_value(GTK_SCALE(scale), FALSE); - gtk_scale_set_digits(GTK_SCALE(scale), 3); - gtk_range_set_update_policy(GTK_RANGE(scale), GTK_UPDATE_CONTINUOUS); - gtk_widget_show(scale); - - entry = gtk_entry_new(); - gtk_object_set_user_data(GTK_OBJECT(entry), scale_data); - gtk_object_set_user_data(scale_data, entry); - gtk_widget_set_usize(entry, ENTRY_WIDTH, 0); - sprintf(buf, "%0.3f", *value); - gtk_entry_set_text(GTK_ENTRY(entry), buf); - gtk_signal_connect(GTK_OBJECT(entry), "changed", - (GtkSignalFunc) dialog_entry_update, - value); - gtk_table_attach(GTK_TABLE(table), entry, 2, 3, row, row + 1, GTK_FILL, GTK_FILL, 4, 0); - gtk_widget_show(entry); -} /* dialog_create_value */ - - -/*****/ - -static void -dialog_scale_update(GtkAdjustment *adjustment, gdouble *value) -{ - GtkWidget *entry; - char buf[256]; - - if (*value != adjustment->value) { - *value = adjustment->value; - - entry = gtk_object_get_user_data(GTK_OBJECT(adjustment)); - sprintf(buf, "%0.3f", *value); - - gtk_signal_handler_block_by_data(GTK_OBJECT(entry), value); - gtk_entry_set_text(GTK_ENTRY(entry), buf); - gtk_signal_handler_unblock_by_data(GTK_OBJECT(entry), value); - - dialog_update_preview(); - } /* if */ -} /* dialog_scale_update */ - - -/*****/ - -static void -dialog_entry_update(GtkWidget *widget, gdouble *value) -{ - GtkAdjustment *adjustment; - gdouble new_value; - - new_value = atof(gtk_entry_get_text(GTK_ENTRY(widget))); - - if (*value != new_value) { - adjustment = gtk_object_get_user_data(GTK_OBJECT(widget)); - - if ((new_value >= adjustment->lower) && - (new_value <= adjustment->upper)) { - *value = new_value; - adjustment->value = new_value; - - gtk_signal_emit_by_name(GTK_OBJECT(adjustment), "value_changed"); - - dialog_update_preview(); - } /* if */ - } /* if */ -} /* dialog_entry_update */ - -static void -dialog_create_int_value(char *title, GtkTable *table, int row, gint *value, - int left, int right, int step) -{ - GtkWidget *label; - GtkWidget *scale; - GtkWidget *entry; - GtkObject *scale_data; - char buf[256]; - - label = gtk_label_new(title); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_table_attach(table, label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 4, 0); - gtk_widget_show(label); - - scale_data = gtk_adjustment_new(1.0 * (*value), - 1.0*left, - 1.0*right, - 1.0*step, - 1.0*step, - 0.0); - - gtk_signal_connect(GTK_OBJECT(scale_data), "value_changed", - (GtkSignalFunc) dialog_int_scale_update, - value); - - scale = gtk_hscale_new(GTK_ADJUSTMENT(scale_data)); - gtk_widget_set_usize(scale, SCALE_WIDTH, 0); - gtk_table_attach(table, scale, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_scale_set_draw_value(GTK_SCALE(scale), FALSE); - gtk_scale_set_digits(GTK_SCALE(scale), 3); - gtk_range_set_update_policy(GTK_RANGE(scale), GTK_UPDATE_CONTINUOUS); - gtk_widget_show(scale); - - entry = gtk_entry_new(); - gtk_object_set_user_data(GTK_OBJECT(entry), scale_data); - gtk_object_set_user_data(scale_data, entry); - gtk_widget_set_usize(entry, ENTRY_WIDTH, 0); - sprintf(buf, "%d", *value); - gtk_entry_set_text(GTK_ENTRY(entry), buf); - gtk_signal_connect(GTK_OBJECT(entry), "changed", - (GtkSignalFunc) dialog_int_entry_update, - value); - gtk_table_attach(GTK_TABLE(table), entry, 2, 3, row, row + 1, GTK_FILL, GTK_FILL, 4, 0); - gtk_widget_show(entry); -} /* dialog_create_int_value */ - - -/*****/ - -static void -dialog_int_scale_update(GtkAdjustment *adjustment, gint *value) -{ - GtkWidget *entry; - char buf[256]; - - if (*value != (int) adjustment->value) { - *value = (int) adjustment->value; - - entry = gtk_object_get_user_data(GTK_OBJECT(adjustment)); - sprintf(buf, "%d", *value); - - gtk_signal_handler_block_by_data(GTK_OBJECT(entry), value); - gtk_entry_set_text(GTK_ENTRY(entry), buf); - gtk_signal_handler_unblock_by_data(GTK_OBJECT(entry), value); - - dialog_update_preview(); - } /* if */ -} /* dialog_scale_update */ - - -/*****/ - -static void -dialog_int_entry_update(GtkWidget *widget, gint *value) -{ - GtkAdjustment *adjustment; - gint new_int_value; - - new_int_value = atoi(gtk_entry_get_text(GTK_ENTRY(widget))); - - if (*value != new_int_value) { - adjustment = gtk_object_get_user_data(GTK_OBJECT(widget)); - - if ((new_int_value >= adjustment->lower) && - (new_int_value <= adjustment->upper)) { - *value = new_int_value; - adjustment->value = 1.0*new_int_value; - - gtk_signal_emit_by_name(GTK_OBJECT(adjustment), "value_changed"); - - dialog_update_preview(); - } /* if */ - } /* if */ -} /* dialog_entry_update */ - - -/*****/ - -static void -dialog_close_callback(GtkWidget *widget, gpointer data) -{ - gtk_main_quit(); -} /* dialog_close_callback */ - - -/*****/ - -static void -dialog_ok_callback(GtkWidget *widget, gpointer data) -{ - wpint.run = TRUE; - gtk_widget_destroy(GTK_WIDGET(data)); -} /* dialog_ok_callback */ - - -/*****/ - -static void -dialog_cancel_callback(GtkWidget *widget, gpointer data) -{ - gtk_widget_destroy(GTK_WIDGET(data)); -} /* dialog_cancel_callback */ diff --git a/plug-ins/gimp_ace/AUTHORS b/plug-ins/gimp_ace/AUTHORS deleted file mode 100644 index 65cd08324a..0000000000 --- a/plug-ins/gimp_ace/AUTHORS +++ /dev/null @@ -1,12 +0,0 @@ -Alex Stark : - Adaptive Contrast Enhancement algorithm and implementation. - (in files: glace*) - -Kevin Turner : - GIMP plug-in wrapper for the above. - (in files: dialog.c gimp_ace.*) - -Please direct all comments and queries regarding the GIMP plug-in to -Kevin Turner. Inquiries about other implementations of Adaptive -Contrast Enhancement, or about the process itself may be directed to -Alex Stark. diff --git a/plug-ins/gimp_ace/ChangeLog b/plug-ins/gimp_ace/ChangeLog deleted file mode 100644 index 5edb32c1c2..0000000000 --- a/plug-ins/gimp_ace/ChangeLog +++ /dev/null @@ -1,79 +0,0 @@ -1999-12-31 Kevin Turner - - * glace.c, glace.h: Eliminated COLOR_CLASSIC... it's not smart - enough to survive. - - * glace.c (Glace_Output): Changed COLOR_LUMIN to use the - coefficients from color.h to compute Y. This is more consistant - with the decomposition in gimp_ace.c (SeperateChannels). - - * configure.in: Bumped version to 0.5.0. - - * dialog.c (ace_dialog): use option menu for color method, not - radio buttons. - -1999-12-30 Kevin Turner - - * glace.c (Glace_Output): Color method now configurable at runtime - instead of compile-time #ifdefs. - - * gimp_ace.c (SeperateChannels): The color space in which channels - are seperated now depends on color_method. - - * glace.h: put back the RGB image pointers for use with other - color methods - - * gimp_ace.c (acevals =): Added color_method member to initializer. - - * dialog.c (radio_callback): new function - (ace_dialog): add radio buttons for selecting color_method. - - * glace.h (Glace_CfgInfo): added enum type Glace_ColorMethods, and - added member colorMethod to Glace_CfgInfo struct. - - * gimp_ace.h: include glace.h for Glace_ColorMethods, add - color_method to AceValues struct. - - * glace.c (Glace_FillTableForNotFilt): merge some casting changes - from Alex - - * gimp_ace.c (query): Change menu path. - -1999-10-03 Kevin Turner - - * glace.c, glace.h: Merged with Alex's "ace-not-gimp.zip" of 27-Sep-99 - That just means sifting in the #ifdefs... Still TODO is to take a - good look at Glace_Output again and merge for real. - -1999-07-21 Kevin Turner - - * dialog.c (ace_dialog_new): change asprintf to g_strdup_printf - (ace_dialog): Add toggle to link strength and bradj values - * gimp_ace.c, gimp_ace.h: add link boolean to AceValues - -1999-07-20 Kevin Turner - - * glace.c (Glace_Output): Change the color output routine to use a - Yxy chromacity system. - - * color.h: Add constants for RGB <-> XYZ conversion matricies. - - * gimp_ace.c (SeperateChannels): Seperation of rgb color to xy - chromathings is now done here, not in GlaceOutput. This means we - don't seperate out RGB channels into seperate buffers, but fill in - two buffers for x and y. The luminosity buffer (the one which - gets operated on) is handled the same way as previously. - - * glace.h: {R,G,B}Ptr is gone, replaced by C{x,y}Ptr - -1999-07-19 Kevin Turner - - * Makefile.am, configure.in: first attempt at auto{make,conf} - - * gimp_ace.c (do_ace): implement configurability options with - acevals to cfgInfoPtr. - (run): Add switch(run_mode) to call interactive - interface, etc. - - * dialog.c: new file - diff --git a/plug-ins/gimp_ace/Makefile.am b/plug-ins/gimp_ace/Makefile.am deleted file mode 100644 index 6ba0485080..0000000000 --- a/plug-ins/gimp_ace/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -## Process this file with automake to produce Makefile.in - -libexecdir = $(gimpplugindir)/plug-ins - -libexec_PROGRAMS = gimp_ace - -gimp_ace_SOURCES = \ - gimp_ace.c \ - gimp_ace.h \ - glace.c \ - glace.h \ - glaceG.c \ - glaceInt.h \ - dialog.c \ - color.h \ - acconfig.h - -AM_CPPFLAGS = \ - -DGLACE_GIMP \ - -DVERSION=\"0.5.0\" - -INCLUDES = \ - -I$(top_srcdir) \ - $(GTK_CFLAGS) \ - -I$(includedir) - -LDADD = \ - $(top_builddir)/libgimp/libgimp.la \ - $(GTK_LIBS) \ - $(INTLLIBS) - -.PHONY: files - -files: - @files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \ - echo $$p; \ - done diff --git a/plug-ins/gimp_ace/Makefile.in b/plug-ins/gimp_ace/Makefile.in deleted file mode 100644 index f62181c1e4..0000000000 --- a/plug-ins/gimp_ace/Makefile.in +++ /dev/null @@ -1,483 +0,0 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am - -# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include - -DESTDIR = - -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ - -top_builddir = ../.. - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -transform = @program_transform_name@ - -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -host_alias = @host_alias@ -host_triplet = @host@ -AA = @AA@ -AS = @AS@ -CATALOGS = @CATALOGS@ -CATOBJEXT = @CATOBJEXT@ -CC = @CC@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -DATADIRNAME = @DATADIRNAME@ -DLLTOOL = @DLLTOOL@ -EMACS = @EMACS@ -EXTENSIVE_TESTS = @EXTENSIVE_TESTS@ -GAP_DECODE_MPEG = @GAP_DECODE_MPEG@ -GENCAT = @GENCAT@ -GIMP = @GIMP@ -GIMPDOCS = @GIMPDOCS@ -GIMPINSTALL = @GIMPINSTALL@ -GIMPTOOL = @GIMPTOOL@ -GIMP_CFLAGS = @GIMP_CFLAGS@ -GIMP_CFLAGS_NOUI = @GIMP_CFLAGS_NOUI@ -GIMP_LIBS = @GIMP_LIBS@ -GIMP_LIBS_NOUI = @GIMP_LIBS_NOUI@ -GIMP_MAJOR_VERSION = @GIMP_MAJOR_VERSION@ -GIMP_MICRO_VERSION = @GIMP_MICRO_VERSION@ -GIMP_MINOR_VERSION = @GIMP_MINOR_VERSION@ -GIMP_MODULES = @GIMP_MODULES@ -GIMP_MP_FLAGS = @GIMP_MP_FLAGS@ -GIMP_MP_LIBS = @GIMP_MP_LIBS@ -GIMP_PERL = @GIMP_PERL@ -GIMP_PLUGINS = @GIMP_PLUGINS@ -GIMP_THREAD_FLAGS = @GIMP_THREAD_FLAGS@ -GIMP_THREAD_LIBS = @GIMP_THREAD_LIBS@ -GIMP_VERSION = @GIMP_VERSION@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_LIBS = @GLIB_LIBS@ -GMOFILES = @GMOFILES@ -GMSGFMT = @GMSGFMT@ -GNOME_CONFIG = @GNOME_CONFIG@ -GTKXMHTML_CFLAGS = @GTKXMHTML_CFLAGS@ -GTKXMHTML_LIBS = @GTKXMHTML_LIBS@ -GTK_CFLAGS = @GTK_CFLAGS@ -GTK_CONFIG = @GTK_CONFIG@ -GTK_LIBS = @GTK_LIBS@ -GT_NO = @GT_NO@ -GT_YES = @GT_YES@ -HELPBROWSER = @HELPBROWSER@ -INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@ -INSTOBJEXT = @INSTOBJEXT@ -INTLDEPS = @INTLDEPS@ -INTLLIBS = @INTLLIBS@ -INTLOBJS = @INTLOBJS@ -IN_GIMP = @IN_GIMP@ -JPEG = @JPEG@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAA = @LIBAA@ -LIBJPEG = @LIBJPEG@ -LIBMPEG = @LIBMPEG@ -LIBPNG = @LIBPNG@ -LIBTIFF = @LIBTIFF@ -LIBTOOL = @LIBTOOL@ -LIBUCB = @LIBUCB@ -LIBXMU = @LIBXMU@ -LIBXPM = @LIBXPM@ -LIBZ = @LIBZ@ -LN_S = @LN_S@ -LPC_COMMAND = @LPC_COMMAND@ -LPC_DEF = @LPC_DEF@ -LPR_COMMAND = @LPR_COMMAND@ -LPR_DEF = @LPR_DEF@ -LPSTAT_COMMAND = @LPSTAT_COMMAND@ -LPSTAT_DEF = @LPSTAT_DEF@ -LP_COMMAND = @LP_COMMAND@ -LP_DEF = @LP_DEF@ -LT_AGE = @LT_AGE@ -LT_CURRENT = @LT_CURRENT@ -LT_RELEASE = @LT_RELEASE@ -LT_REVISION = @LT_REVISION@ -MAILER = @MAILER@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MKINSTALLDIRS = @MKINSTALLDIRS@ -MPEG = @MPEG@ -MSGFMT = @MSGFMT@ -NM = @NM@ -OBJDUMP = @OBJDUMP@ -PACKAGE = @PACKAGE@ -PERL = @PERL@ -PNG = @PNG@ -POFILES = @POFILES@ -POSUB = @POSUB@ -PSP = @PSP@ -PYGIMP_CFLAGS_NOUI = @PYGIMP_CFLAGS_NOUI@ -PYGIMP_LIBS_NOUI = @PYGIMP_LIBS_NOUI@ -PYTHON = @PYTHON@ -PYTHON_CFLAGS = @PYTHON_CFLAGS@ -PYTHON_INCLUDES = @PYTHON_INCLUDES@ -PYTHON_LINK = @PYTHON_LINK@ -RANLIB = @RANLIB@ -SENDMAIL = @SENDMAIL@ -SO = @SO@ -TIFF = @TIFF@ -USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ -USE_NLS = @USE_NLS@ -VERSION = @VERSION@ -WEBBROWSER = @WEBBROWSER@ -XJT = @XJT@ -XPM = @XPM@ -brushdata = @brushdata@ -gimpdatadir = @gimpdatadir@ -gimpdir = @gimpdir@ -gimpplugindir = @gimpplugindir@ -gradientdata = @gradientdata@ -l = @l@ -localedir = @localedir@ -palettedata = @palettedata@ -patterndata = @patterndata@ -prefix = @prefix@ -pyexecdir = @pyexecdir@ -pythondir = @pythondir@ - -libexecdir = $(gimpplugindir)/plug-ins - -libexec_PROGRAMS = gimp_ace - -gimp_ace_SOURCES = \ - gimp_ace.c \ - gimp_ace.h \ - glace.c \ - glace.h \ - glaceG.c \ - glaceInt.h \ - dialog.c \ - color.h \ - acconfig.h - - -AM_CPPFLAGS = \ - -DGLACE_GIMP \ - -DVERSION=\"0.5.0\" - - -INCLUDES = \ - -I$(top_srcdir) \ - $(GTK_CFLAGS) \ - -I$(includedir) - - -LDADD = \ - $(top_builddir)/libgimp/libgimp.la \ - $(GTK_LIBS) \ - $(INTLLIBS) - -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = ../../config.h -CONFIG_CLEAN_FILES = -PROGRAMS = $(libexec_PROGRAMS) - - -DEFS = @DEFS@ -I. -I$(srcdir) -I../.. -LIBS = @LIBS@ -gimp_ace_OBJECTS = gimp_ace.o glace.o glaceG.o dialog.o -gimp_ace_LDADD = $(LDADD) -gimp_ace_DEPENDENCIES = $(top_builddir)/libgimp/libgimp.la -gimp_ace_LDFLAGS = -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ -DIST_COMMON = README AUTHORS ChangeLog Makefile.am Makefile.in NEWS \ -TODO - - -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) - -TAR = tar -GZIP_ENV = --best -DEP_FILES = .deps/dialog.P .deps/gimp_ace.P .deps/glace.P \ -.deps/glaceG.P -SOURCES = $(gimp_ace_SOURCES) -OBJECTS = $(gimp_ace_OBJECTS) - -all: all-redirect -.SUFFIXES: -.SUFFIXES: .S .c .lo .o .s -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu plug-ins/gimp_ace/Makefile - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - - -mostlyclean-libexecPROGRAMS: - -clean-libexecPROGRAMS: - -test -z "$(libexec_PROGRAMS)" || rm -f $(libexec_PROGRAMS) - -distclean-libexecPROGRAMS: - -maintainer-clean-libexecPROGRAMS: - -install-libexecPROGRAMS: $(libexec_PROGRAMS) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(libexecdir) - @list='$(libexec_PROGRAMS)'; for p in $$list; do \ - if test -f $$p; then \ - echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(libexecdir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ - $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(libexecdir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ - else :; fi; \ - done - -uninstall-libexecPROGRAMS: - @$(NORMAL_UNINSTALL) - list='$(libexec_PROGRAMS)'; for p in $$list; do \ - rm -f $(DESTDIR)$(libexecdir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ - done - -.s.o: - $(COMPILE) -c $< - -.S.o: - $(COMPILE) -c $< - -mostlyclean-compile: - -rm -f *.o core *.core - -clean-compile: - -distclean-compile: - -rm -f *.tab.c - -maintainer-clean-compile: - -.s.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -.S.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -maintainer-clean-libtool: - -gimp_ace: $(gimp_ace_OBJECTS) $(gimp_ace_DEPENDENCIES) - @rm -f gimp_ace - $(LINK) $(gimp_ace_LDFLAGS) $(gimp_ace_OBJECTS) $(gimp_ace_LDADD) $(LIBS) - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $$unique $(LISP) - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) - -mostlyclean-tags: - -clean-tags: - -distclean-tags: - -rm -f TAGS ID - -maintainer-clean-tags: - -distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) - -subdir = plug-ins/gimp_ace - -distdir: $(DISTFILES) - here=`cd $(top_builddir) && pwd`; \ - top_distdir=`cd $(top_distdir) && pwd`; \ - distdir=`cd $(distdir) && pwd`; \ - cd $(top_srcdir) \ - && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu plug-ins/gimp_ace/Makefile - @for file in $(DISTFILES); do \ - d=$(srcdir); \ - if test -d $$d/$$file; then \ - cp -pr $$/$$file $(distdir)/$$file; \ - else \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file || :; \ - fi; \ - done - -DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) - --include $(DEP_FILES) - -mostlyclean-depend: - -clean-depend: - -distclean-depend: - -rm -rf .deps - -maintainer-clean-depend: - -%.o: %.c - @echo '$(COMPILE) -c $<'; \ - $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-cp .deps/$(*F).pp .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm .deps/$(*F).pp - -%.lo: %.c - @echo '$(LTCOMPILE) -c $<'; \ - $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ - < .deps/$(*F).pp > .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm -f .deps/$(*F).pp -info-am: -info: info-am -dvi-am: -dvi: dvi-am -check-am: all-am -check: check-am -installcheck-am: -installcheck: installcheck-am -install-exec-am: install-libexecPROGRAMS -install-exec: install-exec-am - -install-data-am: -install-data: install-data-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -install: install-am -uninstall-am: uninstall-libexecPROGRAMS -uninstall: uninstall-am -all-am: Makefile $(PROGRAMS) -all-redirect: all-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install -installdirs: - $(mkinstalldirs) $(DESTDIR)$(libexecdir) - - -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -maintainer-clean-generic: -mostlyclean-am: mostlyclean-libexecPROGRAMS mostlyclean-compile \ - mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ - mostlyclean-generic - -mostlyclean: mostlyclean-am - -clean-am: clean-libexecPROGRAMS clean-compile clean-libtool clean-tags \ - clean-depend clean-generic mostlyclean-am - -clean: clean-am - -distclean-am: distclean-libexecPROGRAMS distclean-compile \ - distclean-libtool distclean-tags distclean-depend \ - distclean-generic clean-am - -rm -f libtool - -distclean: distclean-am - -maintainer-clean-am: maintainer-clean-libexecPROGRAMS \ - maintainer-clean-compile maintainer-clean-libtool \ - maintainer-clean-tags maintainer-clean-depend \ - maintainer-clean-generic distclean-am - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - -maintainer-clean: maintainer-clean-am - -.PHONY: mostlyclean-libexecPROGRAMS distclean-libexecPROGRAMS \ -clean-libexecPROGRAMS maintainer-clean-libexecPROGRAMS \ -uninstall-libexecPROGRAMS install-libexecPROGRAMS mostlyclean-compile \ -distclean-compile clean-compile maintainer-clean-compile \ -mostlyclean-libtool distclean-libtool clean-libtool \ -maintainer-clean-libtool tags mostlyclean-tags distclean-tags \ -clean-tags maintainer-clean-tags distdir mostlyclean-depend \ -distclean-depend clean-depend maintainer-clean-depend info-am info \ -dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ -install-exec install-data-am install-data install-am install \ -uninstall-am uninstall all-redirect all-am all installdirs \ -mostlyclean-generic distclean-generic clean-generic \ -maintainer-clean-generic clean mostlyclean distclean maintainer-clean - - -.PHONY: files - -files: - @files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \ - echo $$p; \ - done - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/plug-ins/gimp_ace/NEWS b/plug-ins/gimp_ace/NEWS deleted file mode 100644 index c05a268092..0000000000 --- a/plug-ins/gimp_ace/NEWS +++ /dev/null @@ -1,30 +0,0 @@ -0.5.0, 12/31/1999: - - * The method used to reconstitute colors is now selectable from the - dialog. The operational description used for Alex's method is "add - white", while the method from 0.4.990720 is called "limit". Better - translations are always apprecaite. - -0.4.991003: - - * Merged with Alex's update in theory, little changed in practice. - -0.4.990721: - - * Button to link strength and brightness adjust. - -0.4.990720: - - * Color image handling changed. No more frost, but red is weird. - -0.4.990719: - - * Addition of a user interface to fiddle with the options. - - * gettext support in place (I hope). Translations appreciated. - - * The coefficients used in the RGB -> luminosity conversion changed. - See file "color.h" - - * I wrote some help-text to go with the interface. - http://www.oberlin.edu/~kturner/gimp/ace/gimp_ace-help.html \ No newline at end of file diff --git a/plug-ins/gimp_ace/README b/plug-ins/gimp_ace/README deleted file mode 100644 index e5422d8e5c..0000000000 --- a/plug-ins/gimp_ace/README +++ /dev/null @@ -1,29 +0,0 @@ -Adaptive Contrast Enhancement plug-in for the GIMP 1.x -====================================================== - -FIXME: I still need a good concise, non-technical description of what -this plug-in does in comparison to the other "Enhance Contrast" -operations. - -Technical Details -================= - -Adaptive Image Contrast Enhancement using Generalizations of Histogram - Equalization -J.A. Stark, NISS (January 1999). -(FIXME: ¿published in IEEE Transactions on Image Processing?) -http://www.niss.org/~stark/pubs.html - -References -========== - -GIMP is the GNU Image Manipulation Program -http://www.gimp.org/ - -The GIMP Plug-in Registry is at -http://registry.gimp.org/ - -You can find Adaptive Contrast Enhancement at -http://www.poboxes.com/kevint/gimp/gimp_ace.html - - -- Kevin Turner diff --git a/plug-ins/gimp_ace/TODO b/plug-ins/gimp_ace/TODO deleted file mode 100644 index 0cf9a3f7b0..0000000000 --- a/plug-ins/gimp_ace/TODO +++ /dev/null @@ -1,5 +0,0 @@ -* fix 'make install' -* Add preview -* Merge with Alex on Glace_Output, add switch for how to handle out-of-gamut - colors (either preserve-luma or preserve-chroma) - diff --git a/plug-ins/gimp_ace/color.h b/plug-ins/gimp_ace/color.h deleted file mode 100644 index f76e546289..0000000000 --- a/plug-ins/gimp_ace/color.h +++ /dev/null @@ -1,55 +0,0 @@ -/* These are the weighing factors used to convert color images to - the one-dimensional channel (luminosity?) to operate on - in gimp_ace.c:SeperateChannels() - They're recombined in glace.c:Glace_Output(), - which should undergo some scrutiny. */ -/* For more on this subject, see the thread in gimp-developer - From: Carey Bunks - Subject: [gimp-devel] Conversion to Grayscale Bug - and http://www.inforamp.net/~poynton/ */ - -#ifndef NTSC_RGB - -/* These are used to compute CIE luminace from linear RGB for - contemporary CRT phosphors, as specified in ITU-R Recommendation - BT.709 (formerly CCIR Rec. 709) */ - -/* Matrix for RGB -> XYZ conversion. */ - -#define X_r 0.412453 -#define X_g 0.357580 -#define X_b 0.180423 - -#define Y_r 0.212671 -#define Y_g 0.715160 -#define Y_b 0.072169 - -#define Z_r 0.019334 -#define Z_g 0.119193 -#define Z_b 0.950227 - -/* Matrix for XYZ -> RGB version. */ - -#define R_x 3.240479 -#define R_y -1.537150 -#define R_z -0.498535 - -#define G_x -0.969256 -#define G_y 1.876992 -#define G_z 0.041556 - -#define B_x 0.055648 -#define B_y -0.204043 -#define B_z 1.057311 - -#else - -/* This computes luma from RGB, according to NTSC RGB CRT phosphors of - 1953. Standardized in ITU-R Recommendation BT.601-4. (formerly - CCIR Rec. 601) */ - -#define Y_r 0.299 -#define Y_g 0.587 -#define Y_b 0.114 - -#endif diff --git a/plug-ins/gimp_ace/dialog.c b/plug-ins/gimp_ace/dialog.c deleted file mode 100644 index 896dc75bdb..0000000000 --- a/plug-ins/gimp_ace/dialog.c +++ /dev/null @@ -1,503 +0,0 @@ -/* dialog.c: user interface for GIMP Adaptive Contrast Enhancment plug-in */ -/* Copyright (C) 1999 Kevin M. Turner */ -/* $Id$ */ - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. See the file COPYING for details. - * - */ - -#include /* autostuff */ - -#include /* for asprintf(wintitle,...) */ - -#include -#include - -#include /* i18n - gettext */ -#define _(String) gettext (String) -#ifdef gettext_noop -# define N_(String) gettext_noop (String) -#else -# define N_(String) (String) -#endif - -#include "gimp_ace.h" /* AceValues */ - -static void ok_callback (GtkWidget *widget, gpointer data); -static void close_callback (GtkWidget *widget, gpointer data); -static GtkWidget *ace_dialog_new(GtkSignalFunc ok_callback, - GtkSignalFunc close_callback, - gboolean *go_ahead); -static void adjust_double_changed (GtkAdjustment *adj, - gpointer *unused); -static void adjust_uint_changed (GtkAdjustment *adj, - gpointer *unused); - -static void omenu_callback (GtkWidget *menuitem, - gpointer data); - -static void toggled_cb (GtkToggleButton *toggle, - gboolean *data); - -static void strength_changed (GtkAdjustment *strength_adj, - GtkAdjustment *bradj_adj); -static void bradj_changed (GtkAdjustment *bradj_adj, - gpointer unused); - -#define SPACING 4 -#define HBOX_SPACING SPACING -#define DIALOG_BORDER_WIDTH 0 -#define OUTER_BORDER_WIDTH 6 -#define ACTION_AREA_BORDER_WIDTH OUTER_BORDER_WIDTH -#define TOP_AREA_BORDER_WIDTH OUTER_BORDER_WIDTH -#define TABLE_ROW_SPACING SPACING -#define TABLE_COL_SPACING SPACING - -#define SPIN_ATTOPT_X GTK_EXPAND | GTK_FILL -#define SPIN_ATTOPT_Y 0 - -#define SCALE_ATTOPT_X GTK_EXPAND | GTK_FILL -#define SCALE_ATTOPT_Y 0 - -#define LABEL_ATTOPT 0 - -gboolean ace_dialog(guint32 drawable_id, AceValues *acevals) -{ - GtkWidget *dlg; - - GtkWidget *vbox1; - GtkWidget *table1; - GtkObject *bradj_scale_adj; - GtkWidget *bradj_scale; - GtkObject *strength_scale_adj; - GtkWidget *strength_scale; - GtkWidget *link_toggle; - GtkWidget *label; - GtkWidget *hseparator; - GtkWidget *table2; - GtkObject *iter_spin_adj; - GtkWidget *iter_spin; - GtkObject *size_spin_adj; - GtkWidget *size_spin; - GtkObject *smooth_spin_adj; - GtkWidget *smooth_spin; - GtkObject *foobarum_spin_adj; - GtkWidget *foobarum_spin; - - GtkTooltips *tooltips; - - GtkWidget *menuitem, *color_menu, *color_omenu; - GtkWidget *frame; - - gboolean go_ahead=FALSE; - -#if 0 - printf("Waiting... (pid %d)\n", getpid()); - kill(getpid(), 19); -#endif - - /* Standard gimp_dialog creation. */ - dlg = ace_dialog_new((GtkSignalFunc) ok_callback, - (GtkSignalFunc) close_callback, - &go_ahead); - - tooltips=gtk_tooltips_new(); - - /* Neato Box */ - vbox1 = gtk_vbox_new (FALSE, SPACING); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dlg)->vbox),vbox1, - TRUE, TRUE, 0); - gtk_container_border_width (GTK_CONTAINER (vbox1), - TOP_AREA_BORDER_WIDTH); - - /* Table which holds sliders */ - table1 = gtk_table_new (2, 3, FALSE); - gtk_box_pack_start (GTK_BOX (vbox1), table1, TRUE, TRUE, 0); - gtk_table_set_row_spacings (GTK_TABLE (table1), SPACING); - gtk_table_set_col_spacings (GTK_TABLE (table1), SPACING); - - /* slider: strength */ - strength_scale_adj=gtk_adjustment_new (acevals->strength, - 0, 1, 0.01, 0.1, 0); - strength_scale = gtk_hscale_new (GTK_ADJUSTMENT (strength_scale_adj)); - gtk_widget_set_name (strength_scale, "strength_scale"); - gtk_table_attach (GTK_TABLE (table1), strength_scale, 1, 2, 0, 1, - SCALE_ATTOPT_X, SCALE_ATTOPT_Y, - 0, 0); - gtk_scale_set_value_pos (GTK_SCALE (strength_scale), GTK_POS_LEFT); - gtk_scale_set_digits (GTK_SCALE (strength_scale), 2); - gtk_range_set_update_policy (GTK_RANGE (strength_scale), - GTK_UPDATE_DELAYED); - - /* slider: Brightness adjust */ - bradj_scale_adj=gtk_adjustment_new (acevals->bradj, - 0, 1, 0.01, 0.1, 0); - bradj_scale = gtk_hscale_new (GTK_ADJUSTMENT (bradj_scale_adj)); - gtk_widget_set_name (bradj_scale, "bradj_scale"); - gtk_table_attach (GTK_TABLE (table1), bradj_scale, 1, 2, 1, 2, - SCALE_ATTOPT_X, SCALE_ATTOPT_Y, - 0, 0); - gtk_scale_set_value_pos (GTK_SCALE (bradj_scale), GTK_POS_LEFT); - gtk_scale_set_digits (GTK_SCALE (bradj_scale), 2); - gtk_range_set_update_policy (GTK_RANGE (bradj_scale), - GTK_UPDATE_DELAYED); - - /* Link toggle */ - link_toggle = gtk_toggle_button_new_with_label(_("Link")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(link_toggle), - acevals->link); - gtk_signal_connect (GTK_OBJECT(link_toggle),"toggled", - GTK_SIGNAL_FUNC(toggled_cb), - &(acevals->link)); - gtk_table_attach (GTK_TABLE (table1), link_toggle, 2, 3, 0, 2, - LABEL_ATTOPT, LABEL_ATTOPT, - 0, 0); - - /* Callbacks for above adjustments */ - gtk_object_set_user_data(GTK_OBJECT(strength_scale_adj), - &(acevals->strength)); - gtk_signal_connect (GTK_OBJECT (strength_scale_adj), "value_changed", - GTK_SIGNAL_FUNC (strength_changed), - bradj_scale_adj); - - gtk_object_set_user_data(GTK_OBJECT(bradj_scale_adj), - &(acevals->bradj)); - gtk_object_set_data(GTK_OBJECT(bradj_scale_adj), - "link", link_toggle); - gtk_signal_connect (GTK_OBJECT (bradj_scale_adj), "value_changed", - GTK_SIGNAL_FUNC (bradj_changed), - NULL); - - /* Labels for brightness adjust and strength */ - label = gtk_label_new (_("Strength:")); - gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 0, 1, - LABEL_ATTOPT, LABEL_ATTOPT, - 0, 0); - - label = gtk_label_new (_("Brightness Adjust:")); - gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 1, 2, - LABEL_ATTOPT, LABEL_ATTOPT, - 0, 0); - - /* Seperator */ - hseparator = gtk_hseparator_new (); - gtk_box_pack_start (GTK_BOX (vbox1), hseparator, FALSE, FALSE, 0); - - /* Table which holds spinbuttons */ - /* (iterations, size, threshold) */ - - table2 = gtk_table_new (2, 4, FALSE); - gtk_box_pack_start (GTK_BOX (vbox1), table2, TRUE, TRUE, 0); - gtk_table_set_row_spacings (GTK_TABLE (table2), SPACING); - gtk_table_set_col_spacings (GTK_TABLE (table2), SPACING); - - /* Iteration spin */ - iter_spin_adj = gtk_adjustment_new (acevals->iterations, - 1, 200, 1, 10, 0); - iter_spin = gtk_spin_button_new (GTK_ADJUSTMENT (iter_spin_adj), - 1, 0); - gtk_widget_set_name (iter_spin, "iteration_spin"); - gtk_table_attach (GTK_TABLE (table2), iter_spin, 0, 1, 1, 2, - SPIN_ATTOPT_X, SPIN_ATTOPT_Y, - 0, 0); - gtk_object_set_user_data(GTK_OBJECT(iter_spin_adj), - &(acevals->iterations)); - gtk_signal_connect (GTK_OBJECT (iter_spin_adj), "value_changed", - GTK_SIGNAL_FUNC (adjust_uint_changed), NULL); - - /* Iteration label */ - label = gtk_label_new (_("Iterations:")); - gtk_table_attach (GTK_TABLE (table2), label, 0, 1, 0, 1, - LABEL_ATTOPT, LABEL_ATTOPT, - 0, 0); - - /* size spin */ - size_spin_adj = gtk_adjustment_new (acevals->wsize, - 4, 128, 1, 10, 0); - size_spin = gtk_spin_button_new (GTK_ADJUSTMENT (size_spin_adj), 1, 0); - gtk_widget_set_name (size_spin, "size_spin"); - gtk_table_attach (GTK_TABLE (table2), size_spin, 1, 2, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, - 0, 0); - gtk_object_set_user_data(GTK_OBJECT(size_spin_adj), - &(acevals->wsize)); - gtk_signal_connect (GTK_OBJECT (size_spin_adj), "value_changed", - GTK_SIGNAL_FUNC (adjust_uint_changed), NULL); - - /* size label */ - label = gtk_label_new (_("Detail Size:")); - gtk_table_attach (GTK_TABLE (table2), label, 1, 2, 0, 1, - LABEL_ATTOPT, LABEL_ATTOPT, - 0, 0); - - /* smoothing spin */ - smooth_spin_adj = gtk_adjustment_new (acevals->smoothing, - 0, 100, 5, 10, 0); - smooth_spin = gtk_spin_button_new (GTK_ADJUSTMENT (smooth_spin_adj), - 1, 0); - gtk_widget_set_name (smooth_spin, "smooth_spin"); - gtk_table_attach (GTK_TABLE (table2), smooth_spin, 2, 3, 1, 2, - SPIN_ATTOPT_X, SPIN_ATTOPT_Y, - 0, 0); - gtk_object_set_user_data(GTK_OBJECT(smooth_spin_adj), - &(acevals->smoothing)); - gtk_signal_connect (GTK_OBJECT (smooth_spin_adj), "value_changed", - GTK_SIGNAL_FUNC (adjust_double_changed), NULL); - - /* smoothing label */ - label = gtk_label_new (_("Smoothing:")); - gtk_table_attach (GTK_TABLE (table2), label, 2, 3, 0, 1, - LABEL_ATTOPT, LABEL_ATTOPT, - 0, 0); - - /* foobarum spin */ - foobarum_spin_adj = gtk_adjustment_new (acevals->coefftol, - 0, 1, .001, .01, 0); - foobarum_spin = gtk_spin_button_new (GTK_ADJUSTMENT (foobarum_spin_adj), - 1, 3); - gtk_widget_set_name (foobarum_spin, "foobarum_spin"); - gtk_table_attach (GTK_TABLE (table2), foobarum_spin, 3, 4, 1, 2, - SPIN_ATTOPT_X, SPIN_ATTOPT_Y, - 0, 0); - gtk_object_set_user_data(GTK_OBJECT(foobarum_spin_adj), - &(acevals->coefftol)); - gtk_signal_connect (GTK_OBJECT (foobarum_spin_adj), "value_changed", - GTK_SIGNAL_FUNC (adjust_double_changed), NULL); - - /* foobarum label */ - label = gtk_label_new (_("foobarm:")); - gtk_table_attach (GTK_TABLE (table2), label, 3, 4, 0, 1, - LABEL_ATTOPT, LABEL_ATTOPT, - 0, 0); - - /** Color method **/ - frame=gtk_frame_new(_("Color Overflow")); - - color_menu=gtk_menu_new(); - - menuitem = gtk_menu_item_new_with_label(_("limit")); - gtk_menu_append(GTK_MENU(color_menu), menuitem); - gtk_object_set_user_data(GTK_OBJECT(menuitem), - GUINT_TO_POINTER(GLACE_COLOR_Yxy)); - gtk_signal_connect(GTK_OBJECT(menuitem), "activate", - GTK_SIGNAL_FUNC(omenu_callback), - &(acevals->color_method)); - - menuitem = gtk_menu_item_new_with_label(_("add white")); - gtk_menu_append(GTK_MENU(color_menu), menuitem); - gtk_object_set_user_data(GTK_OBJECT(menuitem), - GUINT_TO_POINTER(GLACE_COLOR_LUMIN)); - gtk_signal_connect(GTK_OBJECT(menuitem),"activate", - GTK_SIGNAL_FUNC(omenu_callback), - &(acevals->color_method)); - - gtk_widget_show_all(color_menu); - - color_omenu = gtk_option_menu_new(); - gtk_option_menu_set_menu(GTK_OPTION_MENU(color_omenu), - color_menu); - - switch(acevals->color_method) { - case GLACE_COLOR_Yxy: - gtk_option_menu_set_history(GTK_OPTION_MENU(color_omenu), 0); - break; - case GLACE_COLOR_LUMIN: - gtk_option_menu_set_history(GTK_OPTION_MENU(color_omenu), 1); - break; - } - - gtk_container_add(GTK_CONTAINER(frame), color_omenu); - gtk_box_pack_start (GTK_BOX(vbox1), frame, FALSE, TRUE, 0); - - /* done */ - - gtk_widget_show_all(dlg); - - gtk_main(); - - return(go_ahead); -} - -/* ???_dialog_new: */ -/* This should probably be generalized into a libgimpui function, - but there are many different strings for argv0, wmclass, - and window title, and I find it easier to hardcode them now. */ -static GtkWidget *ace_dialog_new(GtkSignalFunc ok_callback, - GtkSignalFunc close_callback, - gboolean *go_ahead) -{ - GtkWidget *dlg; - GtkWidget *button; - - guchar *color_cube; - - gchar *wintitle; - - gchar **argv; - gint argc; - - /* It's desirable to have an argv0 to pass to gtk_init, - so that GTK+ knows what the program's name is... */ - argc = 1; - argv = g_new (gchar *, 1); - argv[0] = g_strdup ("gimp_ace"); - - gtk_init (&argc, &argv); - - gtk_rc_parse (gimp_gtkrc ()); - - /* FIXME: I don't understand any of this colormapcube stuff. */ - gtk_preview_set_gamma(gimp_gamma()); - gtk_preview_set_install_cmap(gimp_install_cmap()); - color_cube = gimp_color_cube(); - gtk_preview_set_color_cube(color_cube[0], color_cube[1], color_cube[2], color_cube[3]); - - gtk_widget_set_default_visual(gtk_preview_get_visual()); - gtk_widget_set_default_colormap(gtk_preview_get_cmap()); - - dlg = gtk_dialog_new (); - - gtk_window_set_wmclass(GTK_WINDOW(dlg), - "plug-in-ace", - "Gimp"); - - gtk_widget_set_name(dlg,"plug-in-ace"); - - /* This window title includes the version string. */ - wintitle = g_strdup_printf(_("Adaptive Contrast Enhancement v %s"), - VERSION); - gtk_window_set_title (GTK_WINDOW (dlg), - wintitle); - g_free(wintitle); - gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE); - gtk_signal_connect (GTK_OBJECT (dlg), "destroy", - close_callback, - NULL); - - /* Various border settings... */ - gtk_container_border_width(GTK_CONTAINER(dlg), - DIALOG_BORDER_WIDTH); - gtk_container_border_width(GTK_CONTAINER(GTK_DIALOG(dlg)->action_area), - ACTION_AREA_BORDER_WIDTH); - /* Action Area */ - - gtk_widget_set_name(GTK_DIALOG(dlg)->action_area,"action_area"); - - button = gtk_button_new_with_label(_("OK")); - gtk_widget_set_name(button,"ok_button"); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(ok_callback), - go_ahead); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg)->action_area), - button, TRUE, TRUE, 0); - gtk_widget_grab_default(button); - - button = gtk_button_new_with_label(_("Cancel")); - gtk_widget_set_name(button,"cancel_button"); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - close_callback, - NULL); - - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg)->action_area), - button, TRUE, TRUE, 0); - - /* FIXME: I'm missing a HELP button. */ - - return dlg; -} - -static void -adjust_uint_changed (GtkAdjustment *adj, gpointer *unused) -{ - guint *variable; - variable=gtk_object_get_user_data(GTK_OBJECT(adj)); - *variable=(guint)(adj->value); - -/* dialog_update_preview(pre_info); */ -} - -static void -adjust_double_changed (GtkAdjustment *adj, gpointer *unused) -{ - gdouble *variable; - variable=gtk_object_get_user_data(GTK_OBJECT(adj)); - *variable=(gdouble)(adj->value); - -/* dialog_update_preview(pre_info); */ -} - -static void -toggled_cb (GtkToggleButton *toggle, gboolean *data) -{ - *data=toggle->active; -} - -static void -strength_changed (GtkAdjustment *strength_adj, GtkAdjustment *bradj_adj) -{ - GtkToggleButton *link_toggle = NULL; - gdouble *strength; - strength=gtk_object_get_user_data (GTK_OBJECT(strength_adj)); - *strength=(gdouble)(strength_adj->value); - - link_toggle= - GTK_TOGGLE_BUTTON(gtk_object_get_data(GTK_OBJECT(bradj_adj), - "link")); - - if(link_toggle->active) - gtk_adjustment_set_value (bradj_adj, *strength); -} - -static void -bradj_changed (GtkAdjustment *bradj_adj, gpointer unused) -{ - GtkToggleButton *link_toggle = NULL; - gdouble *bradj_p=NULL; - gdouble bradj=(gdouble)(bradj_adj->value); - - if(TRUE) { - bradj_p = gtk_object_get_user_data (GTK_OBJECT(bradj_adj)); - *bradj_p = bradj; - } - - if(FALSE) { - link_toggle= - GTK_TOGGLE_BUTTON(gtk_object_get_data(GTK_OBJECT(bradj_adj), - "link")); - gtk_toggle_button_set_active(link_toggle, FALSE); - } - -} - -static void -omenu_callback (GtkWidget *menuitem, gpointer data) -{ - *((Glace_ColorMethods*)data) = - (Glace_ColorMethods)GPOINTER_TO_UINT( - gtk_object_get_user_data(GTK_OBJECT(menuitem))); - printf("option menu set data to %d\n", - *((Glace_ColorMethods*)data)); -} - - -static void -ok_callback (GtkWidget *unused, gpointer data) -{ - gboolean *go_ahead=(gboolean*)data; - - *go_ahead=TRUE; - - gtk_main_quit(); -} - -static void -close_callback (GtkWidget *unused_widget, gpointer unused_data) -{ - gtk_main_quit(); -} diff --git a/plug-ins/gimp_ace/gimp_ace.c b/plug-ins/gimp_ace/gimp_ace.c deleted file mode 100644 index b513680db4..0000000000 --- a/plug-ins/gimp_ace/gimp_ace.c +++ /dev/null @@ -1,581 +0,0 @@ -/* :PREAMBLE: gimp_ace.c - * Adaptive Contrast Enhancement plug-in for the GIMP (v1.0) - * (A windowed histogram equalization using the Fourier-series based - * fast algorithm.) - * Based on J. Alex Stark's GLACE system. - * GIMP Plug-in by Kevin Turner */ - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. See the file COPYING for details. - * - */ - -/* :HEADERS: - */ - -#include "config.h" /* autostuff */ - -#ifndef GLACE_GIMP -# define GLACE_GIMP -#endif - -#include /* i18n - gettext */ -#define _(String) gettext (String) -#ifdef gettext_noop -# define N_(String) gettext_noop (String) -#else -# define N_(String) (String) -#endif - -#include "gimp_ace.h" /* defines the AceValues struct */ -#include "color.h" /* This has the RGB -> Y conversion factors. - for the SeperateChannels */ - - -/* :*** Prototypes ***: - */ - -static void query (void); -static void run (gchar *name, - gint nparams, - GParam *param, - gint *nreturn_vals, - GParam **return_vals); - -static gboolean do_ace(gint32 drawable_id); - -static void GlaceGimp_ReadImgArrays(Glace_WData wData, - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr, - GDrawable *drawable_ptr); - -static int SeperateChannels (guchar *inbuf, const gint buflen, - const gboolean TypeRGB, const gboolean HasAlpha, - const Glace_ColorMethods color_method, - guchar **rbuf, guchar **gbuf, guchar **bbuf, - guchar **Graybuf, - guchar **xbuf, guchar **ybuf, - guchar **ymaxbuf); - -static void GlaceGimp_Process ( - Glace_WData wData, - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - Glace_ImgArrays *imgArraysPtr); - -/* static void GlaceGimp_ScanListfiles (Glace_CfgInfo *cfgInfoPtr); */ - -/* :*** Definitions ***: - */ - -GPlugInInfo PLUG_IN_INFO = -{ - NULL, /* init_proc */ - NULL, /* quit_proc */ - query, /* query_proc */ - run, /* run_proc */ -}; - -static AceValues acevals = -{ - 1.0, /* Strength (full) */ - 0.0, /* brightness adjust (none) */ - 0.0, /* foobarm (none) */ - 0.0, /* smoothing (none) */ - 10, /* iterations */ - 25, /* window size */ - GLACE_COLOR_Yxy, /* Color method */ - TRUE /* link strength and brightness adjust in dialog. */ -}; - -/* :*** MAIN ***: - */ - -MAIN() - -/* :FUNCTION: query - */ - -static void -query () -{ - static GParamDef params[] = { - /* Required params. */ - { PARAM_INT32, "run_mode", "Interactive=0x0, Noninteractive=0x1" }, - { PARAM_IMAGE, "image_id", "(unused)" }, - { PARAM_DRAWABLE, "drawable_id", N_("Drawable to affect") }, - /* Our params. */ - { PARAM_INT32, "ace_argc", "ace argument count" }, - { PARAM_STRINGARRAY, "ace_argv", "ace argument vector" }, - }; - const int nparams = sizeof (params) / sizeof (GParamDef); - - gimp_install_procedure ("plug_in_ace", - _("Adaptive Contrast Enhancement"), - _("FIXME: Write ACE help."), - "Alex Stark, Kevin Turner,", - "Alex Stark, Kevin Turner,", - "1998,1999", - "/Image/Colors/Auto/Adaptive Contrast", - "GRAY*, RGB*", /*FIXME*/ - PROC_PLUG_IN, - nparams, /* # Params */ - 0, /* # return values */ - params, - NULL); /* GParamDef *return_vals */ -} - -/* :FUNCTION: run - */ - -static void -run (gchar *name, gint nparams, GParam *param, - gint *nreturn_vals, GParam **return_vals) -{ - static GParam retvals[1]; - gint needparams; - GRunModeType run_mode; - - *return_vals=retvals; - - *nreturn_vals=1; - retvals[0].type = PARAM_STATUS; - - /* Guilty until proven innocent. */ - retvals[0].data.d_status = STATUS_CALLING_ERROR; - - run_mode=(GRunModeType) param[0].data.d_int32; - - switch(run_mode) { - case RUN_NONINTERACTIVE: - if (nparams < 3 || - param[0].type != PARAM_INT32 || - param[1].type != PARAM_IMAGE || - param[2].type != PARAM_DRAWABLE) { - g_warning("gimp_ace: Caller is on crack! " - "You're not passing me the parameters required for a plug-in. " - "The first three types should be %d, %d, %d; but I'm reading " - "%d, %d, %d.\n", - PARAM_INT32, PARAM_IMAGE, PARAM_DRAWABLE, - param[0].type, param[1].type, param[2].type); - return; - } - if (param[3].type != PARAM_INT32 || - param[4].type != PARAM_STRING) { - g_warning("gimp_ace: caller is passing ace_argc and ace_argv as " - "types %d and %d, should be %d and %d.\n", - param[3].type, param[4].type, - PARAM_INT32, PARAM_STRINGARRAY); - return; - } /* endif param.type */ - /* FIXME: do something intelligent with the parameters. */ - break; - case RUN_INTERACTIVE: - retvals[0].data.d_status = STATUS_EXECUTION_ERROR; - gimp_get_data ("plug_in_ace",&acevals); - if(!ace_dialog (-1, &acevals)) { - /* No error, but dialog cancelled. */ - retvals[0].data.d_status = STATUS_EXECUTION_ERROR; - return; - } /* else continue on and do antialias below. */ - gimp_set_data ("plug_in_ace", &acevals, - sizeof (AceValues)); - break; - case RUN_WITH_LAST_VALS: - gimp_get_data ("plug_in_ace", &acevals); - break; - } - - retvals[0].data.d_status = STATUS_EXECUTION_ERROR; - - retvals[0].data.d_status = do_ace(param[2].data.d_drawable) - ? STATUS_SUCCESS : STATUS_EXECUTION_ERROR; -} - -/* :*** Support Functions ***: - */ - -/* :FUNCTION: do_ace(gint32 drawable_id) - */ -static gboolean -do_ace(gint32 drawable_id) -{ - gchar *ace_argv[] = { "-reset", - "25", - "25", - "10", - "-factor", - "0.0", /* 1.0 is identity, 0.0 is full effect. */ - "-prescale", - "1.0", - "-gauss", - "0", - "-hamming", - "-gg", - "-passthru", - "1.0", - "-inoffset", - "127.5", - "-tol", - "0.0" }; - gint ace_argc=18; - - /* -reset 25 25 10 -cumu -1.2 1.2 361 -factor 1.0 -prescale 1.0 -gauss - 0 -gg -passthru 1.0 -inoffset 127.5 -tol 0.0 -input inImg -output outImg1*/ - - /* gchar *ace_argv[] = { "-reset", "25", "25", "5", "-cumu", "-1.2", - "1.2", "361", "-factor", "0.0", "-prescale", - "1.0", "-gauss", "0", "-gg", - "-passthru", "1.00", "-inoffset", "127.5", "-tol", "0.0"}; */ - - Glace_ClientData *clientData; - GDrawable *drawable_ptr = gimp_drawable_get(drawable_id); - - gimp_progress_init(_("Adaptive Contrast Enhancement:")); -#if 0 - g_message("gimp_ace PID: %d\n",getpid()); - kill(getpid(),19); -#endif - - /* I don't know what most of this does. - It's copied out of pnmace.c */ - clientData = Glace_AllocClientData (); - Glace_WInit(GLACE_CDATA(wData)); - - Glace_CfgInit ( GLACE_CDATA(cfgInfoPtr) ); - - Glace_ParseArgs ( GLACE_CDATA(cfgInfoPtr), - GLACE_CDATA(imgArraysPtr), - ace_argc, ace_argv); - - clientData->cfgInfoPtr->heFactor = 1.0 - acevals.strength; - clientData->cfgInfoPtr->passthruFactor = 1.0 - acevals.bradj; - clientData->cfgInfoPtr->numTerms = acevals.iterations; - clientData->cfgInfoPtr->windBaseW = acevals.wsize; - clientData->cfgInfoPtr->windBaseH = acevals.wsize; - clientData->cfgInfoPtr->coeffTol = acevals.coefftol; - clientData->cfgInfoPtr->gaussCwindWidth = acevals.smoothing; - clientData->cfgInfoPtr->colorMethod= acevals.color_method; - - GLACE_ERROR_EXIT( GLACE_CDATA(wData) ); - Glace_CfgAllocSeriesVectors ( GLACE_CDATA(cfgInfoPtr) ); - /* FIXME: GlaceGimp_ScanListfiles ( GLACE_CDATA(cfgInfoPtr) ); */ - GLACE_ERROR_EXIT( GLACE_CDATA(wData) ); - - Glace_CfgBeginToHeseries ( GLACE_CDATA(cfgInfoPtr) ); - GLACE_ERROR_EXIT( GLACE_CDATA(wData) ); - Glace_CfgHeseriesToAddback ( GLACE_CDATA(cfgInfoPtr) ); - - Glace_CFuncGen ( GLACE_CDATA(cfgInfoPtr) ); - - /* This also allocs the input/ref/ddH/ddV image arrays */ - /* FIXME */ - GlaceGimp_ReadImgArrays ( GLACE_CDATA(wData), GLACE_CDATA(cfgInfoPtr), - GLACE_CDATA(imgArraysPtr), drawable_ptr ); - GLACE_ERROR_EXIT( GLACE_CDATA(wData) ); - - gimp_progress_update(0.1); - - Glace_CfgAddbackToEnd ( GLACE_CDATA(cfgInfoPtr) ); - - Glace_AllocTables ( GLACE_CDATA(cfgInfoPtr), GLACE_CDATA(tableInfoPtr) ); - Glace_DefaultTmpImg ( GLACE_CDATA(cfgInfoPtr), GLACE_CDATA(imgArraysPtr) ); - Glace_AllocImgArrays ( GLACE_CDATA(cfgInfoPtr), GLACE_CDATA(imgArraysPtr) ); - - GlaceGimp_Process ( GLACE_CDATA(wData), GLACE_CDATA(cfgInfoPtr), - GLACE_CDATA(tableInfoPtr), GLACE_CDATA(imgArraysPtr)); - GLACE_ERROR_EXIT( GLACE_CDATA(wData) ); - - Glace_CfgFreeSeriesVectors ( GLACE_CDATA(cfgInfoPtr) ); - Glace_FreeImgArrays ( GLACE_CDATA(cfgInfoPtr), GLACE_CDATA(imgArraysPtr) ); - Glace_FreeTables ( GLACE_CDATA(cfgInfoPtr), GLACE_CDATA(tableInfoPtr) ); - - Glace_FreeClientData ( clientData ); - - /* GlaceGimp_CloseFile (stdout); */ - - return TRUE; -} - -/* :FUNCTION: FIXME GlaceGimp_ReadImgArrays - * Assumptions: Input is one byte-per-pixel grayscale. - */ - -static void -GlaceGimp_ReadImgArrays(Glace_WData wData, Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr, - GDrawable *drawable_ptr) -{ - guchar *gimp_buf=NULL; - gint gimp_size; - GPixelRgn src_rgn; - gint x1, y1, x2, y2; /* Bounds of the selection */ - - /* Nurb Nurb Oink. */ - - GLACE_IMG(inImgPtr) = - GLACE_IMG(inImgCxPtr) = - GLACE_IMG(inImgCyPtr) = - GLACE_IMG(inImgCYMaxPtr) = - GLACE_IMG(inImgRPtr) = - GLACE_IMG(inImgGPtr) = - GLACE_IMG(inImgBPtr) = NULL; - - WRAPPER(drawable_ptr)=drawable_ptr; - - gimp_drawable_mask_bounds (drawable_ptr->id, &x1, &y1, &x2, &y2); - - (((GlaceGimpData *)wData)->gimp_x0 ) =x1; - (((GlaceGimpData *)wData)->gimp_y0 ) =y1; - (imgArraysPtr->cols ) =x2-x1; - (imgArraysPtr->rows ) =y2-y1; - - gimp_pixel_rgn_init(&src_rgn, - WRAPPER(drawable_ptr), - WRAPPER(gimp_x0), WRAPPER(gimp_y0), - GLACE_IMG(cols), GLACE_IMG(rows), - FALSE, FALSE); - - /* skip some pixels on output so we can mix the alpha back in. */ - GLACE_IMG(pixelBytePad) = gimp_drawable_has_alpha(drawable_ptr->id) ? 1 : 0; - - /* This refers to precision, not number of channels. */ - GLACE_IMG(pixelSize) = 1; - - gimp_size = GLACE_IMG(cols) * GLACE_IMG(rows) * drawable_ptr->bpp; - WRAPPER(gimpImgPtr) = gimp_buf = g_new(guchar, gimp_size); - - gimp_pixel_rgn_get_rect(&src_rgn, gimp_buf, - WRAPPER(gimp_x0), WRAPPER(gimp_y0), - GLACE_IMG(cols), GLACE_IMG(rows)); - - imgArraysPtr->inImgSize = - SeperateChannels(gimp_buf, gimp_size, - gimp_drawable_color(drawable_ptr->id), - gimp_drawable_has_alpha(drawable_ptr->id), - cfgInfoPtr->colorMethod, - &imgArraysPtr->inImgPtr, /* Greybuf (to process) */ - &imgArraysPtr->inImgRPtr, /* rbuf */ - &imgArraysPtr->inImgGPtr, /* gbuf */ - &imgArraysPtr->inImgBPtr, /* bbuf */ - &imgArraysPtr->inImgCxPtr, /* xbuf */ - &imgArraysPtr->inImgCyPtr, /* ybuf */ - &imgArraysPtr->inImgCYMaxPtr); /* YMaxbuf */ - - imgArraysPtr->refImgPtr = imgArraysPtr->inImgPtr; - - imgArraysPtr->refImgLBPtr = imgArraysPtr->refImgHBPtr = - imgArraysPtr->inImgLBPtr = imgArraysPtr->inImgHBPtr = - imgArraysPtr->inImgPtr; - - GLACE_CFG(chrome)= gimp_drawable_color(drawable_ptr->id) - ? GLACE_CC : GLACE_GG; - - /* This is forced config stuff. */ - /* if (GLACE_CFG(filtMethod) == GLACE_WINDOW) */ - GLACE_CFG(filtMethod) = GLACE_WINDOW; - GLACE_IMG(ddHImgPtr) = GLACE_IMG(ddVImgPtr) = NULL; - - GLACE_CFG(doublep)=GLACE_FALSE; -} - -static int -SeperateChannels (guchar *inbuf, const gint buflen, - const gboolean TypeRGB, const gboolean HasAlpha, - const Glace_ColorMethods color_method, - guchar **Graybuf, - guchar **rbuf, guchar **gbuf, guchar **bbuf, - guchar **xbuf, guchar **ybuf, - guchar **Ymaxbuf) -{ - int c=0, ic=0, bpp; - guchar *Grayfoo; - if(!TypeRGB && !HasAlpha) { - *Graybuf = inbuf; - return buflen; - } - if(!TypeRGB && HasAlpha) { - if((buflen % 2) != 0) - g_error("GRAYA with odd size %d?",buflen); - if(*Graybuf == NULL) - *Graybuf = g_new(guchar,buflen/2); - - Grayfoo=*Graybuf; - while(ic < buflen) { - Grayfoo[c] = inbuf[ic++]; - ic++; - c++; - } - return c; - } /* if GRAYA */ - if(TypeRGB) { - guchar R,G,B; - guchar *xfoo, *yfoo, *Ymaxfoo; - guchar *rfoo, *bfoo, *gfoo; - - bpp = HasAlpha ? 4 : 3; - if((buflen % bpp) != 0) { - g_error("RGB: %d Alpha: %d. I think bpp should be %d, but that" - "doesn't make sense with size %d, as R = %d", - TypeRGB, HasAlpha, bpp, buflen, buflen % bpp); - } - - - if(*Graybuf == NULL) - *Graybuf = g_new(guchar,buflen/bpp); - - Grayfoo=*Graybuf; - - if(color_method == GLACE_COLOR_Yxy) { - if(*xbuf == NULL) - *xbuf = g_new(guchar,buflen/bpp); - if(*ybuf == NULL) - *ybuf = g_new(guchar,buflen/bpp); - if(*Ymaxbuf == NULL) - *Ymaxbuf = g_new(guchar,buflen/bpp); - - xfoo=*xbuf; - yfoo=*ybuf; - Ymaxfoo=*Ymaxbuf; - - puts("Seperating into Yxy"); - } else { - if(*rbuf == NULL) - *rbuf = g_new(guchar,buflen/bpp); - - if(*gbuf == NULL) - *gbuf = g_new(guchar,buflen/bpp); - - if(*bbuf == NULL) - *bbuf = g_new(guchar,buflen/bpp); - - rfoo=*rbuf; - gfoo=*gbuf; - bfoo=*bbuf; - - puts("Seperating into RGB"); - } - - while(ic < buflen) { - R = inbuf[ic++]; - G = inbuf[ic++]; - B = inbuf[ic++]; - if(HasAlpha) ic++; - - if(color_method != GLACE_COLOR_Yxy) { - rfoo[c]=R; - gfoo[c]=G; - bfoo[c]=B; - } - - if((R==0) && (G==0) && (B==0)) { - /* Black is a special case. Choose values - that won't make divide by 0 errors. */ - Grayfoo[c] = 0; - - if(color_method == GLACE_COLOR_Yxy) { - xfoo[c] = 0; - yfoo[c] = 255; - Ymaxfoo[c] = 255; - } - } else { - gfloat X1, Y1, Z1; - gfloat x,y,z; - gfloat rYmax, gYmax, bYmax; - - /* Calculate XYZ coordinates for original image. */ - Y1 = Y_r * R + Y_g * G + Y_b * B; - - /* This is the channel which is processed. */ - Grayfoo[c] = Y1; - - if(color_method == GLACE_COLOR_Yxy) { - X1 = X_r * R + X_g * G + X_b * B; - Z1 = Z_r * R + Z_g * G + Z_b * B; - - /* Find chromacity xy coordinates. */ - /* Multiplied by 255 because we're not storing - them as floats from 0-1 but in an 8-bit - data type. */ - xfoo[c] = x = 255.0 * X1 / ( X1 + Y1 + Z1 ); - yfoo[c] = y = 255.0 * Y1 / ( X1 + Y1 + Z1 ); - - z = 255.0 - x - y; - - /* This calculates the maximum displayable - luminosity for this color. */ - rYmax = 255.0 / ((1/y) * (R_x * x + R_z * z) + R_y); - gYmax = 255.0 / ((1/y) * (G_x * x + G_z * z) + G_y); - bYmax = 255.0 / ((1/y) * (B_x * x + B_z * z) + B_y); - - Ymaxfoo[c] = MIN(MIN(rYmax,gYmax),bYmax); - } /* endif Yxy */ - } /* endif rgb != 0 */ - c++; - } /* whend */ - return c; - } /* endif rgb */ - g_error("Fell through SeperateChannels."); - return -1; -} /* SeperateChannels() */ - -/**************************************************************/ -/* - * :FUNCTION: Glace_Process - */ -void -GlaceGimp_Process ( - Glace_WData wData, - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - Glace_ImgArrays *imgArraysPtr -) -{ - guint k; - - Glace_WindChk (cfgInfoPtr, GLACE_IMG(cols), GLACE_IMG(rows)); - GLACE_ERROR_CHECK( GLACE_CFG(wData) ); - - Glace_InitAccIm (cfgInfoPtr, imgArraysPtr); - - if (GLACE_CFG(outputMethod) == GLACE_NORMAL) { - for (k = GLACE_CFG(firstTerm); - k <= (unsigned) GLACE_CFG(numTerms); - k++) { - Glace_SetForTerm(tableInfoPtr, k, GLACE_COS); - Glace_TermlyReport( cfgInfoPtr, tableInfoPtr); - - Glace_SetTables (cfgInfoPtr, tableInfoPtr); - Glace_GenGen ( cfgInfoPtr, tableInfoPtr, imgArraysPtr); - GLACE_ERROR_CHECK( GLACE_CFG(wData) ); - - Glace_SetForTerm(tableInfoPtr, k, GLACE_SIN); - - Glace_SetTables (cfgInfoPtr, tableInfoPtr); - Glace_GenGen ( cfgInfoPtr, tableInfoPtr, imgArraysPtr); - GLACE_ERROR_CHECK( GLACE_CFG(wData) ); - - Glace_WMessage( GLACE_CFG(wData), ";\n" ); - - gimp_progress_update(0.10 + 0.90 * k/GLACE_CFG(numTerms)); - } - } else { - Glace_DiagGen (cfgInfoPtr, tableInfoPtr, imgArraysPtr); - } - GLACE_ERROR_CHECK( GLACE_CFG(wData) ); - Glace_Output (wData, cfgInfoPtr, imgArraysPtr ); -} - -/* :FUNCTION: FIXME GlacePnm_ScanListfiles - */ - -/*static void -GlaceGimp_ScanListfiles (Glace_CfgInfo *cfgInfoPtr) -{ - g_warning("GlaceGimp_ScanListFiles in gimp_ace.c not yet implemented.\n"); -}*/ - -/* GlaceGimp_CloseFile (stdout); */ diff --git a/plug-ins/gimp_ace/gimp_ace.h b/plug-ins/gimp_ace/gimp_ace.h deleted file mode 100644 index 94976b17c2..0000000000 --- a/plug-ins/gimp_ace/gimp_ace.h +++ /dev/null @@ -1,14 +0,0 @@ -/* $Id$ */ - -#include "glace.h" - -typedef struct { - gdouble strength; - gdouble bradj; - gdouble coefftol; - gdouble smoothing; - guint iterations; - guint wsize; - Glace_ColorMethods color_method; - gboolean link; -} AceValues; diff --git a/plug-ins/gimp_ace/glace.c b/plug-ins/gimp_ace/glace.c deleted file mode 100644 index 4beaecb2ad..0000000000 --- a/plug-ins/gimp_ace/glace.c +++ /dev/null @@ -1,3079 +0,0 @@ -/* :PREAMBLE: Glace.c - * - * Wrapper-independent Code: - * For both PBMPLUS and Tk/Tcl-based versions - */ - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. See the file COPYING for details. - * - */ - -/* :HEADERS: - */ - -#include - -#include /* auto-generated by configure */ -#include "glaceInt.h" - -#include -#include /* FLT_MIN ??? */ -#include -#include - - -#ifdef GLACE_GIMP -#include "color.h" /* for vR vG vB -> y conversion, below. */ -#endif - -/* :*** Process Blocks ***: - - * :FUNCTION: Glace_Output - */ -#define YMAP_ADD (1.0) -int -Glace_Output ( - Glace_WData wData, - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr -) -{ - Glace_MidGray temp_gray, out_offset; - int r, c; - Glace_MidGray *agP; - /* register Glace_Pixel* opP;*/ - Glace_Gray *ogP, tmph, tmpl; - - /* COLOR_Yxy */ - Glace_Gray *xP, *yP; - - /* COLOR_LUMIN */ - Glace_Gray *rP, *gP, *bP; - - long temp_long; - int round_off; - register int gstep; - - /*float tmpz,tmpy;*/ - - /* We output row-by-row */ - Glace_WPutImgStart(wData,cfgInfoPtr,imgArraysPtr); - - /* 255 because that brings zero to the right (?) place and - 1 because that becomes 0.5, that is rounding by truncation. */ - if ((GLACE_CFG(chrome)==GLACE_CC) || (GLACE_CFG(doubleout)==GLACE_TRUE)) - round_off=0; - else - round_off=1; - - if (GLACE_CFG(outputMethod) == GLACE_NORMAL) - out_offset = (long) - ldexp(255 + round_off, - (ACC_BITS - OUT_BITS)); - /* out_offset = (long) - ldexp(255 - ((double) 255.0-2*GLACE_CFG(inoffsetVal)) - * GLACE_CFG(addbackFactor) + round_off, - (ACC_BITS - OUT_BITS));*/ - else - out_offset = (255 + round_off) << (ACC_BITS - OUT_BITS); - - /* tmpz= (float) ldexp((double)out_offset ,-(ACC_BITS - OUT_BITS + 1) ); - tmpy = (float) ldexp((double)1.0 ,-(ACC_BITS - OUT_BITS + 1) ); - */ - - - - agP = GLACE_IMG(outAccImgPtr); - for (r = 0; r < GLACE_IMG(rows); r++) - { - Glace_WPutImgRowStart(wData, cfgInfoPtr, imgArraysPtr, r); - - if ((GLACE_CFG(chrome) != GLACE_CC) - && (GLACE_CFG(doubleout)==GLACE_FALSE)) - if (GLACE_CFG(doClip)==GLACE_FALSE) - for ( gstep = GLACE_IMG(pixelBytePad), - c = GLACE_IMG(cols), ogP = GLACE_IMG(putImgRowPtr); - c >0 ; c--, ogP++, ogP +=gstep, agP++) - { - temp_gray = (*agP + out_offset) - >> (ACC_BITS - OUT_BITS + 1); - /*temp_gray = (Glace_MidGray) (((float) *agP)*tmpy +tmpz);*/ - *ogP = temp_gray > 255 ? 255 : temp_gray < 0 ? 0 : temp_gray; - } - else - for ( gstep = GLACE_IMG(pixelBytePad), - c = GLACE_IMG(cols), ogP = GLACE_IMG(putImgRowPtr); - c >0 ; c--, ogP++, ogP +=gstep, agP++) - { - temp_gray = (*agP + out_offset) - >> (ACC_BITS - OUT_BITS + 1); - /*temp_gray = (Glace_MidGray) (((float) *agP)*tmpy +tmpz);*/ - *ogP = temp_gray > 255 ? 255 : temp_gray < 0 ? 0 : 127; - } - else if (GLACE_CFG(doubleout)==GLACE_TRUE) - for ( gstep = 3+GLACE_IMG(pixelBytePad), - c = GLACE_IMG(cols), - ogP = GLACE_IMG(putImgRowPtr); - c >0 ; - c--, ogP+= gstep,++agP ) - { - temp_long = (*agP + out_offset) - << (8-(ACC_BITS - OUT_BITS + 1)); - temp_long = temp_long > 65535 ? 65535 : - temp_long < 0 ? 0 : temp_long; - BYTE_SPLIT(temp_long, tmph, tmpl); - GLACE_ASSIGN( - *((Glace_Pixel *)ogP), - tmph,tmph,tmpl); - } - else if (GLACE_CFG(colorMethod)==GLACE_COLOR_Yxy) { - for ( gstep = 3+GLACE_IMG(pixelBytePad), - c = GLACE_IMG(cols), - ogP = GLACE_IMG(putImgRowPtr), - xP = GLACE_IMG(inImgCxPtr) - + r * GLACE_IMG(cols) * GLACE_IMG(pixelSize), - yP = GLACE_IMG(inImgCyPtr) - + r * GLACE_IMG(cols) * GLACE_IMG(pixelSize); - c >0 ; - c--, ogP+=gstep, - xP+=GLACE_IMG(pixelSize), - yP+=GLACE_IMG(pixelSize), ++agP ) - - { - float x, y, X2, Y2, Z2, vR, vG, vB; - /* Note that x and y here range from 0 - 255 */ - x = *xP; - y = *yP; - - Y2 = (float) - ldexp((double)*agP + out_offset ,-(ACC_BITS - OUT_BITS + 1) ); - Y2 = CLAMP(Y2,0,255); - - /* Convert new XYZ coordinates to RGB. */ - /* This is what it looks like without Y2 factored out: - vR = CLAMP(R_x * X2 + R_y * Y2 + R_z * Z2, 0,255); */ - - /* Make new XYZ coordinates with new Y and same chromacity. */ - /* NOTE: These are not really X and Z coordinates! - They are missing a factor of Y2. - (Notice that Y2 is a factor of every term in the RGB - equations, so one may factor it out...) */ - X2 = (x / y); /* * Y2 */ - Z2 = ((255.0 - x - y) / y); /* * Y2 */ - - vR = CLAMP(Y2 * (R_x * X2 + R_y + R_z * Z2), 0,255); - vG = CLAMP(Y2 * (G_x * X2 + G_y + G_z * Z2), 0,255); - vB = CLAMP(Y2 * (B_x * X2 + B_y + B_z * Z2), 0,255); - - GLACE_ASSIGN( - *((Glace_Pixel *)ogP), - vR, vG, vB); - } - } /* endif COLOR_Yxy */ - else { /* COLOR_LUMIN */ - for ( gstep = 3+GLACE_IMG(pixelBytePad), - c = GLACE_IMG(cols), - ogP = GLACE_IMG(putImgRowPtr), - rP = GLACE_IMG(inImgRPtr) - + r * GLACE_IMG(cols) * GLACE_IMG(pixelSize), - gP = GLACE_IMG(inImgGPtr) - + r * GLACE_IMG(cols) * GLACE_IMG(pixelSize), - bP = GLACE_IMG(inImgBPtr) - + r * GLACE_IMG(cols) * GLACE_IMG(pixelSize); - c >0 ; - c--, ogP+=gstep, - rP+=GLACE_IMG(pixelSize), - gP+=GLACE_IMG(pixelSize), bP+=GLACE_IMG(pixelSize), ++agP ) - - { - float y1, y2, vR, vG, vB, lambda; - float alpha, beta; - const Glace_Gray mmaxval = GLACE_MAXMAXGRAY; - - y2 = (float) - ldexp((double)*agP + out_offset ,-(ACC_BITS - OUT_BITS + 1) ); - y2 = y2 > 255 ? 255 : y2 < 0 ? 0 : y2; - - vR = *rP; - vG = *gP; - vB = *bP; - - - /* y1 = 0.299*vR + 0.587*vG + 0.114*vB; */ - y1 = Y_r * vR + Y_g * vG + Y_b * vB; - - vR -= y1; - vG -= y1; - vB -= y1; - beta = max(max(vR, vG), vB); - alpha = abs(min(min(vR, vG), vB)); - - /* lambda = min( beta*(y1-1), alpha*(maxval-1-y1) )/(beta+0.001)/(alpha+0.001);*/ - - lambda = min( beta*y2, alpha*(mmaxval-y2) ) / - (YMAP_ADD+min( beta*y1, alpha*(mmaxval-y1) ) ); - - /* lambda = min( y2/alpha, (maxval-y2)/beta ) / - (YMAP_ADD+min( y1/alpha, (maxval-y1)/beta ) );*/ - - GLACE_ASSIGN( - *((Glace_Pixel *)ogP), - y2 + lambda* vR, - y2 + lambda* vG, - y2 + lambda* vB); - } /* next ogP */ - } /* endif COLOR_LUMIN */ - - Glace_WPutImgRowFinish(wData, cfgInfoPtr, imgArraysPtr, r); - } - - Glace_WPutImgFinish(wData, cfgInfoPtr, imgArraysPtr); - - return Glace_WErrorValue( GLACE_IMG(wData) ); -} - - - -/**************************************************************/ -/* - * :FUNCTION: GlaceBigGrayAccumulate - */ -void -GlaceBigGrayAccumulate( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - Glace_ImgArrays *imgArraysPtr -) -{ - register long r; - register Glace_MidGray *agP; - register Glace_Gray *hgP, *lgP; - register Glace_BigGray *bgP; - register long tmplong, tmpoffset; - -#if 0 - register Glace_Gray pixA, pixB; - - Glace_FillTableForNotFilt (cfgInfoPtr,tableInfoPtr); - - tmpoffset = 1 <<(GLACE_TRM(accShift)-1); - - for (r = GLACE_IMG(rows)*GLACE_IMG(cols)-2, - bgP = (Glace_BigGray *) GLACE_IMG(tmpImgPtr), - agP = (GLACE_IMG(accImgPtr)), - hgP = (GLACE_IMG(inImgHBPtr))+1, pixA = *(GLACE_IMG(inImgHBPtr)), - pixB=*((GLACE_IMG(inImgHBPtr))+1); r !=0; r--) - { - tmplong = GLACE_TRM(seriesTable)[pixA]; - tmplong *= (*bgP >> (BSHIFT)); - tmplong += tmpoffset; - - *agP += (Glace_MidGray) (tmplong >> GLACE_TRM(accShift) ); - - pixA = pixB; - pixB = *hgP; - bgP++; agP++; hgP++; - } - tmplong = GLACE_TRM(seriesTable)[pixA]; - tmplong *= (*bgP >> (BSHIFT)); - tmplong += tmpoffset; - - *agP += (Glace_MidGray) (tmplong >> GLACE_TRM(accShift) ); - -#elif 0 - - register Glace_Gray pixA; - - register int thisShift; - Glace_FillTableForNotFilt (cfgInfoPtr,tableInfoPtr); - - thisShift = GLACE_TRM(accShift); - - tmpoffset = 1 <<(GLACE_TRM(accShift)-1); - - /* About 1% better! */ - for (r = GLACE_IMG(rows)*GLACE_IMG(cols)-1, - bgP = (Glace_BigGray *) GLACE_IMG(tmpImgPtr), - agP = (GLACE_IMG(accImgPtr)), - hgP = (GLACE_IMG(inImgHBPtr))+1, pixA = *(GLACE_IMG(inImgHBPtr)); - r !=0; r--) - { - tmplong = GLACE_TRM(seriesTable)[pixA]; - tmplong *= (*bgP >> (BSHIFT)); - tmplong += tmpoffset; - - *agP += (Glace_MidGray) (tmplong >> (thisShift) ); - pixA = *hgP; - - bgP++; agP++; hgP++; - } - tmplong = GLACE_TRM(seriesTable)[pixA]; - tmplong *= (*bgP >> (BSHIFT)); - tmplong += tmpoffset; - - *agP += (Glace_MidGray) (tmplong >> (thisShift) ); -#elif 0 - - Glace_FillTableForNotFilt (cfgInfoPtr,tableInfoPtr); - - tmpoffset = 1 <<(GLACE_TRM(accShift)-1); - - Glace_MidGray *cgP, tmpMG, tmpMGZ; - for (r = GLACE_IMG(rows)*GLACE_IMG(cols)-1, - bgP = (Glace_BigGray *) GLACE_IMG(tmpImgPtr), - agP = (GLACE_IMG(accImgPtr)), cgP = (GLACE_IMG(accImgPtr))+1, - hgP = (GLACE_IMG(inImgHBPtr)), pixA = *(GLACE_IMG(inImgHBPtr)); - r !=0; r--) - { - - *agP = tmpMGZ; - - tmplong = GLACE_TRM(seriesTable)[pixA]; - tmplong *= (*bgP >> (BSHIFT)); - tmplong += tmpoffset; - tmpMG = (Glace_MidGray) (tmplong >> GLACE_TRM(accShift) ); - tmpMGZ = *cgP + tmpMG; - - pixA = *hgP; - bgP++; agP++; hgP++; cgP++; - } - - - - -#elif 0 - - float tmpa, tmpb, tmpc, tmplookup[256]; - - Glace_FillTableForNotFilt (cfgInfoPtr,tableInfoPtr); - - tmpb = (float) (1 >> (BSHIFT + GLACE_TRM(accShift) )); - tmpc = (float) 0.5; - - for (r=255, r>=0, r--) - tmplookup[r] = (float) GLACE_TRM(seriesTable)[r] * tmpb; - - for (r = GLACE_IMG(rows)*GLACE_IMG(cols), - bgP = (Glace_BigGray *) GLACE_IMG(tmpImgPtr), - agP = (GLACE_IMG(accImgPtr)), - hgP = (GLACE_IMG(inImgHBPtr)); r !=0; r--) - { - tmpa = tmplookup[*hgP]; - tmpa *= (float) *bgP; - tmpa += tmpc; - - *agP += (Glace_MidGray) (tmpa); - /* - *agP += (Glace_MidGray) - (GLACE_TRM(seriesTable)[*hgP] * (*bgP) *tmpflA); - */ - - bgP++; agP++; hgP++; - } - -#elif 0 - - Glace_FillTableForNotFilt (cfgInfoPtr,tableInfoPtr); - - tmpoffset = 1 <<(GLACE_TRM(accShift)-1); - - for (r = GLACE_IMG(rows)*GLACE_IMG(cols), - bgP = (Glace_BigGray *) GLACE_IMG(tmpImgPtr), - agP = (GLACE_IMG(accImgPtr)), - hgP = (GLACE_IMG(inImgHBPtr)); r !=0; r--) - { - tmplong = GLACE_TRM(seriesTable)[*hgP]; - tmplong *= (*bgP >> (BSHIFT)); - tmplong += tmpoffset; - - *agP += (Glace_MidGray) (tmplong >> GLACE_TRM(accShift) ); - /* - *agP += (Glace_MidGray) - (GLACE_TRM(seriesTable)[*hgP] * (*bgP) *tmpflA); - */ - - bgP++; agP++; hgP++; - } -#else - register int thisShift; - register long* thisTable; - register Glace_FpSeries *thisAH, *thisAL, *thisBH, *thisBL; - register float thisABF; - Glace_FillTableForNotFilt (cfgInfoPtr,tableInfoPtr); - - thisShift = GLACE_TRM(accShift); - tmpoffset = 1 <<(GLACE_TRM(accShift)-1); - - - if (GLACE_CFG(doublep)==GLACE_FALSE) - { - thisTable = GLACE_TRM(seriesTable); - for (r = GLACE_IMG(rows)*GLACE_IMG(cols), - bgP = (Glace_BigGray *) GLACE_IMG(tmpImgPtr), - agP = (GLACE_IMG(accImgPtr)), - hgP = (GLACE_IMG(inImgHBPtr)); r !=0; r--) - { - tmplong = thisTable[*hgP]; - tmplong *= (*bgP >> (BSHIFT)); - tmplong += tmpoffset; - - *agP += (Glace_MidGray) (tmplong >> thisShift ); - /* - *agP += (Glace_MidGray) - (GLACE_TRM(seriesTable)[*hgP] * (*bgP) *tmpflA); - */ - - bgP++; agP++; hgP++; - } - } - else - { - thisABF = GLACE_TRM(abFactor); - thisAH = GLACE_TRM(seriesAH); - thisAL = GLACE_TRM(seriesAL); - thisBH = GLACE_TRM(seriesBH); - thisBL = GLACE_TRM(seriesBL); - if (GLACE_TRM(termType) == GLACE_COS) - for (r = GLACE_IMG(rows)*GLACE_IMG(cols), - bgP = (Glace_BigGray *) GLACE_IMG(tmpImgPtr), - agP = (GLACE_IMG(accImgPtr)), - hgP = (GLACE_IMG(inImgHBPtr)), - lgP = (GLACE_IMG(inImgLBPtr)); r !=0; r--) - { -#if 1 - tmplong = thisAH[*hgP]*thisBL[*lgP] - - thisBH[*hgP]*thisAL[*lgP] + 0.5; - tmplong *= (*bgP >> (BSHIFT)); -#else - tmplong = (thisAH[*hgP]*thisBL[*lgP] - - thisBH[*hgP]*thisAL[*lgP]) - * ldexp(*bgP,- (BSHIFT)); -#endif - tmplong += tmpoffset; - - *agP += (Glace_MidGray) (tmplong >> thisShift ); - /* - *agP += (Glace_MidGray) - (GLACE_TRM(seriesTable)[*hgP] * (*bgP) *tmpflA); - */ - - bgP++; agP++; hgP++, lgP++; - } - else - for (r = GLACE_IMG(rows)*GLACE_IMG(cols), - bgP = (Glace_BigGray *) GLACE_IMG(tmpImgPtr), - agP = (GLACE_IMG(accImgPtr)), - hgP = (GLACE_IMG(inImgHBPtr)), - lgP = (GLACE_IMG(inImgLBPtr)); r !=0; r--) - { -#if 1 - tmplong = thisAH[*hgP]*thisBL[*lgP] - - thisBH[*hgP]*thisAL[*lgP] + 0.5 +thisABF; - tmplong *= (*bgP >> (BSHIFT)); -#else - tmplong = (thisAH[*hgP]*thisBL[*lgP] - - thisBH[*hgP]*thisAL[*lgP]) - * ldexp(*bgP,- (BSHIFT)); -#endif - tmplong += tmpoffset; - - *agP += (Glace_MidGray) (tmplong >> thisShift ); - /* - *agP += (Glace_MidGray) - (GLACE_TRM(seriesTable)[*hgP] * (*bgP) *tmpflA); - */ - - bgP++; agP++; hgP++, lgP++; - } - } - -#endif -} - - -/**************************************************************/ -/* - * :FUNCTION: GlaceMidGrayAccumulate - */ -void -GlaceMidGrayAccumulate( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - Glace_ImgArrays *imgArraysPtr -) -{ - long r; - register Glace_MidGray *agP; - register Glace_Gray *igP; - register Glace_MidGray *mgP; - register long tmplong, tmpoffset; - - Glace_FillTableForNotFilt (cfgInfoPtr,tableInfoPtr); - - tmpoffset = 1 <<(GLACE_TRM(accShift)-1); - - for (r = GLACE_IMG(rows)*GLACE_IMG(cols), - mgP = (Glace_MidGray *) GLACE_IMG(tmpImgPtr), - agP = (GLACE_IMG(accImgPtr)), - igP = (GLACE_IMG(inImgHBPtr)); r !=0; r--) - { - tmplong = GLACE_TRM(seriesTable)[*igP]; - tmplong *= (*mgP >> (MSHIFT)); - tmplong += tmpoffset; - - *agP += (Glace_MidGray) (tmplong >> GLACE_TRM(accShift) ); - - mgP++; agP++; igP++; - } -} - -/**************************************************************/ -/* - * :FUNCTION: Glace_CallFilt - */ -void -Glace_CallFilt ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - Glace_ImgArrays *imgArraysPtr) -{ - - if (GLACE_CFG(filtMethod) == GLACE_WINDOW) - if (GLACE_TRM(termType == GLACE_COS)) - Glace_FiltWind (cfgInfoPtr, - GLACE_IMG(refImgHBPtr), - GLACE_IMG(refImgLBPtr), - (Glace_BigGray *) GLACE_IMG(tmpImgPtr), - /*GLACE_TRM(filtTable),*/ - GLACE_IMG(cols), GLACE_IMG(rows), tableInfoPtr, - GLACE_CFG(windCWSeries[GLACE_TRM(termNum)]), - GLACE_CFG(windCHSeries[GLACE_TRM(termNum)])); - else - Glace_FiltWind (cfgInfoPtr, - GLACE_IMG(refImgHBPtr), - GLACE_IMG(refImgLBPtr), - (Glace_BigGray *) GLACE_IMG(tmpImgPtr), - /*GLACE_TRM(filtTable),*/ - GLACE_IMG(cols), GLACE_IMG(rows), tableInfoPtr, - GLACE_CFG(windSWSeries[GLACE_TRM(termNum)]), - GLACE_CFG(windSHSeries[GLACE_TRM(termNum)])); - else if (GLACE_CFG(filtMethod) == GLACE_DIRDIFF) - { - if (GLACE_TRM(termType == GLACE_COS)) - Glace_FiltDD (cfgInfoPtr, - GLACE_IMG(refImgHBPtr), - (Glace_MidGray *) GLACE_IMG(tmpImgPtr), - /*GLACE_TRM(filtTable),*/ - GLACE_IMG(cols), GLACE_IMG(rows), tableInfoPtr, - GLACE_IMG(ddHImgPtr), GLACE_IMG(ddVImgPtr), - GLACE_CFG(GLACE_CFG_COSDIM[GLACE_TRM(termNum)])); - else - Glace_FiltDD (cfgInfoPtr, - GLACE_IMG(refImgHBPtr), - (Glace_MidGray *) GLACE_IMG(tmpImgPtr), - /*GLACE_TRM(filtTable),*/ - GLACE_IMG(cols), GLACE_IMG(rows), tableInfoPtr, - GLACE_IMG(ddHImgPtr), GLACE_IMG(ddVImgPtr), - GLACE_CFG(GLACE_CFG_SINDIM[GLACE_TRM(termNum)])); - } - GLACE_ERROR_CHECK( GLACE_CFG(wData) ); -} - - -/**************************************************************/ -/* - * :FUNCTION: Glace_InitAccIm - */ -void -Glace_InitAccIm ( - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr) -{ - Glace_MidGray start_offset; - long r; - Glace_MidGray *agP; - Glace_Gray *hgP, *lgP; - float ptfac; - - if (GLACE_CFG(outputMethod) != GLACE_NORMAL) - return; - - start_offset = (long) - ldexp( - ((double) 255.0-2*GLACE_CFG(inoffsetVal)) - * (GLACE_CFG(addbackFactor)) - - 255.0*GLACE_CFG(passthruFactor), - (ACC_BITS - OUT_BITS)); - - ptfac = ldexp((double) 2*GLACE_CFG(passthruFactor), - (ACC_BITS - OUT_BITS-8)); - - if (GLACE_CFG(doublep) == GLACE_TRUE ) - for (r = GLACE_IMG(rows)*GLACE_IMG(cols), - agP = (GLACE_IMG(accImgPtr)), - hgP = (GLACE_IMG(inImgHBPtr)), - lgP = (GLACE_IMG(inImgLBPtr)); r !=0; r--) - { - *agP += start_offset + ptfac*(*hgP*256+*lgP); - agP++; lgP++; hgP++; - } - else - for (r = GLACE_IMG(rows)*GLACE_IMG(cols), - agP = (GLACE_IMG(accImgPtr)), - hgP = (GLACE_IMG(inImgHBPtr)); r !=0; r--) - { - *agP += start_offset + ptfac*(*hgP*256); - agP++; lgP++; hgP++; - } -} - - -/**************************************************************/ -/* - * :FUNCTION: Glace_GenGen - */ -void -Glace_GenGen ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - Glace_ImgArrays *imgArraysPtr) -{ - - if ((GLACE_TRM(accShift) GLACE_CFG(coeffTol)) - || (abs(GLACE_CFG(addbackSeries)[GLACE_TRM(termNum)]) - > GLACE_CFG(coeffTol)) )*/ - GLACE_TRM(termNum) <= GLACE_CFG(activeTerms) - ) - { - Glace_CallFilt ( cfgInfoPtr, tableInfoPtr, imgArraysPtr); - GLACE_ERROR_CHECK( GLACE_CFG(wData) ); - - if (GLACE_IMG(tmpImgGraySize) == sizeof(Glace_BigGray)) - GlaceBigGrayAccumulate(cfgInfoPtr, tableInfoPtr,imgArraysPtr); - else if (GLACE_CFG(filtMethod) == GLACE_DIRDIFF) - GlaceMidGrayAccumulate(cfgInfoPtr, tableInfoPtr,imgArraysPtr); - } -} - - - - -/**************************************************************/ - -/* :*** Image Array Allocation ***: - - * :FUNCTION: Glace_SetTmpImg - */ -void -Glace_SetTmpImg ( - Glace_ImgArrays *imgArraysPtr, - size_t graySize, - int rowPad, - int colPad - ) -{ - GLACE_IMG(tmpImgGraySize) = graySize; - GLACE_IMG(tmpImgRPad) = rowPad; - GLACE_IMG(tmpImgCPad) = colPad; -} - -/**************************************************************/ -/* - * :FUNCTION: Glace_DefaultTmpImg - */ -void -Glace_DefaultTmpImg ( - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr - ) -{ - if ((GLACE_CFG(outputMethod) == GLACE_SINRAW) || - (GLACE_CFG(outputMethod) == GLACE_COSRAW) || - (GLACE_CFG(filtMethod) == GLACE_DIRDIFF)) - Glace_SetTmpImg(imgArraysPtr, sizeof (Glace_MidGray), 1, 0); - else - Glace_SetTmpImg(imgArraysPtr, sizeof (Glace_BigGray), 1, 1); -} - -/**************************************************************/ -/* - * :FUNCTION: Glace_AllocImgArrays - */ -void -Glace_AllocImgArrays ( - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr - ) -{ - long newTmpImgSize; - char *tmpPtr; - float minBound; - - if ((GLACE_CFG(outputMethod) == GLACE_NORMAL) && - (GLACE_CFG(plainGlace) == GLACE_TRUE)) - { - GLACE_IMG(accImgPtr) = (Glace_MidGray *) - Glace_CallocReallocFree( GLACE_IMG(accImgPtr), &GLACE_IMG(accImgSize), - GLACE_IMG(cols) * GLACE_IMG(rows), - sizeof (Glace_MidGray), 0.9); - memset (GLACE_IMG(accImgPtr), '\0', - GLACE_IMG(cols) * GLACE_IMG(rows) * sizeof (Glace_MidGray)); - } - - /* Get the old pointer in case we need to reassign or free */ - tmpPtr = GLACE_IMG(tmpImgPtr); - - - newTmpImgSize = (GLACE_IMG(cols) + GLACE_IMG(tmpImgCPad)) * - (GLACE_IMG(rows) + GLACE_IMG(tmpImgRPad)) * - GLACE_IMG(tmpImgGraySize); - - /* We allow a certain slack if the new image is slightly smaller - * than the old one. Also, we allow greater shrinkage if the image - * is diagnostic, since the user will probably go back to the larger - * one later anyway. Hence a base gray size of 4 bytes is assumed. - */ - if (GLACE_IMG(tmpImgGraySize) < sizeof(Glace_BigGray)) - minBound = 0.9 * - ((float) GLACE_IMG(tmpImgGraySize)) / sizeof(Glace_BigGray); - else - minBound = 0.9; - - tmpPtr = (char *) - Glace_CallocReallocFree( tmpPtr, &GLACE_IMG(tmpImgSize), newTmpImgSize, - 1, minBound); - - -/* (Glace_BigGray *) GLACE_IMG(tmpImgPtr) = (Glace_BigGray *) tmpPtr; */ -/* (Glace_MidGray *) GLACE_IMG(tmpImgPtr) = (Glace_MidGray *) tmpPtr; */ - /* - if (GLACE_IMG(tmpImgGraySize) == GLACE_TMP_IMG_BIG) - { - (Glace_BigGray *) GLACE_IMG(tmpImgPtr) = (Glace_BigGray *) tmpPtr; - (Glace_MidGray *) GLACE_IMG(tmpImgPtr) = NULL; - } - else - { - (Glace_MidGray *) GLACE_IMG(tmpImgPtr) = (Glace_MidGray *) tmpPtr; - (Glace_BigGray *) GLACE_IMG(tmpImgPtr) = NULL; - } - */ - GLACE_IMG(tmpImgPtr) = tmpPtr; - - /* Assign the pointer to the accumulator used for output */ - if (GLACE_CFG(outputMethod) == GLACE_NORMAL) - GLACE_IMG(outAccImgPtr) = GLACE_IMG(accImgPtr); - else - GLACE_IMG(outAccImgPtr) = (Glace_MidGray *) tmpPtr; - -} - -/**************************************************************/ -/* - * :FUNCTION: Glace_FreeImgArrays - */ -void -Glace_FreeImgArrays ( - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr - ) -{ - if (GLACE_CFG(outputMethod) == GLACE_NORMAL) - Glace_CallocReallocFree( GLACE_IMG(accImgPtr), &GLACE_IMG(accImgSize), - 0, - sizeof (Glace_MidGray), 0.9); - - Glace_CallocReallocFree( GLACE_IMG(tmpImgPtr), - &GLACE_IMG(tmpImgSize), 0, 1, 0.9); - - -} - -/**************************************************************/ -/* - * :FUNCTION: Glace_AllocInputImgArrays - */ -void -Glace_AllocInputImgArrays ( - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr - ) -{ - int bytesper; - - if (GLACE_CFG(doublep)==GLACE_FALSE) - bytesper = 1; - else - bytesper = 2; - - if (GLACE_CFG(refimageMode) == GLACE_SEPARATE) - GLACE_IMG(refImgPtr) = (Glace_Gray *) - Glace_CallocReallocFree( GLACE_IMG(refImgPtr), &GLACE_IMG(refImgSize), - GLACE_IMG(rows)*GLACE_IMG(cols)*bytesper, - sizeof(Glace_Gray), 0.9); - else - GLACE_IMG(refImgPtr) = (Glace_Gray *) - Glace_CallocReallocFree( GLACE_IMG(refImgPtr), &GLACE_IMG(refImgSize), - 0, - sizeof(Glace_Gray), 0.9); - GLACE_IMG(inImgPtr) = (Glace_Gray *) - Glace_CallocReallocFree( GLACE_IMG(inImgPtr), &GLACE_IMG(inImgSize), - GLACE_IMG(rows)*GLACE_IMG(cols)*bytesper, - sizeof(Glace_Gray), 0.9); -} - - -/**************************************************************/ -/* - * :FUNCTION: Glace_FreeInputImgArrays - */ -void -Glace_FreeInputImgArrays ( - Glace_ImgArrays *imgArraysPtr - ) -{ - if (GLACE_IMG(refImgHBPtr) != GLACE_IMG(inImgHBPtr)) - GLACE_IMG(refImgHBPtr) = (Glace_Gray *) - Glace_CallocReallocFree( GLACE_IMG(refImgHBPtr), &GLACE_IMG(refImgSize), - 0, - sizeof(Glace_Gray), 0.9); - GLACE_IMG(inImgHBPtr) = (Glace_Gray *) - Glace_CallocReallocFree( GLACE_IMG(inImgHBPtr), &GLACE_IMG(inImgSize), - 0, - sizeof(Glace_Gray), 0.9); - -} - - -/**************************************************************/ - -/**************************************************************/ - -/* :*** General Memory Allocation ***: - - * :FUNCTION: Glace_AllocClientData - */ -Glace_ClientData * -Glace_AllocClientData () -{ - Glace_ClientData *clientData; - - clientData = (Glace_ClientData *) GlaceWMalloc(sizeof(Glace_ClientData)); - - GLACE_CDATA(wData) = Glace_WDataAlloc(); - GLACE_CDATA(cfgInfoPtr) = (Glace_CfgInfo *) - GlaceWMalloc(sizeof(Glace_CfgInfo)); - GLACE_CDATA(tableInfoPtr) = (Glace_TableInfo *) - GlaceWMalloc(sizeof(Glace_TableInfo)); - GLACE_CDATA(imgArraysPtr) = (Glace_ImgArrays *) - GlaceWMalloc(sizeof(Glace_ImgArrays)); - - memset(GLACE_CDATA(cfgInfoPtr), '\0',sizeof(Glace_CfgInfo)); - memset(GLACE_CDATA(tableInfoPtr), '\0',sizeof(Glace_TableInfo)); - memset(GLACE_CDATA(imgArraysPtr), '\0',sizeof(Glace_ImgArrays)); - - (GLACE_CDATA(cfgInfoPtr))->wData = - (GLACE_CDATA(tableInfoPtr))->wData = - (GLACE_CDATA(imgArraysPtr))->wData = GLACE_CDATA(wData); - - return clientData; -} - -/**************************************************************/ -/* - * :FUNCTION: Glace_FreeClientData - */ -void -Glace_FreeClientData ( - Glace_ClientData *clientData - ) -{ - GlaceWFree(GLACE_CDATA(wData)); - GlaceWFree(GLACE_CDATA(cfgInfoPtr)); - GlaceWFree(GLACE_CDATA(tableInfoPtr)); - GlaceWFree(GLACE_CDATA(imgArraysPtr)); - GlaceWFree(clientData); -} - - -/**************************************************************/ -/* - * :FUNCTION: Glace_CallocReallocFree - */ -char * -Glace_CallocReallocFree( - void *p, - long *nObjPtr, - long newNObj, - size_t size, - float minBound -) -{ - char *tmpPtr=NULL; - - if ( ((newNObj*((long) size))>*nObjPtr ) - || ((newNObj*size)<(*nObjPtr*minBound)) - || ((newNObj*size)==0) ) - { - if (*nObjPtr != 0) - if ((newNObj*size)==0) - GlaceWFree(p); - else { - /* tmpPtr = (char *) GlaceWRealloc (p, newNObj*size);*/ - GlaceWFree(p); - tmpPtr = (char *) GlaceWMalloc (newNObj*size); - } - else - if ((newNObj*size)!=0) - tmpPtr = (char *) GlaceWMalloc (newNObj*size); - - *nObjPtr = (newNObj*size); - } - else - tmpPtr = (char *) p; - - return tmpPtr; -} - - -/**************************************************************/ - -/* :*** Lookup Table and Term-Wise Stuff ***: - - * :FUNCTION: Glace_AllocTables - */ -void -Glace_AllocTables ( - GLACE_OVAR(Glace_CfgInfo *cfgInfoPtr), - Glace_TableInfo *tableInfoPtr - ) -{ - if (GLACE_CFG(doublep)==GLACE_FALSE) - { - if (GLACE_TRM(seriesTable) == NULL) - GLACE_TRM(seriesTable) = - (long * ) GlaceWCalloc(GLACE_MAXMAXGRAY + 1 , sizeof( long ) ); - } - else if (GLACE_TRM(seriesAH) == NULL) - { - GLACE_TRM(seriesAH) = - (Glace_FpSeries *) GlaceWCalloc( (GLACE_MAXMAXGRAY +1)*4 , - sizeof( Glace_FpSeries ) ); - GLACE_TRM(seriesAL) = GLACE_TRM(seriesAH) +GLACE_MAXMAXGRAY + 1; - GLACE_TRM(seriesBH) = GLACE_TRM(seriesAL) +GLACE_MAXMAXGRAY + 1; - GLACE_TRM(seriesBL) = GLACE_TRM(seriesBH) +GLACE_MAXMAXGRAY + 1; - } -} - -/**************************************************************/ -/* - * :FUNCTION: Glace_FreeTables - */ -void -Glace_FreeTables ( - GLACE_OVAR(Glace_CfgInfo *cfgInfoPtr), - Glace_TableInfo *tableInfoPtr - ) -{ - GlaceWFree(GLACE_TRM(seriesTable)); - GlaceWFree(GLACE_TRM(seriesAH)); -} - -/* - * :FUNCTION: Glace_SetForTerm - */ -void -Glace_SetForTerm ( - Glace_TableInfo *tableInfoPtr, - int k, - Glace_TermTypes type - ) -{ - GLACE_TRM(termNum) = k; - GLACE_TRM(termType) = type; -} - -/**************************************************************/ -/* - * :FUNCTION: Glace_SetTables - */ -void -Glace_SetTables ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr -) -{ - float area; - int filtShifts, notFiltShifts, abShifts; - float filtFactor, notFiltFactor, abFactor; - /* int r;*/ - - double waveFactor; - - /* Set the table tableInfoPtr so that, after filtering (or without - * filtering) the resulting field will have max magnitude - * AFTFILTVAL. If DIRDIFF is used, this will be shifted down to - * sit in a two-byte integer instead. - * - * The filter must shift the values down by filtShifts as part - * of its processing. */ - if ((GLACE_CFG(outputMethod) == GLACE_SINRAW) || - (GLACE_CFG(outputMethod) == GLACE_COSRAW) || - (GLACE_CFG(filtMethod) == GLACE_DIRDIFF)) - { - filtFactor = MAFT_FILTVAL; - filtShifts = 0; - /* We aim to produce a result in the accumulator field - * between -255 and +255. - * - * Hence, to get the `notfilt' tableInfoPtr - * required to multiply AFTFILTVAL - * by to get 255*heseries[k], we proceed as follows: - */ - notFiltFactor = frexp (((double) - GLACE_CFG(heseriesSeries[GLACE_TRM(termNum)])) - * 255.0 / MAFT_FILTVAL / NOT_FILTVAL, - ¬FiltShifts) * NOT_FILTVAL; - abFactor = frexp (((double) GLACE_CFG(addbackSeries[GLACE_TRM(termNum)])) - * 255.0 / MAFT_FILTVAL / NOT_FILTVAL, - &abShifts) * NOT_FILTVAL; - } - else - { - if (GLACE_TRM(termType) == GLACE_COS) - area = (2.0 * GLACE_CFG(windCWSeries[GLACE_TRM(termNum)]) + 1) - * (2 * GLACE_CFG(windCHSeries[GLACE_TRM(termNum)]) + 1); - else - area = (2.0 * GLACE_CFG(windSWSeries[GLACE_TRM(termNum)]) + 1) - * (2 * GLACE_CFG(windSHSeries[GLACE_TRM(termNum)]) + 1); - - filtFactor = frexp (1.0 / area, &filtShifts) * AFT_FILTVAL; - filtShifts = -filtShifts; - notFiltFactor = frexp (((double) - GLACE_CFG(heseriesSeries[GLACE_TRM(termNum)])) - * 255.0 / AFT_FILTVAL / NOT_FILTVAL +FLT_MIN, - ¬FiltShifts) * NOT_FILTVAL; - abFactor = frexp (((double) GLACE_CFG(addbackSeries[GLACE_TRM(termNum)])) - * 255.0 / AFT_FILTVAL / NOT_FILTVAL +FLT_MIN, - &abShifts) * NOT_FILTVAL; - } - - /* - * The tableInfoPtr of 2 means that the effect of the addback does not - * overflow. -2<= ( cos(...)-addback ) <=1 - * - * The idea of this is that the unfiltered (co)sine table is - * already in the right place, and that the range of the filtered - * field will occupy BIG_TMP_BITS bits for max postive number. - * - * Note that the notFiltShifts is the number of left shifts - * to generate a result in the range -255 to +255. - */ - - /* - * NO NEED IF WE ADD FLT_MIN ABOVE * - if (notFiltFactor==0.0) - { - notFiltFactor=1.0; - notFiltShifts = (FORCE_NO_BIT_SHIFT); - } - if (abFactor==0.0) - { - abFactor=1.0; - abShifts = (FORCE_NO_BIT_SHIFT); - } - */ - - /* GLACE_MAXMAXGRAY is prescale/2 of a half-wave - * (Fourier series truncation). */ - waveFactor = (2 * GLACE_TRM(termNum) - 1) * GLACE_PI / GLACE_MAXMAXGRAY - * GLACE_CFG(prescaleVal) / 2; - - if (GLACE_TRM(termType) == GLACE_SIN) - { - if (abShifts < notFiltShifts) - abFactor = ldexp(abFactor,abShifts-notFiltShifts); - else - { - notFiltFactor = ldexp(notFiltFactor,notFiltShifts-abShifts); - notFiltShifts = abShifts; - } - } - - /* - if (GLACE_TRM(termType) == GLACE_COS) - for (r = 0; r <= GLACE_MAXMAXGRAY; r++) - { - GLACE_TRM(filtTable)[r] = filtFactor - * cos ((r - GLACE_CFG(inoffsetVal)) * waveFactor); - GLACE_TRM(notFiltTable)[r] = notFiltFactor - * sin ((r - GLACE_CFG(inoffsetVal)) * waveFactor); - } - else - for (r = 0; r <= GLACE_MAXMAXGRAY; r++) - { - GLACE_TRM(filtTable)[r] = filtFactor - * sin ((r - GLACE_CFG(inoffsetVal)) * waveFactor); - GLACE_TRM(notFiltTable)[r] = -1*((long) (notFiltFactor - * (cos ((r - GLACE_CFG(inoffsetVal)) * waveFactor)) - - abFactor)); - } - */ - - if ((GLACE_CFG(outputMethod) == GLACE_SINRAW) || - (GLACE_CFG(outputMethod) == GLACE_COSRAW) || - (GLACE_CFG(filtMethod) == GLACE_DIRDIFF)) - GLACE_TRM(accShift) = (-notFiltShifts - MSHIFT + OUT_BITS - ACC_BITS); - else - GLACE_TRM(accShift) = (-notFiltShifts - BSHIFT + OUT_BITS - ACC_BITS); - - GLACE_TRM(filtFactor) = filtFactor; - GLACE_TRM(filtShifts) = filtShifts; - GLACE_TRM(notFiltFactor) = notFiltFactor; - GLACE_TRM(notFiltShifts) = notFiltShifts; - GLACE_TRM(abFactor) = abFactor; - GLACE_TRM(abShifts) = abShifts; - GLACE_TRM(waveFactor) = waveFactor; -} - - -/**************************************************************/ -/* - * :FUNCTION: Glace_FillTableForFilt - */ -void -Glace_FillTableForFilt ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - float scale - ) -{ - int r; - float sfac; - - sfac = scale * GLACE_TRM(filtFactor); - - if (GLACE_CFG(doublep)==GLACE_FALSE) - if (GLACE_TRM(termType) == GLACE_COS) - for (r = 0; r <= GLACE_MAXMAXGRAY; r++) - { - GLACE_TRM(seriesTable)[r] = 0.5+sfac - * cos ((r - GLACE_CFG(inoffsetVal)) * GLACE_TRM(waveFactor)); - } - else - for (r = 0; r <= GLACE_MAXMAXGRAY; r++) - { - GLACE_TRM(seriesTable)[r] = 0.5+sfac - * sin ((r - GLACE_CFG(inoffsetVal)) * GLACE_TRM(waveFactor)); - } - else - if (GLACE_TRM(termType) == GLACE_COS) - for (r = 0; r <= GLACE_MAXMAXGRAY; r++) - { - GLACE_TRM(seriesAH)[r] = sfac - * cos ((r - GLACE_CFG(inoffsetVal)) * GLACE_TRM(waveFactor)); - GLACE_TRM(seriesBH)[r] = -sfac - * sin ((r - GLACE_CFG(inoffsetVal)) * GLACE_TRM(waveFactor)); - GLACE_TRM(seriesAL)[r] = - cos (r * GLACE_TRM(waveFactor)/256); - GLACE_TRM(seriesBL)[r] = - sin (r * GLACE_TRM(waveFactor)/256); - } - else - for (r = 0; r <= GLACE_MAXMAXGRAY; r++) - { - GLACE_TRM(seriesAH)[r] = sfac - * sin ((r - GLACE_CFG(inoffsetVal)) * GLACE_TRM(waveFactor)); - GLACE_TRM(seriesBH)[r] = sfac - * cos ((r - GLACE_CFG(inoffsetVal)) * GLACE_TRM(waveFactor)); - GLACE_TRM(seriesAL)[r] = - cos (r * GLACE_TRM(waveFactor)/256); - GLACE_TRM(seriesBL)[r] = - sin (r * GLACE_TRM(waveFactor)/256); - } -} - - -/**************************************************************/ -/* - * :FUNCTION: Glace_FillTableForNotFilt - - */ -void -Glace_FillTableForNotFilt ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr - ) -{ - int r; - float sfac; - - sfac = GLACE_TRM(notFiltFactor); - - if (GLACE_CFG(doublep)==GLACE_FALSE) - if (GLACE_TRM(termType) == GLACE_COS) - for (r = 0; r <= GLACE_MAXMAXGRAY; r++) - { - GLACE_TRM(seriesTable)[r] = 0.5+sfac - * sin ((r - GLACE_CFG(inoffsetVal)) * GLACE_TRM(waveFactor)); - } - else - for (r = 0; r <= GLACE_MAXMAXGRAY; r++) - { - GLACE_TRM(seriesTable)[r] = 0.5+-1*((double) (sfac - * (cos ((r - GLACE_CFG(inoffsetVal)) * GLACE_TRM(waveFactor))) - - GLACE_TRM(abFactor) )); - } - else - if (GLACE_TRM(termType) == GLACE_COS) - for (r = 0; r <= GLACE_MAXMAXGRAY; r++) - { - GLACE_TRM(seriesAH)[r] = sfac - * cos ((r - GLACE_CFG(inoffsetVal)) * GLACE_TRM(waveFactor)); - GLACE_TRM(seriesBH)[r] = -sfac - * sin ((r - GLACE_CFG(inoffsetVal)) * GLACE_TRM(waveFactor)); - } - else - for (r = 0; r <= GLACE_MAXMAXGRAY; r++) - { - GLACE_TRM(seriesAH)[r] = sfac - * sin ((r - GLACE_CFG(inoffsetVal)) * GLACE_TRM(waveFactor)); - GLACE_TRM(seriesBH)[r] = sfac - * cos ((r - GLACE_CFG(inoffsetVal)) * GLACE_TRM(waveFactor)); - } -} - - - - - - -/**************************************************************/ -/* Output accImgPtr */ - -/* :*** Overall Process ***: - - * :FUNCTION: Glace_WindChk - */ -void -Glace_WindChk ( - Glace_CfgInfo *cfgInfoPtr, - int rows, int cols -) -{ - unsigned int k; - char message[MAX_MESSAGE_LEN]; - int r; - - if (GLACE_CFG(filtMethod) == GLACE_WINDOW) - for (k = GLACE_CFG(firstTerm); k <= (unsigned) GLACE_CFG(numTerms); k++) - { - r = 1; - if ((signed) (2 * GLACE_CFG(windSWSeries[k])) >= cols) - sprintf (message, "Sine window width (%3d:%5d) " - "too large for image.", k, - GLACE_CFG(windSWSeries[k])); - else if ((signed) (2 * GLACE_CFG(windCHSeries[k])) >= rows) - sprintf (message, "Cosine window height (%3d:%5d) " - "too large for image.", k, - GLACE_CFG(windCHSeries[k])); - else if ((signed) (2 * GLACE_CFG(windSHSeries[k])) >= cols) - sprintf (message, "Sine window height (%3d:%5d) " - "too large for image.", k, - GLACE_CFG(windSHSeries[k])); - else if ((signed) (2 * GLACE_CFG(windCWSeries[k])) >= rows) - sprintf (message, "Cosine window width (%3d:%5d) " - "too large for image.", k, - GLACE_CFG(windCWSeries[k])); - else if ((signed) (2 * GLACE_CFG(windSWSeries[k])) < 3) - sprintf (message, "Sine window width (%3d:%5d) " - "too small.", k, GLACE_CFG(windSWSeries[k])); - else if ((signed) (2 * GLACE_CFG(windCHSeries[k])) < 3) - sprintf (message, "Cosine window height (%3d:%5d) " - "too small.", k, GLACE_CFG(windCHSeries[k])); - else if ((signed) (2 * GLACE_CFG(windSHSeries[k])) < 3) - sprintf (message, "Sine window height (%3d:%5d) " - "too small.", k, GLACE_CFG(windSHSeries[k])); - else if ((signed) (2 * GLACE_CFG(windCWSeries[k])) < 3) - sprintf (message, "Cosine window width (%3d:%5d) " - "too small.", k, GLACE_CFG(windCWSeries[k])); - else - r = 0; - if (r) - { - Glace_WError( GLACE_CFG(wData),message); - return; - } - } -} - - -/**************************************************************/ -/* - * :FUNCTION: Glace_TermlyReport - */ -void -Glace_TermlyReport ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr -) -{ - char message[MAX_MESSAGE_LEN]; - - if (GLACE_CFG(verbose)) - { - if (GLACE_CFG(filtMethod) == GLACE_WINDOW) - sprintf (message, "%5u: %5d %5d %5d %5d %12.6g %12.6g", - GLACE_TRM(termNum), - GLACE_CFG(windCWSeries[GLACE_TRM(termNum)]), - GLACE_CFG(windCHSeries[GLACE_TRM(termNum)]), - GLACE_CFG(windSWSeries[GLACE_TRM(termNum)]), - GLACE_CFG(windSHSeries[GLACE_TRM(termNum)]), - GLACE_CFG(heseriesSeries[GLACE_TRM(termNum)]), - GLACE_CFG(addbackSeries[GLACE_TRM(termNum)])); - else - sprintf - (message, - "%5u: %5d %5d %12.6g %12.6g", - GLACE_TRM(termNum), - GLACE_CFG(GLACE_CFG_COSDIM[GLACE_TRM(termNum)]), - GLACE_CFG(GLACE_CFG_SINDIM[GLACE_TRM(termNum)]), - GLACE_CFG(heseriesSeries[GLACE_TRM(termNum)]), - GLACE_CFG(addbackSeries[GLACE_TRM(termNum)])); - Glace_WMessage( GLACE_CFG(wData), message ); - } -} - - -/**************************************************************/ -/* - * :FUNCTION: Glace_DiagGen - */ -void -Glace_DiagGen ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - Glace_ImgArrays *imgArraysPtr -) -{ - long r; - Glace_Gray *hgP, *lgP; - Glace_MidGray *mgP, *ogP; - Glace_BigGray *bgP; - register Glace_FpSeries *thisAH, *thisAL, *thisBH, *thisBL; - - if ((GLACE_CFG(outputMethod) == GLACE_COSFILT) - || (GLACE_CFG(outputMethod) == GLACE_COSRAW)) - Glace_SetForTerm(tableInfoPtr, GLACE_CFG(numTerms), GLACE_COS); - else - Glace_SetForTerm(tableInfoPtr, GLACE_CFG(numTerms), GLACE_SIN); - - Glace_TermlyReport( cfgInfoPtr, tableInfoPtr); - - Glace_SetTables (cfgInfoPtr, tableInfoPtr); - - - if ((GLACE_CFG(outputMethod) == GLACE_COSFILT) - || (GLACE_CFG(outputMethod) == GLACE_SINFILT)) - { - Glace_FillTableForFilt (cfgInfoPtr,tableInfoPtr,1.0); - Glace_CallFilt ( cfgInfoPtr, tableInfoPtr, imgArraysPtr); - } - - else if ((GLACE_CFG(outputMethod) == GLACE_SINRAW) - || (GLACE_CFG(outputMethod) == GLACE_COSRAW)) - { - Glace_FillTableForFilt (cfgInfoPtr,tableInfoPtr,1.0); - - if (GLACE_CFG(doublep) ==GLACE_FALSE) - for (r = 0, hgP = GLACE_IMG(refImgHBPtr), - mgP = (Glace_MidGray *) GLACE_IMG(tmpImgPtr); - r < GLACE_IMG(rows)*GLACE_IMG(cols); r++, mgP++, hgP++) - *mgP = GLACE_TRM(seriesTable)[*hgP]; - else - { - thisAH = GLACE_TRM(seriesAH); - thisAL = GLACE_TRM(seriesAL); - thisBH = GLACE_TRM(seriesBH); - thisBL = GLACE_TRM(seriesBL); - - for (r = 0, hgP = GLACE_IMG(refImgHBPtr), - lgP = GLACE_IMG(refImgLBPtr), - mgP = (Glace_MidGray *) GLACE_IMG(tmpImgPtr); - r < GLACE_IMG(rows)*GLACE_IMG(cols); r++, mgP++, hgP++, lgP++) - *mgP = thisAH[*hgP]*thisAL[*lgP] + - thisBH[*hgP]*thisBL[*lgP] +0.5; - } - } - - - - if (GLACE_IMG(tmpImgGraySize) == sizeof(Glace_BigGray)) - for (r = 0, bgP = (Glace_BigGray *) GLACE_IMG(tmpImgPtr), - ogP = GLACE_IMG(outAccImgPtr); - r < GLACE_IMG(rows)*GLACE_IMG(cols); r++, bgP++, ogP++) - *ogP = (*bgP) >> (BIG_TMP_BITS - ACC_BITS); - else - for (r = 0, mgP = (Glace_MidGray *) GLACE_IMG(tmpImgPtr), - ogP = GLACE_IMG(outAccImgPtr); - r < GLACE_IMG(rows)*GLACE_IMG(cols); r++, mgP++, ogP++) - *ogP = (*mgP) >> (MID_TMP_BITS - ACC_BITS); - - if (GLACE_CFG(verbose)) - Glace_WMessage( GLACE_CFG(wData), ";\n" ); -} - - -/**************************************************************/ - -/**************************************************************/ -/* - * :FUNCTION: Glace_Process - */ -void -Glace_Process ( - Glace_WData wData, - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - Glace_ImgArrays *imgArraysPtr -) -{ - unsigned int k; - - Glace_WindChk (cfgInfoPtr, GLACE_IMG(cols), GLACE_IMG(rows)); - GLACE_ERROR_CHECK( GLACE_CFG(wData) ); - - Glace_InitAccIm (cfgInfoPtr, imgArraysPtr); - - if (GLACE_CFG(outputMethod) == GLACE_NORMAL) - for (k = GLACE_CFG(firstTerm); k <= (unsigned) GLACE_CFG(numTerms); k++) - { - - Glace_SetForTerm(tableInfoPtr, k, GLACE_COS); - Glace_TermlyReport( cfgInfoPtr, tableInfoPtr); - - Glace_SetTables (cfgInfoPtr, tableInfoPtr); - Glace_GenGen ( cfgInfoPtr, tableInfoPtr, imgArraysPtr); - GLACE_ERROR_CHECK( GLACE_CFG(wData) ); - - Glace_SetForTerm(tableInfoPtr, k, GLACE_SIN); - - Glace_SetTables (cfgInfoPtr, tableInfoPtr); - Glace_GenGen ( cfgInfoPtr, tableInfoPtr, imgArraysPtr); - GLACE_ERROR_CHECK( GLACE_CFG(wData) ); - - if (GLACE_CFG(verbose)) - Glace_WMessage( GLACE_CFG(wData), ";\n" ); - } - else - Glace_DiagGen (cfgInfoPtr, tableInfoPtr, imgArraysPtr); - GLACE_ERROR_CHECK( GLACE_CFG(wData) ); - Glace_Output (wData, cfgInfoPtr, imgArraysPtr ); -} - - -/*************************************************************/ - - -/* :*** Argument Parsing ***: - - * :FUNCTION: GlaceArgError - */ -int -GlaceArgError ( - Glace_WData wData, - const char *message, - char *argv[], - int numArgs, - int problemArg - ) - -{ - char argErrStr[GLACE_STRMAX+201]; - char *sp; - int spaceleft; - int k; - - sp = &argErrStr[0]; - - strncpy( sp, message, 100 ); - sp += strlen(sp); - - sprintf( sp, "\nargument number: %u\n\t\"", problemArg ); - sp += strlen(sp); - for (k=0, spaceleft=GLACE_STRMAX; - (k0); - k++) - { - strncpy( sp, argv[problemArg+k], spaceleft ); - - spaceleft -= strlen(sp); - sp += strlen(sp); - *sp++ = ' '; - } - sprintf( --sp, "\"" ); - - return Glace_WError( wData,argErrStr); -} - - -/**************************************************************/ -/* - * :FUNCTION: Glace_ParseArgs - */ -int -Glace_ParseArgs ( - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr, - int argc, - char *argv[]) -{ - - int argn; - - char *usage = "OPTIONS [pgmfile]\n" - "\t-reset (reset configuration: use first\n" - "\t\twhen calling as a library. Ignore on command line)\n" - "\t\tMandatory arguments:\n" - "\t <# terms> | ...\n" - "\t-windlistfile | ...\n" - "\t <# terms> -ddimages | ...\n" - "\t-ddimages -ddlistfile | ...\n" - "\t\tOptions:\n" - "\t-factor | -seriesfile \n" - "\t-doublep * double precision\n" - "\t-cc | -cg | -gg | -cgd | -ggd\n" - "\t\t* inputletter-outputletter pair (colour/gray)\n" - "\t\t -gg[d] and -doublep: split input r-ignore, g-high, b-low\n" - "\t\t d-suffix for double-precision output (split rgb/ppm)\n" - /* "\t\tppm input, -gg or -gc , w/o -doublep: read as pgm\n"*/ - "\t\t -cc is overidden to -cg for diagnostic output\n" - "\t\t -cc and -cg are overidden with pgm input\n" - "\t-cosraw | -cosfilt | -sinraw | -sinfilt | -clip\n" - "\t-quiet | -verbose\n" - "\t-hamming\n" - "\t-prescale

\n" - "\t-zaddback | -laddback \n" - "\t-passthru \n" - "\t-onlyheseries * coefficient windowing\n" - "\t-tolerance * -1 disables\n" - "\t-inoffset \n" - "\t-gauss \n" - "\t-refimage \n" - "\t-cumulation * c-function\n" - "Options may come in any sensible order: valueless ones like" - "-verbose must\nnot come last. " - "They may be abbreviated.\n" - "\t** Base values are ignored in dd filtering.\n"; - /* Remaining letters: bejkmnuxy */ - - /* Indicators to check if option already scanned. - These contain the index into argv of the relevant argument. */ - int vprescale=0, vaddback=0, vinoffset=0, vwlistfile=0, vdimensions=0, - vseriesfile=0, vfactor=0, vddimages=0, vddlistfile=0, vtype=0, vtol=0, - vrefimage=0, vgauss=0, vcfunc=0, vinput=0, voutput=0, vpassthru=0; - /* The following are just overruled by a later argument: - * sinraw, sinfilt, cosraw, cosfilt, verbose, quiet. - * hamming cannot be turned off later. - */ - int last_arg; - - - argn = 1; - - if (argc<=1) - { - Glace_WUsage (GLACE_CFG(wData), usage); - return Glace_WErrorValue( GLACE_CFG(wData) ); - } - - do { - last_arg=argn; - - if (Glace_WKeyMatch (argv[argn], "-reset", 4)) - { - Glace_CfgInit ( cfgInfoPtr ); - argn++; - } - else if (Glace_WKeyMatch (argv[argn], "-cosraw", 5)) - { - vtype = argn++; - GLACE_CFG(outputMethod) = GLACE_COSRAW; - } - else if (Glace_WKeyMatch (argv[argn], "-sinraw", 5)) - { - vtype = argn++; - GLACE_CFG(outputMethod) = GLACE_SINRAW; - } - else if (Glace_WKeyMatch (argv[argn], "-cosfilt", 5)) - { - vtype = argn++; - GLACE_CFG(outputMethod) = GLACE_COSFILT; - } - else if (Glace_WKeyMatch (argv[argn], "-sinfilt", 5)) - { - vtype = argn++; - GLACE_CFG(outputMethod) = GLACE_SINFILT; - } - else if (Glace_WKeyMatch (argv[argn], "-clip", 3)) - { - vtype = argn++; - GLACE_CFG(doClip) = GLACE_TRUE; - GLACE_CFG(outputMethod) = GLACE_NORMAL; - } - else if (Glace_WKeyMatch (argv[argn], "-quiet", 2)) - { - GLACE_CFG(verbose) = GLACE_FALSE; - argn++; - } - else if (Glace_WKeyMatch (argv[argn], "-verbose", 2)) - { - GLACE_CFG(verbose) = GLACE_TRUE; - argn++; - } - else if (Glace_WKeyMatch (argv[argn], "-refimage", 4)) - { - vrefimage = argn; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-input", 4)) - { - vinput = argn; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-output", 4)) - { - voutput = argn; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-hamming", 2)) - { - GLACE_CFG(hammingCwind) = GLACE_TRUE; - argn++; - } - else if (Glace_WKeyMatch (argv[argn], "-prescale", 3)) - { - vprescale = argn; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-passthru", 2)) - { - vpassthru = argn; - GLACE_CFG(addbackMode) = GLACE_COMMANDLINE; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-zaddback", 2)) - { - vaddback = argn; - GLACE_CFG(addbackType) = GLACE_ZEROINPUT; - GLACE_CFG(addbackMode) = GLACE_COMMANDLINE; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-laddback", 2)) - { - vaddback = argn; - GLACE_CFG(addbackType) = GLACE_LOCALMEAN; - GLACE_CFG(addbackMode) = GLACE_COMMANDLINE; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-onlyheseries", 5)) - { - GLACE_CFG(addbackCwind) = GLACE_FALSE; - argn++; - } - else if (Glace_WKeyMatch (argv[argn], "-gauss", 3)) - { - vgauss = argn; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-inoffset", 2)) - { - vinoffset = argn; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-factor", 2)) - { - vfactor = argn; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-windlistfile", 2)) - { - vwlistfile = argn; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-seriesfile", 2)) - { - vseriesfile = argn; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-ddlistfile", 4)) - { - vddlistfile = argn; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-ddimages", 4)) - { - vddimages = argn; - argn +=3; - } - else if (Glace_WKeyMatch (argv[argn], "-cumulation", 3)) - { - vcfunc = argn; - argn +=4; - } - else if (Glace_WKeyMatch (argv[argn], "-tolerance", 2)) - { - vtol = argn; - argn +=2; - } - else if (Glace_WKeyMatch (argv[argn], "-doublep", 2)) - { - GLACE_CFG(doublep) = GLACE_TRUE; - argn++; - } - else if (Glace_WKeyMatch (argv[argn], "-ggd", 4)) - { - GLACE_CFG(chrome) = GLACE_GG; - GLACE_CFG(doubleout) = GLACE_TRUE; - argn++; - /* PNM: default for PGM input - + and use to force reading PPM as gray*/ - } - else if (Glace_WKeyMatch (argv[argn], "-gg", 3)) - { - GLACE_CFG(chrome) = GLACE_GG; - argn++; - /* PNM: default for PGM input - + and use to force reading PPM as gray*/ - } - else if (Glace_WKeyMatch (argv[argn], "-cgd", 4)) - { - GLACE_CFG(chrome) = GLACE_CG; - GLACE_CFG(doubleout) = GLACE_TRUE; - argn++; - /* PNM: use to force gray output*/ - } - else if (Glace_WKeyMatch (argv[argn], "-cg", 3)) - { - GLACE_CFG(chrome) = GLACE_CG; - argn++; - /* PNM: use to force gray output*/ - } - else if (Glace_WKeyMatch (argv[argn], "-cc", 3)) - { - GLACE_CFG(chrome) = GLACE_CC; - argn++; - /* PNM: default for PPM input and hence irrelevant */ - } - else - { - vdimensions = argn; - argn +=3; - } - } - while (argn<(argc-1)); - - - /* Possiblities here: (note argc=#args +1) - * - * Last argument must not be single, eg -verbose - * - * Single final argument must be filename or `-': argn==argc-1 - * Standard input assumed otherwise: argn==argc-1+1 - * Error if we have overspilled: argn >argc-1+1 - */ - - if (argn > (argc)) - return GlaceArgError( GLACE_CFG(wData), - "Final option was missing a value.", - argv, argc-last_arg, last_arg); - - /* Input stream is opened at end of this procedure, so that - earlier errors are indicated first. */ - - /* ************************************************************ */ - /* Check types of operation. */ - - /* DIAGNOSTIC (sinfilt etc. override -clip when coming after) */ - if (GLACE_CFG(outputMethod) != GLACE_NORMAL) - { - GLACE_CFG(doClip) = GLACE_FALSE; - } - - /* HETYPE */ - if (vfactor>0) - { - if (vseriesfile>0) - return GlaceArgError( GLACE_CFG(wData), - "Option conflict: seriesfile with factor.", - argv, 2, vseriesfile); - GLACE_CFG(heType) = GLACE_FACTOR; - } - else if (vseriesfile>0) - { - GLACE_CFG(heType) = GLACE_SERIES; - GLACE_CFG(sListfile) = fopen (argv[vseriesfile+1], "rt"); - if ( GLACE_CFG(sListfile) == NULL) - return GlaceArgError( GLACE_CFG(wData), - "Unable to open series list file.", - argv, 2, vseriesfile); - } - - /* FILTMETHOD & DIMENSIONSRC */ - if (vddimages>0) - { - if (vwlistfile>0) - return GlaceArgError( GLACE_CFG(wData), - "Option conflict: windlistfile with ddimages.", - argv, 2, vwlistfile); - GLACE_CFG(filtMethod) = GLACE_DIRDIFF; - if (vddlistfile>0) - { - GLACE_CFG(dimensionSrc) = GLACE_LISTFILE; - GLACE_CFG(dListfile) = fopen (argv[vddlistfile+1], "rt"); - if ( GLACE_CFG(dListfile) == NULL) - return GlaceArgError( GLACE_CFG(wData), - "Unable to open window list file.", - argv, 2, vddlistfile); - } - - - } - else if (vwlistfile>0) - { - if (vddlistfile>0) - return GlaceArgError( GLACE_CFG(wData), - "Option conflict: ddlistfile" - " with windlistfile.", - argv, 2, vddlistfile); - GLACE_CFG(dimensionSrc) = GLACE_LISTFILE; - - GLACE_CFG(wListfile) = fopen (argv[vwlistfile+1], "rt"); - if ( GLACE_CFG(wListfile) == NULL) - return GlaceArgError( GLACE_CFG(wData), - "Unable to open window list file.", - argv, 2, vwlistfile); - - } - else if (vddlistfile>0) - return GlaceArgError( GLACE_CFG(wData), - "Option ddlistfile requires ddimages.", - argv, 2, vddlistfile); - - if (vdimensions>0) - if (GLACE_CFG(dimensionSrc) == GLACE_LISTFILE) - return GlaceArgError( GLACE_CFG(wData), - "Option conflict: dimensions with a listfile.", - argv, 3, vdimensions); - else - { - GLACE_CFG(dimensionSrc) = GLACE_COMMANDLINE; - /* read window/dd parameters from next three args. */ - GLACE_CFG(windBaseW) = atoi (argv[vdimensions]); - GLACE_CFG(windBaseH) = atoi (argv[vdimensions+1]); - GLACE_CFG(numTerms) = atoi (argv[vdimensions+2]); - if (GLACE_CFG(numTerms) < 0) - return GlaceArgError( GLACE_CFG(wData), - "Number of terms must be a" - " positive integer.", - argv, 3, vdimensions); - if (GLACE_CFG(numTerms) == 0) - { - if (GLACE_CFG(wrapType)==GLACE_TK_VER) - GLACE_CFG(plainGlace) = GLACE_FALSE; - else - return GlaceArgError( GLACE_CFG(wData), - "Number of terms must be" - " greater than zero.", - argv, 3, vdimensions); - } - if (GLACE_CFG(plainGlace) == GLACE_TRUE) - { - if (GLACE_CFG(numTerms) > GLACE_CFG_DEFAULT_NUM_TERMS) - return GlaceArgError( GLACE_CFG(wData), - "The maximum number of terms is 200.", - argv, 3, vdimensions); - - if (GLACE_CFG(filtMethod) == GLACE_WINDOW) - { - if (GLACE_CFG(windBaseW) < 3 || GLACE_CFG(windBaseH) < 3) - return GlaceArgError( GLACE_CFG(wData), - "Dimensions integers must" - " be greater than 2.", - argv, 3, vdimensions); - else - if (GLACE_CFG(windBaseW) < 1 || GLACE_CFG(windBaseH) < 0) - return GlaceArgError( GLACE_CFG(wData), - "Dimension >=1 and baseval >0.", - argv, 3, vdimensions); - } - } - } - else if (GLACE_CFG(dimensionSrc) == GLACE_MISSING) - return GlaceArgError( GLACE_CFG(wData),"Filter specification required.", - argv, 0, vddlistfile); - - - /* ************************************************************ */ - /* Extract argument information. */ - - /* PRESCALE */ - if (vprescale>0) - { - GLACE_CFG(prescaleMode) = GLACE_COMMANDLINE; - GLACE_CFG(prescaleVal) = atof (argv[vprescale+1]); - if ( (GLACE_CFG(prescaleVal) < 0) || (GLACE_CFG(prescaleVal) > 2) ) - return GlaceArgError( GLACE_CFG(wData), - "Prescale argument should be between 0 and 2.", - argv, 2, vprescale); - } - - /* FACTOR */ - if (vfactor>0) - { - GLACE_CFG(heFactor) = (float) atof (argv[vfactor+1]); - if (GLACE_CFG(heFactor)>1) - GLACE_CFG(heFactor) = GLACE_CFG(heFactor)/100.0; - if ( (GLACE_CFG(heFactor) < 0.0) || (GLACE_CFG(heFactor) > 1.0) ) - return GlaceArgError( GLACE_CFG(wData), - "Factor argument should be between 0 and 1.", - argv, 2, vfactor); - } - - /* ADDBACK */ - if (vaddback>0) - { - GLACE_CFG(addbackFactor) = atof (argv[vaddback+1]); - if ( (GLACE_CFG(addbackFactor) < 0.0) || - (GLACE_CFG(addbackFactor) > 1.0) ) - return GlaceArgError( GLACE_CFG(wData), - "Addback argument should be between 0 and 1.", - argv, 2, vaddback); - } - if (vpassthru>0) - { - GLACE_CFG(passthruFactor) = atof (argv[vpassthru+1]); - if ( (GLACE_CFG(passthruFactor) < 0.0) || - (GLACE_CFG(passthruFactor) > 1.0) ) - return GlaceArgError( GLACE_CFG(wData), - "Passthru argument should be between 0 and 1.", - argv, 2, vpassthru); - } - - /* INOFFSET */ - if (vinoffset>0) - { - GLACE_CFG(inoffsetMode) = GLACE_COMMANDLINE; - GLACE_CFG(inoffsetVal) = atof (argv[vinoffset+1]); - if ( (GLACE_CFG(inoffsetVal) < 0) || - (GLACE_CFG(inoffsetVal) > GLACE_MAXMAXGRAY) ) - return GlaceArgError( GLACE_CFG(wData), - "Input offset argument out of gray level range.", - argv, 2, vinoffset); - if ( (GLACE_CFG(inoffsetVal) > -0.000001) && - (GLACE_CFG(inoffsetVal) < 1.000001 ) ) - GLACE_CFG(inoffsetVal) = GLACE_CFG(inoffsetVal) * GLACE_MAXMAXGRAY; - } - - /* GAUSSIAN SMOOTHING */ - if (vgauss>0) - { - GLACE_CFG(gaussCwindWidth) = atof (argv[vgauss+1]); - if (GLACE_CFG(gaussCwindWidth) < 0.0) - return GlaceArgError( GLACE_CFG(wData), - "Gaussian width argument must be nonnegative.", - argv, 2, vgauss); - GLACE_CFG(gaussCwind) = GLACE_TRUE; - } - - /* TOLERANCE */ - if (vtol>0) - { - GLACE_CFG(coeffTol) = (float) atof (argv[vtol+1]); - } - - /* REFERENCE IMAGE */ - if (vrefimage>0) - { - Glace_WOpenImage( GLACE_CFG(wData), cfgInfoPtr, argv[vrefimage+1], - &GLACE_IMG(refImageHandle) ); - GLACE_CFG(refimageMode) = GLACE_SEPARATE; - } - - /* CUMULATION FUNCTION */ - if (vcfunc>0) - { - GLACE_CFG(genCFunc) = GLACE_TRUE; - GLACE_CFG(cFuncMin) = atof (argv[vcfunc+1]); - GLACE_CFG(cFuncMax) = atof (argv[vcfunc+2]); - GLACE_CFG(cFuncPoints) = atol (argv[vcfunc+3]); - if (GLACE_CFG(cFuncPoints) < 2) - return GlaceArgError( GLACE_CFG(wData), - "Number of points in curve must be greater than 1.", - argv, 4, vcfunc); - } - - /* OPEN INPUT */ - if (argn < argc) /* `-' = stdin */ - Glace_WOpenImage( GLACE_CFG(wData), cfgInfoPtr, argv[argn], - &GLACE_IMG(inputImageHandle) ); - else if (argn == argc) - Glace_WOpenImage( GLACE_CFG(wData), cfgInfoPtr, NULL, - &GLACE_IMG(inputImageHandle) ); - - /* INPUT IMAGE */ - if (vinput>0) - Glace_WOpenImage( GLACE_CFG(wData), cfgInfoPtr, argv[vinput+1], - &GLACE_IMG(inputImageHandle) ); - - /* OUTPUT IMAGE */ - if (voutput>0) - Glace_WOpenImage( GLACE_CFG(wData), cfgInfoPtr, argv[voutput+1], - &GLACE_IMG(outputImageHandle) ); - /* OPEN DIRECTION IMAGES */ - if (vddimages>0) - { - Glace_WOpenImage( GLACE_CFG(wData), cfgInfoPtr, argv[vddimages+1], - &GLACE_IMG(ddHImageHandle) ); - if (GLACE_IMG(ddHImageHandle) == NULL) - return GlaceArgError( GLACE_CFG(wData), - "Unable to open first (horiz) image direction file.", - argv, 2, vddimages); - Glace_WOpenImage( GLACE_CFG(wData), cfgInfoPtr, argv[vddimages+2], - &GLACE_IMG(ddVImageHandle) ); - if (GLACE_IMG(ddVImageHandle) == NULL) - return GlaceArgError( GLACE_CFG(wData), - "Unable to open second (vert) image direction file.", - argv, 2, vddimages); - } - - /* ********************************************************************** */ - return Glace_WErrorValue( GLACE_CFG(wData) ); -} - - - -/* :*** Cumulation Function ***: - - * :FUNCTION: Glace_CFuncGen - */ -int -Glace_CFuncGen ( - Glace_CfgInfo *cfgInfoPtr - ) -{ - char outText[20]; - float x, y; - int i; - - if (GLACE_CFG(genCFunc)) - { - if (GLACE_CFG(numTerms)!=GLACE_CFG(termsSerialised)) - return Glace_WError( GLACE_CFG(wData), - "Series arrays not correctly allocated before call to" - " cumulation\nfunction generator."); - if (GLACE_CFG(verbose)) - Glace_WMessage( GLACE_CFG(wData), "Cumulation Function:\n" - " x y ideal-y\n" ); - - for (i=0; ioutputmethod = NORMAL; etc.. */ - memset((cfgInfoPtr), '\0',sizeof(Glace_CfgInfo)); - - GLACE_CFG(verbose) = GLACE_TRUE; - GLACE_CFG(addbackCwind) = GLACE_TRUE; - - GLACE_CFG(numTerms) = GLACE_CFG_DEFAULT_NUM_TERMS; - GLACE_CFG(inoffsetVal) = GLACE_MIDGRAY; - - GLACE_CFG(wData) = wData; - GLACE_CFG(wrapType) = Glace_WWrapTell(); - GLACE_CFG(plainGlace) = GLACE_TRUE; - -} - - -/**************************************************************/ - -/* - * :FUNCTION: Glace_CfgFreeSeriesVectors - */ -void -Glace_CfgFreeSeriesVectors ( - Glace_CfgInfo *cfgInfoPtr - ) -{ - Glace_CallocReallocFree( GLACE_CFG(heseriesSeries), - &GLACE_CFG(currentSeriesAllocation), - 0, 1, 0.4); - -} - - -/**************************************************************/ - -/* - * :FUNCTION: Glace_CfgAllocSeriesVectors - */ -void -Glace_CfgAllocSeriesVectors ( - Glace_CfgInfo *cfgInfoPtr - ) -{ - int newSeriesTerms; - - /* Note that we start the series from [1], and so the */ - - /* round up to nearest ROUND_TERMS */ -#define ROUND_TERMS (10) - newSeriesTerms = ( (int) (GLACE_CFG(numTerms)/ROUND_TERMS) +1 ) - * ROUND_TERMS; - - GLACE_CFG(heseriesSeries) = (double *) - Glace_CallocReallocFree( GLACE_CFG(heseriesSeries), - &GLACE_CFG(currentSeriesAllocation), - newSeriesTerms, - 3*sizeof( double ) + 4*sizeof( int ), - 0.4); - - GLACE_CFG(cwindSeries) = - &GLACE_CFG(heseriesSeries)[newSeriesTerms]; - GLACE_CFG(addbackSeries) = - &GLACE_CFG(heseriesSeries)[newSeriesTerms*2]; - GLACE_CFG(windCWSeries) = (int *) - &GLACE_CFG(heseriesSeries)[newSeriesTerms*3]; - GLACE_CFG(windCHSeries) = - &GLACE_CFG(windCWSeries)[newSeriesTerms]; - GLACE_CFG(windSWSeries) = - &GLACE_CFG(windCWSeries)[newSeriesTerms*2]; - GLACE_CFG(windSHSeries) = - &GLACE_CFG(windCWSeries)[newSeriesTerms*3]; - - GLACE_CFG(termsSerialised) = GLACE_CFG(numTerms); - -} - -/**************************************************************/ - -/* - * :FUNCTION: Glace_CfgBeginToHeseries - */ -void -Glace_CfgBeginToHeseries ( - Glace_CfgInfo *cfgInfoPtr - ) -{ - int j; - int windw, windh; - - double hamma, hammb; - struct Glace_HeseriesInfo hsi; - - - - for (j=1; j<=GLACE_CFG(numTerms); j++) - GLACE_CFG(cwindSeries[j]) = 1.0; - - if ( GLACE_CFG(heType) != GLACE_FACTOR ) - GLACE_CFG(heFactor) = 0.0; - - - /* SET TERM RANGE */ - /* if not normal we only output 1 term, ie the last */ - if (GLACE_CFG(outputMethod) == GLACE_NORMAL) - GLACE_CFG(firstTerm) = 1; - else - GLACE_CFG(firstTerm) = GLACE_CFG(numTerms); - - - /* PRESCALE */ - if ( GLACE_CFG(prescaleMode) == GLACE_MISSING ) - { - if (GLACE_CFG(heType) == GLACE_STANDARD) - GLACE_CFG(prescaleVal) = 1.7; - else - GLACE_CFG(prescaleVal) = 1.0; - } - - /* ADDBACK */ - if ( GLACE_CFG(addbackMode) == GLACE_MISSING ) - { - GLACE_CFG(addbackType) = GLACE_CFG_DEFAULT_A_WITH_F; - GLACE_CFG(passthruFactor) = GLACE_CFG(heFactor); - GLACE_CFG(addbackFactor) = 0.0; - /*GLACE_CFG(addbackFactor) = GLACE_CFG(heFactor);*/ - } - - if (GLACE_CFG(filtMethod) == GLACE_WINDOW) { - /* WINDOW SIZES */ - if ( GLACE_CFG(dimensionSrc) == GLACE_LISTFILE ) - { /* Now in pgm scan listfiles */ } - else if ( GLACE_CFG(dimensionSrc) == GLACE_COMMANDLINE ) - { - if (GLACE_CFG(windBaseW) < 3 || GLACE_CFG(windBaseH) < 3) - Glace_WError( GLACE_CFG(wData), - "Dimensions integers must be greater than 2."); - if (GLACE_CFG(numTerms) <= 0) - Glace_WError( GLACE_CFG(wData), - "Number of terms must be a positive integer."); - if (GLACE_CFG(numTerms) > GLACE_CFG_DEFAULT_NUM_TERMS) - Glace_WError( GLACE_CFG(wData), - "The maximum number of terms is 200."); - /* convert to extent either side of pel */ - windw = GLACE_CFG(windBaseW) / 2; - windh = GLACE_CFG(windBaseH) / 2; - for (j = 1; j <= GLACE_CFG(numTerms); j++) - { - GLACE_CFG(windCWSeries[j]) = windw; - GLACE_CFG(windSWSeries[j]) = windw; - GLACE_CFG(windCHSeries[j]) = windh; - GLACE_CFG(windSHSeries[j]) = windh; - }; - } - } else { /* DIRDIFF */ - if ( GLACE_CFG(dimensionSrc) == GLACE_LISTFILE ) - { /* Now in pgm scan listfiles */ } - else if ( GLACE_CFG(dimensionSrc) == GLACE_COMMANDLINE ) - { - if (GLACE_CFG(windBaseW) < 1 || GLACE_CFG(windBaseH) < 0) - Glace_WError( GLACE_CFG(wData),"Dimension >=1 and baseval >0."); - if (GLACE_CFG(numTerms) <= 0) - Glace_WError( GLACE_CFG(wData),"Number of terms must be a positive integer."); - if (GLACE_CFG(numTerms) > GLACE_CFG_DEFAULT_NUM_TERMS) - Glace_WError( GLACE_CFG(wData),"The maximum number of terms is 200."); - for (j = 1; j <= GLACE_CFG(numTerms); j++) - { - GLACE_CFG(GLACE_CFG_COSDIM[j]) = GLACE_CFG(windBaseW); - GLACE_CFG(GLACE_CFG_SINDIM[j]) = GLACE_CFG(windBaseW); - GLACE_CFG(GLACE_CFG_COSBV[j]) = GLACE_CFG(windBaseH); - GLACE_CFG(GLACE_CFG_SINBV[j]) = GLACE_CFG(windBaseH); - }; - } - } - - /* HE SERIES */ - if ( GLACE_CFG(heType) == GLACE_SERIES ) - { /* Now in pgm scan listfiles */ } - else if ( GLACE_CFG(heType) == GLACE_FACTOR ) - { - Glace_HeseriesInit(&hsi,GLACE_CFG(heFactor)); - for (j = 1; j <= GLACE_CFG(numTerms); j++) - { - GLACE_CFG(heseriesSeries[j]) = Glace_HeseriesVal(&hsi,j); - if (GLACE_CFG(heseriesSeries[j]) ==GLACE_HESERIES_ERRORFLAG) - Glace_WError( GLACE_CFG(wData), - "Error in Fourier series evaluation."); - } - } - else - { - for (j = 1; j <= GLACE_CFG(numTerms); j++) - GLACE_CFG(heseriesSeries[j]) = 4 / GLACE_PI / (2 * j - 1); - } - - for (j = 1, hamma=1; j <= GLACE_CFG(numTerms); j++, hamma *= -1) - GLACE_CFG(heseriesSeries[j]) -= - hamma * GLACE_CFG(passthruFactor) - *16 /GLACE_PI /GLACE_PI /(2 * j - 1) /(2 * j - 1); - - /* HAMMING WINDOWING */ - if (GLACE_CFG(hammingCwind)==GLACE_TRUE) - { - /* hamma = 1/(0.54 + 0.46*cos(GLACE_PI/(2*GLACE_CFG(numTerms))));*/ - hamma = 1.0; - hammb = 0.46*hamma; - hamma = 0.54*hamma; - for (j = 1; j <= GLACE_CFG(numTerms); j++) - GLACE_CFG(cwindSeries[j]) = GLACE_CFG(cwindSeries[j]) - * (hamma + hammb*cos(GLACE_PI/(2*GLACE_CFG(numTerms))*(2 * j - 1))); - } - - /* GAUSSIAN BLURRING */ - if ( GLACE_CFG(gaussCwind) == GLACE_TRUE ) - { - hamma = -0.125*GLACE_PI*GLACE_PI/GLACE_MAXMAXGRAY/GLACE_MAXMAXGRAY - * GLACE_CFG(prescaleVal) * GLACE_CFG(prescaleVal) - * GLACE_CFG(gaussCwindWidth) * GLACE_CFG(gaussCwindWidth); - for (j = 1; j <= GLACE_CFG(numTerms); j++) - GLACE_CFG(cwindSeries[j]) = GLACE_CFG(cwindSeries[j]) - * exp(hamma*(2 * j - 1)*(2 * j - 1)); - } - - /* TOLERANCE */ - if ( GLACE_CFG(coeffTol) == 0.0 ) - { - if ( GLACE_CFG(doublep) == GLACE_TRUE ) - GLACE_CFG(coeffTol) = GLACE_TOL_DOUBLEP; - else - GLACE_CFG(coeffTol) = GLACE_TOL_SINGLEP; - } - - if ( (GLACE_CFG(doubleout) == GLACE_TRUE) && - (GLACE_CFG(doClip)==GLACE_TRUE)) - Glace_WError( GLACE_CFG(wData), - "-clip option conflicts with double-precision output."); -} - -/**************************************************************/ - -/* - * :FUNCTION: Glace_CfgHeseriesToAddback - */ -void -Glace_CfgHeseriesToAddback ( - Glace_CfgInfo *cfgInfoPtr - ) -{ - int j; - double hamma; - - - /* ADDBACK SERIES */ - /* NOTE: If, in later versions, different addback amounts can be - specified for each term, then a global factor is still - required for the output offset. */ - if (GLACE_CFG(addbackType)==GLACE_ZEROINPUT ) - for (j = 1; j <= GLACE_CFG(numTerms); j++) - GLACE_CFG(addbackSeries[j]) = GLACE_CFG(heseriesSeries[j]) - * GLACE_CFG(addbackFactor); - else if (GLACE_CFG(addbackType)==GLACE_LOCALMEAN ) - for (j = 1, hamma=1; j <= GLACE_CFG(numTerms); j++, hamma *= -1) - GLACE_CFG(addbackSeries[j]) = hamma * GLACE_CFG(addbackFactor) - *16 /GLACE_PI /GLACE_PI /(2 * j - 1) /(2 * j - 1); - else if (GLACE_CFG(addbackType)==GLACE_NONE ) - for (j = 1; j <= GLACE_CFG(numTerms); j++) - GLACE_CFG(addbackSeries[j]) = 0.0; - - /* APPLY COEFFICIENT WINDOW */ - for (j = 1; j <= GLACE_CFG(numTerms); j++) - GLACE_CFG(heseriesSeries[j]) = GLACE_CFG(cwindSeries[j]) - * GLACE_CFG(heseriesSeries[j]); - - -} - -/**************************************************************/ - -/* - * :FUNCTION: Glace_CfgAddbackToEnd - */ -void -Glace_CfgAddbackToEnd ( - Glace_CfgInfo *cfgInfoPtr - ) -{ - int j; - float total; - - if ( ((GLACE_CFG(outputMethod) != GLACE_NORMAL) || - (GLACE_CFG(doClip)==GLACE_TRUE)) - && (GLACE_CFG(chrome)==GLACE_CC)) - GLACE_CFG(chrome)=GLACE_CG; - - - /* APPLY COEFFICIENT WINDOW */ - if ( GLACE_CFG(addbackCwind)==GLACE_TRUE ) - for (j = 1; j <= GLACE_CFG(numTerms); j++) - GLACE_CFG(addbackSeries[j]) = - GLACE_CFG(cwindSeries[j]) * GLACE_CFG(addbackSeries[j]); - - /* TRUNCATE PRECISION */ - for (j = 1; j <= GLACE_CFG(numTerms); j++) - { - GLACE_CFG(addbackSeries[j]) = - 1.0 - (float) (1.0-GLACE_CFG(addbackSeries[j])); - GLACE_CFG(heseriesSeries[j]) = - 1.0 - (float) (1.0-GLACE_CFG(heseriesSeries[j])); - } - - /* TOLERANCE */ - for (j = GLACE_CFG(numTerms), total = 0.0; - ((j>0) && (total < GLACE_CFG(coeffTol))) ; j--) - total += - max(abs(GLACE_CFG(heseriesSeries[j])), - abs(GLACE_CFG(addbackSeries[j]))); - GLACE_CFG(activeTerms) = min(j+1,GLACE_CFG(numTerms)); - - - - - - /*++++++++++ VERBOSITY POINT ++++++++++*/ - if (GLACE_CFG(verbose)) - { - if ( GLACE_CFG(heType) == GLACE_FACTOR ) - fprintf (stderr, "HE factor: %f.\n", GLACE_CFG(heFactor)); - - if ( GLACE_CFG(chrome) == GLACE_GG ) - if ( GLACE_CFG(doublep) == GLACE_FALSE ) - fprintf (stderr, "Gray input; "); - else - fprintf (stderr, "Two-byte gray input; "); - else - fprintf (stderr, "Colour input; "); - if ( GLACE_CFG(doubleout) == GLACE_TRUE ) - fprintf (stderr, "two-byte gray output.\n"); - else if ( GLACE_CFG(chrome) == GLACE_CC ) - fprintf (stderr, "colour output.\n"); - else - fprintf (stderr, "gray output.\n"); - - if ( GLACE_CFG(doublep) == GLACE_FALSE ) - fprintf (stderr, "Standard precision process.\n"); - else - fprintf (stderr, "Two-byte precision process.\n"); - - if ( GLACE_CFG(gaussCwind) == GLACE_TRUE ) - fprintf (stderr, "Gaussian smoother width: %f.\n", - GLACE_CFG(gaussCwindWidth)); - if (GLACE_CFG(hammingCwind)==GLACE_TRUE) - fprintf (stderr, "Hamming windowing of HE series.\n"); - if (GLACE_CFG(refimageMode)==GLACE_SEPARATE) - fprintf (stderr, "Using separate histogram reference image.\n"); - if ( GLACE_CFG(dimensionSrc) == GLACE_LISTFILE ) - fprintf (stderr, "Filter dimensions from listfile.\n"); - if ( GLACE_CFG(heType) == GLACE_SERIES ) - fprintf (stderr, "HE series coefficients from listfile.\n"); - - fprintf (stderr, "Prescale: %f\tInput offset: %f.\n", - (double) GLACE_CFG(prescaleVal), - (double) GLACE_CFG(inoffsetVal)); - - if (GLACE_CFG(passthruFactor)>0 ) - fprintf (stderr, "Pass-thru, factor %f.\n", - (double) GLACE_CFG(passthruFactor)); - - if (GLACE_CFG(addbackType)==GLACE_ZEROINPUT ) - fprintf (stderr, "Addback: zero-input, factor %f, ", - (double) GLACE_CFG(addbackFactor)); - else if (GLACE_CFG(addbackType)==GLACE_LOCALMEAN ) - fprintf (stderr, "Addback: local-mean, factor %f, ", - (double) GLACE_CFG(addbackFactor)); - - if (GLACE_CFG(addbackType)!=GLACE_NONE ) - { - if ( GLACE_CFG(addbackCwind)==GLACE_TRUE ) - fprintf (stderr, "coefficients windowed/blurred.\n"); - else - fprintf (stderr, "coefficients NOT windowed/blurred.\n"); - } - - fprintf (stderr, "Coefficient tolerance %f; active terms %d.\n", - (double) GLACE_CFG(coeffTol), GLACE_CFG(activeTerms)); - - if (GLACE_CFG(outputMethod) == GLACE_SINRAW) - fprintf (stderr, "DIAGNOSTIC OUTPUT: Raw sine field.\n"); - else if (GLACE_CFG(outputMethod) == GLACE_COSRAW) - fprintf (stderr, "DIAGNOSTIC OUTPUT: Raw cosine field.\n"); - else if (GLACE_CFG(outputMethod) == GLACE_SINFILT) - fprintf (stderr, "DIAGNOSTIC OUTPUT: Filtered sine field.\n"); - else if (GLACE_CFG(outputMethod) == GLACE_COSFILT) - fprintf (stderr, "DIAGNOSTIC OUTPUT: Filtered cosine field.\n"); - else if (GLACE_CFG(doClip) == GLACE_TRUE) - fprintf (stderr, "DIAGNOSTIC OUTPUT: Clipping field.\n"); - - - if (GLACE_CFG(filtMethod) == GLACE_WINDOW) - fprintf (stderr, "Window filtering.\n" - "Term: cos-w cos-h sin-w sin-h; series; addback.\n"); - else - fprintf (stderr, "Biased diffusion filtering.\n" - "Term: cos-d sin-d; series; addback.\n"); - } - - -} - - - -/* :*** SIGNED POWER-LAW HESERIES ***: - - * :HEADER: (extras) - */ - - - -typedef struct GlaceZHeseriesInfo -{ -double heFactor; -double heFactorX; /* 2-heFactor */ -double heGammaVal; /* gamma(heFactorX) */ -double heTwoPower; /* 2^heFactorX */ -double heSinVal; /* sin( heFactorX*pi/2 ) */ -double heBaseMag; /* (1st coeff)/heTwoPower */ - /* (this is kept so that relative errors - for other coefficients can be found.) */ -char dummy[GLACE_HESERIES_RESERVE - 6*sizeof(double)]; -} GlaceZHeseriesInfo; - -#define HE_FACTOR ((GlaceZHeseriesInfo *) heseriesPtr)->heFactor -#define HE_FACTOR_X ((GlaceZHeseriesInfo *) heseriesPtr)->heFactorX -#define HE_GAMMA_VAL ((GlaceZHeseriesInfo *) heseriesPtr)->heGammaVal -#define HE_TWO_POWER ((GlaceZHeseriesInfo *) heseriesPtr)->heTwoPower -#define HE_BASE_MAG ((GlaceZHeseriesInfo *) heseriesPtr)->heBaseMag -#define HE_GLACE_SIN_VAL ((GlaceZHeseriesInfo *) heseriesPtr)->heSinVal - - - - - -/* - * :FUNCTION: Glace_HeseriesInit - */ -void -Glace_HeseriesInit ( - Glace_HeseriesInfo *heseriesPtr, - float heFactor) -{ - double x, g; - double omega_sq = GLACE_PI*GLACE_PI/4; - double cstep, cprod, csum; - - /* simple bits */ - HE_FACTOR = heFactor; - HE_FACTOR_X = 1+heFactor; - - /* - * HE_GAMMA_VAL = gamma(HE_FACTOR_X) - * absolute error < 3e-7 - * - * See Abramowitz & Stegun - */ - x = HE_FACTOR_X -1; - g = ((0.035868343*x - 0.193527818)*x + 0.482199394)*x; - g = ((g - 0.756704078)*x + 0.918206857)*x - 0.897056937; - g = ((g*x + 0.988205891)*x - 0.577191652)*x + 1; - HE_GAMMA_VAL = g; - - /* - * HE_TWO_POWER = 2^HE_FACTOR_X - */ - HE_TWO_POWER = pow(2.0, HE_FACTOR_X); - - /* - * HE_BASE_MAG = 1st coefficient /HE_TWO_POWER - * Series development (only require every other term) - */ - cstep = HE_FACTOR_X; - cprod = 1.0/cstep; - csum = cprod; - while (fabs(cprod) > (10.0 * DBL_EPSILON * fabs(csum))) - { - cstep += 1.0; - cprod *= -omega_sq /cstep; - cstep += 1.0; - cprod /= cstep; - csum += cprod; - }; - HE_BASE_MAG = fabs(csum); - - HE_GLACE_SIN_VAL = sin(GLACE_PI*0.5*HE_FACTOR_X); -} - -/* **************************************** */ -/* CALCULATE SINGLE VALUE */ - -/* - * :FUNCTION: Glace_HeseriesVal - */ -double -Glace_HeseriesVal ( - Glace_HeseriesInfo *heseriesPtr, - int k) -{ - double p1r, p1i, p2r, p2i, q1r, q1i, q2r, q2i, - omega, cold, cnew, tolval, n, normfact; - - if (k<0) - { - /* - Glace_WError("Invalid request of HE series coefficient.\n"); - exit(1); - */ - return GLACE_HESERIES_ERRORFLAG; - } - - - if (k==1) - return HE_BASE_MAG*HE_TWO_POWER; - else - { - tolval = 10.0*DBL_EPSILON*HE_BASE_MAG; - omega = ((double) k -0.5)*GLACE_PI; - p1r = 0.0; - p1i = 0.0; - p2r = 1.0; - p2i = 0.0; - q1r = 1.0; - q1i = 0.0; - q2r = 0.0; - q2i = omega; - cold = 0.0; - cnew = 1.0; /* make sure it gets off the ground. */ - n = 1.0; - normfact = 1.0; - /* - * NB convergence wrt real part is poor, but this will be swamped by - * the addition of the gamma factor. - * while ( abs (cold - cnew) > 10 * eps * abs(cnew) ) & (n<100) - * Note that sometimes (especially, for example, heFactor 0.15) - * the coefficient is near to zero. - */ - while (( fabs(cold - cnew) > tolval ) && (n<300.0)) - { - cold = cnew; - p1r = q1r + p1r * (n - HE_FACTOR_X)*normfact; - p1i = q1i + p1i * (n - HE_FACTOR_X)*normfact; - p2r = q2r + p2r * (n - HE_FACTOR_X)*normfact; - p2i = q2i + p2i * (n - HE_FACTOR_X)*normfact; - q2r = -p2i * omega + n * q2r; - q2i = p2r * omega + n * q2i; - /* simulate getting exponent to normalise. */ - /* normfact = exp(round(-0.5*log(q2r*q2r+q2i*q2i)));*/ - normfact = 1.0 /sqrt(q2r*q2r+q2i*q2i); - q2r = q2r *normfact; - q2i = q2i *normfact; - q1r = (-p1i * omega + n * q1r) *normfact; - q1i = ( p1r * omega + n * q1i) *normfact; - cnew = (q1r*q2r+q1i*q2i) / (q2r*q2r+q2i*q2i); - n = n + 1.0; - } - - /* - * y_cnew = incomplete_gamma(HE_FACTOR_X,i*omega) - * - * cnew is the required real part of an expression of y_cnew - * y_cnew = 1 - exp(-i*omega + HE_FACTOR_X * log(i*omega)) - * * cnew /gamma (HE_FACTOR_X); - * x = -imag((incomplete_gamma(i*omega,HE_FACTOR_X))/ - * (i^HE_FACTOR_X))... - * *gamma(hf)/omega^HE_FACTOR_X*2^HE_FACTOR_X; - */ - - return ( - (1.0 - 2.0*fmod((double) k, 2.0) ) /* (-1)^k */ - * cnew + HE_GLACE_SIN_VAL*HE_GAMMA_VAL*pow(omega,-HE_FACTOR_X) - ) * HE_TWO_POWER; - - } /* k!=1 */ -} - - - -/* :*** IMAGE FIELD FILTERING ***: - - * :FUNCTION: GlaceWindTableFill (unused) - */ -void -GlaceWindTableFill(Glace_BigGray * shifted_table, - int row, - int cols, - Glace_Gray ** inImgHBPtrPtr, - Glace_BigGray * outImgPtr -) -{ - int c; - register Glace_BigGray *iagP; - register Glace_Gray *iigP; - - for (c = cols, iigP = inImgHBPtrPtr[row], - iagP = &outImgPtr[(row+1)*cols]; - c !=0; c--,iagP++,iigP++) - *iagP = shifted_table[*iigP]; - - -} - - -/* - * :FUNCTION: GlaceWindTableFillAll - */ -void -GlaceWindTableFillAll( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - /*register Glace_BigGray * shifted_table,*/ - int numPix, - Glace_Gray * hPixPtr, - Glace_Gray * lPixPtr, - Glace_BigGray * outPixPtr -) -{ - register long c; - register Glace_BigGray *iagP; - register Glace_Gray *hgP, *lgP; - register Glace_FpSeries *thisAH, *thisAL, *thisBH, *thisBL; - long *thisTable; - - thisTable = GLACE_TRM(seriesTable); - - - if (GLACE_CFG(doublep)==GLACE_FALSE) - for (c = numPix, hgP = hPixPtr, iagP = outPixPtr; - c >0; c--, iagP++, hgP++) - *iagP = thisTable[*hgP]; - else - { - thisAH = GLACE_TRM(seriesAH); - thisAL = GLACE_TRM(seriesAL); - thisBH = GLACE_TRM(seriesBH); - thisBL = GLACE_TRM(seriesBL); - for (c = numPix, hgP = hPixPtr, lgP = lPixPtr, iagP = outPixPtr; - c >0; c--, iagP++, hgP++, lgP++) - *iagP = thisAH[*hgP]*thisAL[*lgP] + - thisBH[*hgP]*thisBL[*lgP] +0.5; - } -} - -/* outImgPtr is a vector (row) array of size (cols+1)*(rows+1) - of Glace_BigGrays */ - -/* - * :FUNCTION: Glace_FiltWind - */ -void -Glace_FiltWind( - Glace_CfgInfo *cfgInfoPtr, - Glace_Gray * inImgHBPtr, - Glace_Gray * inImgLBPtr, Glace_BigGray * outImgPtr, - /*signed long *lTable,*/ - int cols, int rows, - Glace_TableInfo *tableInfoPtr, - int width, int height) -{ - int r, second_shifts, first_shifts; - /* Glace_BigGray shifted_table[GLACE_MAXMAXGRAY+1];*/ - Glace_BigGray accumX; - Glace_BigGray *oagP; - register Glace_BigGray accum; - register Glace_BigGray *obgP, *iagP; - register int c; - long k; - - if ( (2*width) >= cols) - Glace_WError( GLACE_TRM(wData), - "Window filter: window width too large."); - else if ( (2*height) >= rows) - Glace_WError( GLACE_TRM(wData), - "Window filter: window height too large."); - - /* The amount of down-shifting in preparation for the first - pass is analogous to that for filtShifts. However, some of - scaling down has already been done in constructing the - table. */ - frexp((2*width+1.0)*((double) GLACE_TRM(filtFactor))/AFT_FILTVAL, - &first_shifts); - /* The shifts required before the second (vertical) pass: */ - second_shifts = GLACE_TRM(filtShifts) -first_shifts; - - Glace_FillTableForFilt (cfgInfoPtr, tableInfoPtr, - ldexp(1.0,-first_shifts) - ); -/* - for (r=0; r<=GLACE_MAXMAXGRAY; r++) - shifted_table[r] = lTable[r] >> first_shifts; -*/ - GlaceWindTableFillAll(cfgInfoPtr,tableInfoPtr, rows*cols, - inImgHBPtr,inImgLBPtr, &outImgPtr[cols]); - - for (r = 0; r < rows; r++) - { - /* Copy row of input image using lookup table to output array, - but starting at location (1,1). */ - /* GlaceWindTableFill(shifted_table,r,cols,inImgHBPtrPtr,outImgPtr);*/ - - /* Add up first (2*width+1) columns in each row. - Put in zeroth column. This is the output for the first - width+1 columns (0 to width). */ - obgP = &outImgPtr[(r+1)*cols]; - - iagP = obgP; - accum = 0; - for (c = (2 * width)+1; c!=0; c--, iagP++) - accum += *iagP; - accumX = accum; - - /* MAIN SCAN ACROSS */ - /* iagP is already pointing at the next one to add. */ - for (c = (cols-2*width-1); c!=0; c--, obgP++, iagP++) - { - /* y(k) = y(k-1) + x(k+w) - x(k-w-1) */ - accum = accum + *iagP - *obgP; - *obgP = accum; - } - iagP = obgP-1; - - /* SHIFT & STORE */ - /* First the last output into the last w+1 entries. */ - accum = *iagP >> second_shifts; - obgP = &outImgPtr[(r+1)*cols+cols-1]; - for (c=width+1; c!=0; c--, obgP--) - *obgP = accum; - /* Then cols-2*width-2 more */ - iagP--; - for (c =(cols-2*width-2); c!=0; c--,iagP--,obgP--) - *obgP = *iagP >> second_shifts; - /* Then the first/final w+1 */ - /* accum = *oagP >> second_shifts;*/ - accum = accumX >> second_shifts; - for (c =width+1; c!=0; c--, obgP--) - *obgP = accum; - } - - - - /* FILTER DOWN COLUMNS */ - /* Sum first 2*height+1 rows */ - memset( outImgPtr, '\0', cols*sizeof(Glace_BigGray) ); - iagP = obgP = outImgPtr; /* iagP only for compiler warnings */ - - for (c = cols, obgP=outImgPtr; - c!=0; c--, obgP++) - { - accum = 0; - for (r=(2 * height+1), iagP=obgP+cols; - r!=0; r--) - { - accum += *iagP; - iagP+=cols; - } - *obgP = accum; - } - iagP = &outImgPtr[(2*height+2)*cols]; - - - /* MAIN SCAN DOWN */ - /* iagP already points to next to add, obgP to in/output. */ - /* Just do one big loop instead of nesting. */ - oagP = outImgPtr; - for (k=(cols*(rows-2*height-1)); k!=0; k--, obgP++, oagP++, iagP++) - { - accum = *oagP + *iagP - *obgP; - /* y(k) = y(k-1) + x(k+w) - x(k-w-1) */ - *obgP = accum; - } - - /* STORE BY COPYING */ - /* First the last output into the last h entries. */ - for (r=height, obgP = &outImgPtr[(rows-1)*cols]; r!=0; - r--, obgP-=cols) - memcpy(obgP, oagP, - cols*sizeof(Glace_BigGray)); - /* middle section */ - memmove(&outImgPtr[height*cols], outImgPtr, - cols*(rows-2*height)*sizeof(Glace_BigGray) ); - /* and first/final rows */ - for (r=1; r 0; r--) - { - iagP = &outImgPtr[r*cols]; - oagP = &outImgPtr[(r+1)*cols]; - *oagP = *iagP; - oagP++; iagP++; - for (c = 1, - ibgP = &outImgPtr[(r-1)*cols]+1, - hwgP = &hBiasArray[cols*r], vwgP = &vBiasArray[cols*r]; - c<(cols-1); - c++, iagP++, oagP++, ibgP++, hwgP++, vwgP++) - { - /* Do everything *2048 */ - accum = ((Glace_BigGray) *iagP)<<10; - wgt = (((Glace_BigGray) *hwgP)<<1)+1; /* 1<= wgt <=511 */ - accum += wgt* *(iagP+1); - accum += (512-wgt)* *(iagP-1); - wgt = (((Glace_BigGray) *vwgP)<<1)+1; - accum += *ibgP * (512-wgt); - accum += *oagP * wgt; - *oagP = (accum >> 11); - } - *oagP = *iagP; - } - memcpy( &outImgPtr[cols], outImgPtr, cols*sizeof(Glace_MidGray)); - } else { - for (r = 1; r < (rows-1); r++) - { - iagP = &outImgPtr[(r+1)*cols]; - oagP = &outImgPtr[r*cols]; - *oagP = *iagP; - oagP++; iagP++; - for (c = 1, ibgP = &outImgPtr[(r+2)*cols]+1, - hwgP = &hBiasArray[cols*r], vwgP = &vBiasArray[cols*r]; - c<(cols-1); - c++, iagP++, oagP++, ibgP++, hwgP++, vwgP++) - { - /* Do everything *2048 */ - accum = ((Glace_BigGray) *iagP)<<10; - - wgt = (((Glace_BigGray) *hwgP)<<1)+1; /* 1<= wgt <=511 */ - accum += wgt* *(iagP+1); - accum += (512-wgt)* *(iagP-1); - wgt = (((Glace_BigGray) *vwgP)<<1)+1; - accum += *oagP * (512-wgt); - accum += *ibgP * wgt; - - *oagP = (accum >> 11); - } - *oagP = *iagP; - } - memcpy( &outImgPtr[(rows-1)*cols], - &outImgPtr[rows*cols], cols*sizeof(Glace_MidGray)); - } - } - -/* If number of passes is odd, image is left in shifted position.*/ - if (numPasses%2) - for (r = 0; r < rows; r++) - memcpy(&outImgPtr[r*cols], - &outImgPtr[(r+1)*cols], cols*sizeof(Glace_MidGray)); -} diff --git a/plug-ins/gimp_ace/glace.h b/plug-ins/gimp_ace/glace.h deleted file mode 100644 index 657923e94a..0000000000 --- a/plug-ins/gimp_ace/glace.h +++ /dev/null @@ -1,987 +0,0 @@ -/* $Id$ */ -/* :PREAMBLE: Glace.h - * - * Main header file for GLACE programs: - * NOTE: This is designed to load your program-specific headers for you - * - * For PBMPLUS and Tk/Tcl-based and GIMP versions - * #define GLACE_PNM or GLACE_TK or GLACE_GIMP before inclusion - * Automatically includes pgm.h or tk.h, or gimp headers as appropriate. - */ - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. See the file COPYING for details. - * - */ - -/* :DEFS AND SUCH: - */ - -#ifdef _PGM_H_ -#error DO NOT LOAD PBMPLUS (OR DERIVATIVE) FIRST -#endif - -#ifndef _GLACE_H_ -#define _GLACE_H_ - - -#ifndef BUFSIZ -#include -#endif - - - -#ifdef GLACE_PNM -/* pbmpluss.h deals with WATCOMC */ -# include "pbmpluss.h" -# include "pnm.h" -#endif - -#ifdef __WATCOMC__ -# define __WIN32__ -/*# define DllEntryPoint LibMain*/ -# include "glace.wcp" -#endif - -#ifdef GLACE_TK -# include "tk.h" -#endif - -#ifdef GLACE_GIMP -# include -# include -#endif - -/* This isn't really the right place for this, but... */ -#define BYTE_SPLIT(x,hb,lb) \ -lb = (Glace_Gray) (((unsigned int) (x+0.5)) & 0377);\ -hb = (Glace_Gray) ((((unsigned int) (x+0.5))>>8)) -/*lb = ((Glace_Gray) x);*/ -/*lb = ((unsigned int) x) - (hb<<8);*/ - - -/* - * There is also an internal header file glaceInt.h - */ - -#ifdef _OVAR_ -#define GLACE_OVAR(A) A __attribute__ ((unused)) -#else -#define GLACE_OVAR(A) A -#endif - -/**********************************************************************/ - -/* :*** Simple Things ***: - * - * :+++++++: #defines - */ -#define GLACE_PI ((double) 3.141592653589793) - -#define GLACE_TRUE 1 -#define GLACE_FALSE 0 -#define GLACE_BOOL int - -/* avoiding 0, 1, etc. */ -#define GLACE_ERROR 99 -#define GLACE_OK 0 - -#define GLACE_STRMAX 100 - -#define GLACE_MIDGRAY ((float) 127.5) -#define GLACE_MAXMAXGRAY 255 - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: Grays and colours typedefs - */ - - -typedef signed long Glace_BigGray; -typedef signed short Glace_MidGray; -#ifndef _PGM_H_ -typedef unsigned char Glace_Gray; - - - -#undef max -#define max(a,b) ((a) > (b) ? (a) : (b)) -#undef min -#define min(a,b) ((a) < (b) ? (a) : (b)) -#undef abs -#define abs(a) ((a) >= 0 ? (a) : -(a)) -#undef odd -#define odd(n) ((n) & 1) - -#else - -#define Glace_Gray gray - -#endif - - - -typedef struct - { - Glace_Gray r, g, b; - } Glace_Pixel; -#define GLACE_GETR(p) ((p).r) -#define GLACE_GETG(p) ((p).g) -#define GLACE_GETB(p) ((p).b) - -/************* added definitions *****************/ -#define GLACE_PUTR(p,red) ((p).r = (red)) -#define GLACE_PUTG(p,grn) ((p).g = (grn)) -#define GLACE_PUTB(p,blu) ((p).b = (blu)) -/**************************************************/ - -#define GLACE_ASSIGN(p,red,grn,blu) do { (p).r = (red); (p).g = (grn); (p).b = (blu); } while ( 0 ) - - - -/**********************************************************************/ - -/* :*** Structures ***: - * - * :+++++++: Glace_WData. Wrapper data structure (dummy typedef) - */ - -typedef char *Glace_WData; -/*typedef char Glace_WErrorInfo;*/ - - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: Glace_ImgArrays. Image arrays structure - * - * This is a structure that holds the pointers and defining parameters of - * the image arrays: input, reference, filtering, accumulation, and - * temporary. The output is done row-by-row. - */ - -/* -typedef enum { - GLACE_TMP_IMG_BIG, GLACE_TMP_IMG_MID -} Glace_TmpImgGraySize; -*/ - -typedef char *Glace_ImageHandle; - -/* - * Structure definition - */ - -typedef struct Glace_ImgArrays { - Glace_ImageHandle inputImageHandle, refImageHandle, - ddHImageHandle, ddVImageHandle, outputImageHandle; - - Glace_Gray *ddHImgPtr, - *ddVImgPtr; - - long inImgSize; /* Allocated size for input image, - taking into account * pixel planes passed on (1 to 5) */ - Glace_Gray *inImgPtr; - /*long inImgBSize;*/ /* for input gray bytes. 0: not alloc or use inImgPtr - * 0: not alloc or use inImgPtr - * *2 if LB+HB (ie doublep) - */ - Glace_Gray *inImgHBPtr; - Glace_Gray *inImgLBPtr; - - /* Some color methods take RGB, others take Yxy. */ - /* (The C is to remind you that x,y are coordinates in color space, - and not cartesian pixel coordinates.) */ - - Glace_Gray *inImgCxPtr; - Glace_Gray *inImgCyPtr; - Glace_Gray *inImgCYMaxPtr; - - Glace_Gray *inImgRPtr; - Glace_Gray *inImgGPtr; - Glace_Gray *inImgBPtr; - - int pixelSize; - int pixelBytePad; /* Set by Glace_WPutImgRowStart or before */ - - long refImgSize; - Glace_Gray *refImgPtr; - /* long refImgBSize;*/ - Glace_Gray *refImgHBPtr; - Glace_Gray *refImgLBPtr; - - - long accImgSize; - Glace_MidGray *accImgPtr; - Glace_MidGray *outAccImgPtr; /* a dummy pointer that refers to the - accumulator array to be output. This - can be other than the true accumulator - if a diagnostic image is being - generated. */ - int cols; - int rows; - long putImgSize; /* The wrapper can use this how it likes, eg size - of a single row or of a whole output image. */ - Glace_Gray *putImgRowPtr; - - long tmpImgSize; - /* basically internal; in size_t. If zero, then tmp is unallocated. */ - - int tmpImgRPad, tmpImgCPad; /*added to rows and cols*/ - /*Glace_TmpImgGraySize tmpImgGraySize;*/ - size_t tmpImgGraySize; - - char *tmpImgPtr; - /* Glace_BigGray *bgTmpImgPtr; - Glace_MidGray *mgTmpImgPtr;*/ - - Glace_WData wData; -} Glace_ImgArrays; - - - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: Glace_CfgInfo. Configuration information - */ - -#define GLACE_CFG_DEFAULT_NUM_TERMS 240 -#define GLACE_CFG_DEFAULT_A_WITH_F GLACE_NONE -/*#define GLACE_CFG_DEFAULT_A_WITH_F GLACE_LOCALMEAN*/ -#define GLACE_TOL_DOUBLEP 0.00001 -#define GLACE_TOL_SINGLEP 0.0025 - - -/* Default value is indicated by zero throughout */ -typedef enum { - GLACE_AUTO = 0, GLACE_MANUAL -} Glace_Modes; - -typedef enum { - GLACE_MISSING = 0, GLACE_LISTFILE, GLACE_COMMANDLINE -} Glace_DimSrcs; - -typedef enum { - GLACE_NORMAL = 0, GLACE_COSRAW, GLACE_COSFILT, GLACE_SINRAW, GLACE_SINFILT -} Glace_OutputMethods; - -typedef enum { - GLACE_STANDARD = 0, GLACE_SERIES, GLACE_FACTOR -} Glace_HeTypes; - -typedef enum { - GLACE_CC = 0, GLACE_CG, GLACE_GG -} Glace_ChromeTypes; - -typedef enum { - GLACE_WINDOW = 0, GLACE_DIRDIFF -} Glace_FiltMethods; - -typedef enum { - GLACE_INPUT = 0, GLACE_SEPARATE -} Glace_RefImageModes; - -typedef enum { - GLACE_NONE = 0, GLACE_ZEROINPUT, GLACE_LOCALMEAN -} Glace_AddbackTypes; - -typedef enum { - GLACE_PNM_VER = 0, GLACE_TK_VER, GLACE_GIMP_VER -} Glace_WrapTypes; - -typedef enum -{ - GLACE_COLOR_Yxy = 0, GLACE_COLOR_LUMIN -} Glace_ColorMethods; - -typedef struct Glace_CfgInfo -{ - FILE *wListfile, *dListfile, *sListfile; - - Glace_OutputMethods outputMethod; - int numTerms, firstTerm, termsSerialised; - unsigned int activeTerms; - GLACE_BOOL verbose; - GLACE_BOOL hammingCwind; - GLACE_BOOL gaussCwind; - GLACE_BOOL addbackCwind; - GLACE_BOOL doClip; - - GLACE_BOOL doublep; - GLACE_BOOL doubleout; - Glace_ChromeTypes chrome; - - - Glace_HeTypes heType; - - long currentSeriesAllocation; - double *heseriesSeries, *cwindSeries; - double *addbackSeries; - int *windCWSeries, *windCHSeries, *windSWSeries, *windSHSeries; - - Glace_FiltMethods filtMethod; - int windBaseW, windBaseH; - float addbackFactor; - /* if dd filtering is used, then we remap arrays */ -#define GLACE_CFG_COSDIM windCWSeries -#define GLACE_CFG_COSBV windCHSeries -#define GLACE_CFG_SINDIM windSWSeries -#define GLACE_CFG_SINBV windSHSeries - - - Glace_DimSrcs dimensionSrc; - - Glace_Modes prescaleMode; - Glace_Modes inoffsetMode; - Glace_Modes addbackMode; - Glace_AddbackTypes addbackType; - float passthruFactor; - float prescaleVal; - float heFactor; - float inoffsetVal; - float gaussCwindWidth; - float coeffTol; - - Glace_ColorMethods colorMethod; - - Glace_RefImageModes refimageMode; - - GLACE_BOOL genCFunc; - float cFuncMin, cFuncMax; - int cFuncPoints; - - Glace_WData wData; - Glace_WrapTypes wrapType; - GLACE_BOOL plainGlace; -} Glace_CfgInfo; - - - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: Glace_TableInfo. Term-wise and table information - */ - -typedef enum { - GLACE_SIN, GLACE_COS -} Glace_TermTypes; - -typedef double Glace_FpSeries; - -typedef struct Glace_TableInfo -{ - int filtShifts, notFiltShifts; - float filtFactor, notFiltFactor; - Glace_TermTypes termType; /* which one is being filtered */ - unsigned int termNum; - - /* long *notFiltTable, *filtTable;*/ - long *seriesTable; - int accShift; - - Glace_FpSeries *seriesAH, *seriesAL, *seriesBH, *seriesBL; - - float abFactor, abShifts; - - double waveFactor; - - Glace_WData wData; -} Glace_TableInfo; - - - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: Glace_ClientData. Umbrella clientdata - */ - - -typedef struct Glace_ClientData -{ - Glace_WData wData; - Glace_CfgInfo *cfgInfoPtr; - Glace_TableInfo *tableInfoPtr; - Glace_ImgArrays *imgArraysPtr; -} Glace_ClientData; - - - -#if defined(GLACE_IMG) -#undef GLACE_IMG -#endif -#define GLACE_IMG(A) (imgArraysPtr->A) - - - -#if defined(GLACE_TRM) -#undef GLACE_TRM -#endif -#define GLACE_TRM(A) (tableInfoPtr->A) - - - -#if defined(GLACE_CFG) -#undef GLACE_CFG -#endif -#define GLACE_CFG(A) (cfgInfoPtr->A) - - - -#if defined(GLACE_CDATA) -#undef GLACE_CDATA -#endif -#define GLACE_CDATA(A) (((Glace_ClientData *) clientData)->A) - - - - -/**********************************************************************/ - -/* :*** Procedures ***: - * - * :+++++++: Dummy tests - * - * These were originally used as dummy operations (a kind of NOP) - * that used a variable or structure pointer such that the error - * should never occur. This keeps the compiler happy. Pointers - * to structures are often unused in some versions, or if they are - * included for future expansion. - * - * Note that these tests could be used in anger, but that the message - * would be non-specific. - */ - -/* - -#define GLACE_NULL_TEST(wData,ptr) if (ptr==NULL) \ - Glace_WError( wData,"Pointer " \ - "null test failed"); -#define GLACE_TEST(wData,T) if (T) Glace_WError( wData,\ - "Test failure"); -*/ - - -#define GLACE_ERROR_EXIT(wData) if (Glace_WIsError(wData)) \ - exit(1); -#define GLACE_ERROR_CHECK(wData) if (Glace_WIsError(wData)) \ - return; -#define GLACE_ERROR_VALUE(wData) if (Glace_WIsError(wData)) \ - return Glace_WErrorValue( wData ); - - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: Cfg. Configuration information - */ - -/* - * CONFIG - * - */ - -void -Glace_CfgInit ( - Glace_CfgInfo *cfgInfoPtr); - -void -Glace_CfgAllocSeriesVectors ( - Glace_CfgInfo *cfgInfoPtr - ); - -void -Glace_CfgBeginToHeseries ( - Glace_CfgInfo *cfgInfoPtr - ); - -void -Glace_CfgHeseriesToAddback ( - Glace_CfgInfo *cfgInfoPtr - ); - -void -Glace_CfgAddbackToEnd ( - Glace_CfgInfo *cfgInfoPtr - ); - -void -Glace_CfgFreeSeriesVectors ( - Glace_CfgInfo *cfgInfoPtr - ); - - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: W. Wrapper-specifics - * - * The following are implemented differently for each wrapper. - * PGM system: glaceP.c and - * TK/TCL system: glaceT.c - */ - - - - -/**********************************************************************/ -/* - * WRAPPER: - * - */ - - -Glace_WData -Glace_WDataAlloc(); - -void -Glace_WInit( - Glace_WData wData - ); - -Glace_WrapTypes -Glace_WWrapTell(); - -void -Glace_WMessage( - Glace_WData wData, char* messageStr ); - -int /* Sets error and returns error flag (but may exit) */ -Glace_WError( - Glace_WData wData, - char* argErrStr - ); - -int /* Returns error flag */ -Glace_WErrorValue( - Glace_WData wData - ); - -int /* Returns boolean */ -Glace_WIsError( - Glace_WData wData - ); - - - -/*----------*/ -void -Glace_WPutImgStart( - Glace_WData wData, - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr - ); -void -Glace_WPutImgRowStart( - Glace_WData wData, - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr, - int row - ); -void -Glace_WPutImgRowFinish( - Glace_WData wData, - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr, - int row - ); -void -Glace_WPutImgFinish( - Glace_WData wData, - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr - ); -int -Glace_WKeyMatch( - char* str, - char* keyWord, - int minChars - ); - -void -Glace_WUsage( - Glace_WData wData, - char* usage -); - -void -Glace_WOpenImage( - Glace_WData wData, - Glace_CfgInfo *cfgInfoPtr, - char *name, - Glace_ImageHandle *handlePtr -); - - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: Term-wise and table info - */ - - -/* TABLE INFO - * - * This supplies the lookup tables and other related information that is - * specific to the current term being processed. - */ - - -void -Glace_SetForTerm ( - Glace_TableInfo *tableInfoPtr, - int k, - Glace_TermTypes type /* which one is being filtered */ - ); - -void -Glace_TermlyReport ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr -); - -void -Glace_AllocTables ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr - ); - -void -Glace_FreeTables ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr - ); - -void -Glace_SetTables ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr - ); - -void -Glace_FillTableForFilt ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - float scale - ); - -void -Glace_FillTableForNotFilt ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr - ); - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: CFunc. Cumulation function - */ - -int -Glace_CFuncGen ( - Glace_CfgInfo *cfgInfoPtr - ); -float -Glace_CFuncPoint ( - Glace_CfgInfo *cfgInfoPtr, - float x - ); -float -Glace_CFuncIdealPoint ( - Glace_CfgInfo *cfgInfoPtr, - float x - ); - - - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: Allocation and reallocation - */ - -/* - * Etc. - */ -/**************************************************************/ -char * -Glace_CallocReallocFree( - void *p, - long *nObjPtr, - long newNObj, - size_t size, - float minBound -); - -void -Glace_FreeImgArrays ( - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr - ); - -void -Glace_SetTmpImg ( - Glace_ImgArrays *imgArraysPtr, - size_t graySize, - int rowPad, - int colPad - ); - -void -Glace_DefaultTmpImg ( - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr - ); -void -Glace_AllocImgArrays ( - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr - ); - -void -Glace_AllocInputImgArrays ( - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr - ); - -void -Glace_FreeInputImgArrays ( - Glace_ImgArrays *imgArraysPtr - ); - - -Glace_ClientData * -Glace_AllocClientData (); - -void -Glace_FreeClientData ( - Glace_ClientData *clientData - ); - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: Process procedures - */ - -void -Glace_Process ( - Glace_WData wData, - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - Glace_ImgArrays *imgArraysPtr - ); - -/* -void -GlaceArgError ( - const char *message, - char *argv[], - int numArgs, - int problemArg - ); - */ -int -Glace_ParseArgs ( - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr, - int argc, - char *argv[]); - - -void -Glace_WindChk( - Glace_CfgInfo *cfgInfoPtr, - int rows, - int cols - ); - -int -Glace_Output ( - Glace_WData wData, - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr - ); -void -Glace_InitAccIm ( - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr); - -void -Glace_GenGen ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - Glace_ImgArrays *imgArraysPtr); - -void -Glace_DiagGen ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - Glace_ImgArrays *imgArraysPtr - ); -void -Glace_DiagOutput ( - Glace_WData wData, - Glace_CfgInfo *cfgInfoPtr, - Glace_ImgArrays *imgArraysPtr - ); - - - -void -Glace_CallFilt ( - Glace_CfgInfo *cfgInfoPtr, - Glace_TableInfo *tableInfoPtr, - Glace_ImgArrays *imgArraysPtr); - - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: Filt. Filtering - */ - -/**********************************************************************/ -/* - * FILT - * - * Image array filtering - * Implemented in glaceFilt.c - */ - -void -Glace_FiltWind( - Glace_CfgInfo *cfgInfoPtr, - Glace_Gray * inImgHBPtr, - Glace_Gray * inImgLBPtr, Glace_BigGray * outImgPtr, - /*signed long *lTable,*/ - int cols, int rows, - Glace_TableInfo *tableInfoPtr, - int width, int height - ); - -void -Glace_FiltDD( - Glace_CfgInfo *cfgInfoPtr, - Glace_Gray * inImgPtr, Glace_MidGray * outImgPtr, - /*signed long *lTable,*/ - int cols, int rows, - Glace_TableInfo *tableInfoPtr, - Glace_Gray *hBiasArray, Glace_Gray *vBiasArray, - int numPasses - ); - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: Heseries. Generating signed power-law series - */ - -/**********************************************************************/ -/* - * HESERIES - * - * HE Fourier series generation - * Implemented in glaceHeseries.c - */ - -/* Internal structure. - * - * A dummy definition is used for this structure. - * The caller must preallocate it. - */ - -/* An unreasonable value for the series, used to flag errors */ -#define GLACE_HESERIES_ERRORFLAG (-1000000.0) - -#define GLACE_HESERIES_RESERVE 100 -typedef struct Glace_HeseriesInfo -{ -char dummy[GLACE_HESERIES_RESERVE]; -} Glace_HeseriesInfo; - -void -Glace_HeseriesInit (Glace_HeseriesInfo *heseriesPtr, float heFactor); -double -Glace_HeseriesVal (Glace_HeseriesInfo *heseriesPtr, int k); - - - -/**********************************************************************/ - -/* :*** Wrapper specific data ***: - */ - -# if defined(WRAPPER) -# undef WRAPPER -# endif - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: GLACE_PNM - */ - -#ifdef GLACE_PNM -# -typedef struct GlacePnmData -{ - Glace_Gray **ddHImgPtrPtr, **ddVImgPtrPtr; - Glace_Gray **inImgPtrPtr; - Glace_Gray **refImgPtrPtr; - - int errorValue; -} GlacePnmData; -# -# -# define WRAPPER(A) (((GlacePnmData *) wData)->A) -#endif - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: GLACE_GIMP - */ - -#ifdef GLACE_GIMP -# -typedef struct GlaceGimpData -{ - /* Glace_Gray **ddHImgPtrPtr, **ddVImgPtrPtr; */ - /* Glace_Gray **inImgPtrPtr; / No, I don't have a clue as to how */ - /* Glace_Gray **refImgPtrPtr; / much of this is used, or where. [kmt] */ - /* [jas]: These are used in PNM to remember pointers to arrays */ - - Glace_Gray *dest_row; - - /* Is this a good place to store these things? */ - /* [jas]: yes, this is exactly the place! */ - GPixelRgn dest_rgn_ptr; - GDrawable *drawable_ptr; - gint32 gimp_x0, gimp_y0; - - guchar *gimpImgPtr; - - int errorValue; -} GlaceGimpData; -# -# -# define WRAPPER(A) (((GlaceGimpData *) wData)->A) -#endif - -/*--------------------------------------------------------------------*/ -/* - * :+++++++: GLACE_TK - */ - - -#ifdef GLACE_TK -# -typedef struct GlaceTkData -{ - Tk_PhotoImageBlock outputImageBlock; - - Glace_Gray *outImgPtr; - - Tcl_Interp *interp; - int errorValue; -} GlaceTkData; -# -# -# define WRAPPER(A) (((GlaceTkData *) wData)->A) -# define INTERP(A) ((GlaceTkData *) A)->interp -#endif - - -#endif diff --git a/plug-ins/gimp_ace/glaceG.c b/plug-ins/gimp_ace/glaceG.c deleted file mode 100644 index 7753674159..0000000000 --- a/plug-ins/gimp_ace/glaceG.c +++ /dev/null @@ -1,325 +0,0 @@ -/* :PREAMBLE: GlaceG.c - * - * Wrapper-specific Code: - * GIMP plug-in version - * - * Based on glaceT.c and glaceP.c by J.Alex Stark - * g_ified by Kevin M. Turner - */ - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. See the file COPYING for details. - * - */ - -/* :HEADERS: - */ -#ifndef GLACE_GIMP -# define GLACE_GIMP -#endif - -#include "glaceInt.h" - -#include /* for tolower in keymatch */ - -/* Other things we're implementing - * Included first, because glace.h needs to know about it. - */ - -/* :*** Internal Functions ***: - * GlaceWMalloc,Realloc,Calloc, and Free - * have been implemented as defines in an #ifdef block in glaceInt.h - * Ugly, but true. - */ - -/**************************************************************/ - -/* :*** Errors and Messages ***: - - * :FUNCTION: Glace_WError - */ -int /* Sets error and returns error flag (but may exit) */ -Glace_WError ( - Glace_WData wData, - char *argErrStr -) -{ - if (wData == NULL) - g_warning ("Fatal error (error rountine called" - " with invalid package data structure."); - WRAPPER (errorValue) = GLACE_ERROR; - - g_warning (argErrStr); - - return GLACE_ERROR; -} - -/* - * :FUNCTION: Glace_WErrorValue - */ -int /* Returns error flag */ -Glace_WErrorValue ( - Glace_WData wData -) -{ - return WRAPPER (errorValue); -} - - - -/* - * :FUNCTION: Glace_WIsError - */ -int /* Returns boolean */ -Glace_WIsError ( - Glace_WData wData -) -{ - return (WRAPPER (errorValue) == GLACE_ERROR); -} - - - -/* - * :FUNCTION: Glace_WMessage - */ -void -Glace_WMessage ( - GLACE_OVAR(Glace_WData wData), - char *messageStr) -{ - fprintf (stderr, "%s", messageStr); -} - - -/**************************************************************/ -/* :*** Wrapper-specific Setup ***: - - * :FUNCTION: Glace_WInit - */ -void -Glace_WInit ( - GLACE_OVAR(Glace_WData wData)) -{ -#ifdef __EMX__ - _fsetmode (stdin, "b"); - _fsetmode (stdout, "b"); -#endif -} - - - -/**************************************************************/ -/* - * :FUNCTION: Glace_WWrapTell - */ -Glace_WrapTypes -Glace_WWrapTell() -{ - return GLACE_GIMP_VER; -} - -/**************************************************************/ -/* - * :FUNCTION: Glace_WDataAlloc - */ -Glace_WData -Glace_WDataAlloc () -{ - return (Glace_WData) GlaceWMalloc (sizeof (GlaceGimpData)); -} - - - -/* :*** Argument Parsing and Warning ***: - - * :FUNCTION: Glace_WKeyMatch - * - * NB This is an independent rewrite of PBMPLUS routine, - * just to be sure about copyright issues. [Alex] - * - * (Probably not necessary for GIMP version. Feel free to substitute - * pm_keymatch back in...) [kmt] - */ -int -Glace_WKeyMatch( - char* str, - char* keyword, - int minchars - ) -{ - int i, slen; - - slen = strlen(str); - - if (slen < minchars) - return 0; - - else if (slen > (int) strlen(keyword)) - return 0; - - else - for (i=0; ibpp; - -} - - -/**************************************************************/ - - -/* - * :FUNCTION: Glace_WPutImgFinish - */ -void -Glace_WPutImgFinish ( - GLACE_OVAR(Glace_WData wData), - GLACE_OVAR(Glace_CfgInfo *cfgInfoPtr), - GLACE_OVAR(Glace_ImgArrays * imgArraysPtr) -) -{ - /* g_print("*** Glace_WPutImgFinish coming through. ***\n"); */ - - - /* We could do something like this to write the entire image - at one time instead of row by row. */ - - gimp_pixel_rgn_set_rect (&WRAPPER(dest_rgn_ptr), - WRAPPER(gimpImgPtr), - WRAPPER(gimp_x0), WRAPPER(gimp_y0), - GLACE_IMG(cols), GLACE_IMG(rows)); - - gimp_drawable_flush (WRAPPER(drawable_ptr)); - gimp_drawable_merge_shadow (WRAPPER(drawable_ptr)->id, TRUE); - gimp_drawable_update (WRAPPER(drawable_ptr)->id, - WRAPPER(gimp_x0), WRAPPER(gimp_y0), - GLACE_IMG(cols), GLACE_IMG(rows)); - gimp_drawable_detach (WRAPPER(drawable_ptr)); - gimp_displays_flush(); -} - -/**************************************************************/ - diff --git a/plug-ins/gimp_ace/glaceInt.h b/plug-ins/gimp_ace/glaceInt.h deleted file mode 100644 index c6d55123b1..0000000000 --- a/plug-ins/gimp_ace/glaceInt.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. See the file COPYING for details. - * - */ - -#include "glace.h" - -/* GLACE_GIMP implements these as macros, not functions. */ -/* But this is wrapper-specific stuff, so that should be okay, right? */ -/* - * The alternative would be just to #ifdef them out and define macros - * in glaceG.c [jas]. - */ -#ifdef GLACE_GIMP -#define GlaceWMalloc(size) g_malloc(size) -#define GlaceWRealloc(p, size) g_realloc(p, size) -#define GlaceWCalloc(nObj, size) g_malloc0((size) * (nObj)) -#define GlaceWFree(ptr) g_free(ptr) -#else -void *GlaceWMalloc(size_t size); -void *GlaceWRealloc(void *p,size_t size); -void *GlaceWCalloc(size_t nObj, size_t size); -void GlaceWFree(void *p); -#endif - -#if 0 -#if __STDC__ -#define ARGS(alist) alist -#else /*__STDC__*/ -#define ARGS(alist) () -#define const -#endif /*__STDC__*/ -#endif - - - -/* - * For glaceCfg.c - */ - -#define HLB 15 -#define BIG_TMP_BITS 31 -#define MID_TMP_BITS 15 -#define ACC_BITS 14 -#define OUT_BITS 8 -#define AFT_FILTVAL ldexp(255.0, BIG_TMP_BITS-8) -#define MAFT_FILTVAL ldexp(255.0, MID_TMP_BITS-8) -#define BSHIFT (BIG_TMP_BITS-HLB) -#define MSHIFT (MID_TMP_BITS-HLB) -#define NOT_FILTVAL ldexp(255.0, HLB-8-1) -#define FORCE_NO_BIT_SHIFT (-1000) -#define MAX_BIT_SHIFT (32) - -#define MAX_MESSAGE_LEN 150