gimp/plug-ins/common/depth-merge.c

1153 lines
39 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
1997-11-25 06:05:25 +08:00
*
* Depth Merge -- Combine two image layers via corresponding depth maps
* Copyright (C) 1997, 1998 Sean Cier (scier@PostHorizon.com)
1997-11-25 06:05:25 +08:00
*
* This program is free software: you can redistribute it and/or modify
1997-11-25 06:05:25 +08:00
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
1997-11-25 06:05:25 +08:00
* (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.
*/
/* Version 1.0.0: (14 August 1998)
* Math optimizations, miscellaneous speedups
*
* Version 0.1: (6 July 1997)
1997-11-25 06:05:25 +08:00
* Initial Release
*/
#include "config.h"
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
1997-11-25 06:05:25 +08:00
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
#include "libgimp/stdplugins-intl.h"
1997-11-25 06:05:25 +08:00
1997-11-25 06:05:25 +08:00
#define DEBUG
#ifndef LERP
#define LERP(frac,a,b) ((frac)*(b) + (1-(frac))*(a))
#endif
#define MUL255(i) ((i)*256 - (i))
#define DIV255(i) (((i) + (i)/256 + 1) / 256)
1997-11-25 06:05:25 +08:00
#define PLUG_IN_PROC "plug-in-depth-merge"
#define PLUG_IN_VERSION "August 1998"
#define PLUG_IN_BINARY "depth-merge"
#define PLUG_IN_ROLE "gimp-depth-merge"
1997-11-25 06:05:25 +08:00
#define PREVIEW_SIZE 256
1997-11-25 06:05:25 +08:00
1997-11-25 06:05:25 +08:00
/* ----- DepthMerge ----- */
struct _DepthMerge;
typedef struct _DepthMergeInterface
{
gboolean active;
1997-11-25 06:05:25 +08:00
GtkWidget *dialog;
GtkWidget *preview;
gint previewWidth;
gint previewHeight;
1997-11-25 06:05:25 +08:00
guchar *previewSource1;
guchar *previewSource2;
guchar *previewDepthMap1;
guchar *previewDepthMap2;
1997-11-25 06:05:25 +08:00
} DepthMergeInterface;
typedef struct _DepthMergeParams
{
gint32 result_id;
gint32 source1_id;
gint32 source2_id;
gint32 depthMap1_id;
gint32 depthMap2_id;
gfloat overlap;
gfloat offset;
gfloat scale1;
gfloat scale2;
1997-11-25 06:05:25 +08:00
} DepthMergeParams;
typedef struct _DepthMerge
{
1997-11-25 06:05:25 +08:00
DepthMergeInterface *interface;
DepthMergeParams params;
GimpDrawable *resultDrawable;
GimpDrawable *source1Drawable;
GimpDrawable *source2Drawable;
GimpDrawable *depthMap1Drawable;
GimpDrawable *depthMap2Drawable;
gint selectionX;
gint selectionY;
gint selectionWidth;
gint selectionHeight;
gint resultHasAlpha;
1997-11-25 06:05:25 +08:00
} DepthMerge;
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
typedef struct _Merge Merge;
typedef struct _MergeClass MergeClass;
struct _Merge
{
GimpPlugIn parent_instance;
1997-11-25 06:05:25 +08:00
};
struct _MergeClass
{
GimpPlugInClass parent_class;
};
#define MERGE_TYPE (merge_get_type ())
#define MERGE (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MERGE_TYPE, Merge))
GType merge_get_type (void) G_GNUC_CONST;
static GList * merge_query_procedures (GimpPlugIn *plug_in);
static GimpProcedure * merge_create_procedure (GimpPlugIn *plug_in,
const gchar *name);
static GimpValueArray * merge_run (GimpProcedure *procedure,
GimpRunMode run_mode,
GimpImage *image,
gint n_drawables,
GimpDrawable **drawables,
const GimpValueArray *args,
gpointer run_data);
static void DepthMerge_initParams (DepthMerge *dm);
static gboolean DepthMerge_construct (DepthMerge *dm);
static void DepthMerge_destroy (DepthMerge *dm);
static gint32 DepthMerge_execute (DepthMerge *dm);
static void DepthMerge_executeRegion (DepthMerge *dm,
guchar *source1Row,
guchar *source2Row,
guchar *depthMap1Row,
guchar *depthMap2Row,
guchar *resultRow,
gint length);
static gboolean DepthMerge_dialog (DepthMerge *dm);
static void DepthMerge_buildPreviewSourceImage (DepthMerge *dm);
static void DepthMerge_updatePreview (DepthMerge *dm);
static gboolean dm_constraint (GimpImage *image,
GimpItem *item,
gpointer data);
static void dialogSource1ChangedCallback (GtkWidget *widget,
DepthMerge *dm);
static void dialogSource2ChangedCallback (GtkWidget *widget,
DepthMerge *dm);
static void dialogDepthMap1ChangedCallback (GtkWidget *widget,
DepthMerge *dm);
static void dialogDepthMap2ChangedCallback (GtkWidget *widget,
DepthMerge *dm);
static void dialogValueScaleUpdateCallback (GimpLabelSpin *scale,
gfloat *value);
static void util_fillReducedBuffer (guchar *dest,
const Babl *dest_format,
gint destWidth,
gint destHeight,
GimpDrawable *sourceDrawable,
gint x0,
gint y0,
gint sourceWidth,
gint sourceHeight);
G_DEFINE_TYPE (Merge, merge, GIMP_TYPE_PLUG_IN)
GIMP_MAIN (MERGE_TYPE)
DEFINE_STD_SET_I18N
static void
merge_class_init (MergeClass *klass)
{
GimpPlugInClass *plug_in_class = GIMP_PLUG_IN_CLASS (klass);
plug_in_class->query_procedures = merge_query_procedures;
plug_in_class->create_procedure = merge_create_procedure;
plug_in_class->set_i18n = STD_SET_I18N;
1997-11-25 06:05:25 +08:00
}
static void
merge_init (Merge *merge)
{
}
static GList *
merge_query_procedures (GimpPlugIn *plug_in)
{
return g_list_append (NULL, g_strdup (PLUG_IN_PROC));
}
static GimpProcedure *
merge_create_procedure (GimpPlugIn *plug_in,
const gchar *name)
{
GimpProcedure *procedure = NULL;
if (! strcmp (name, PLUG_IN_PROC))
{
procedure = gimp_image_procedure_new (plug_in, name,
GIMP_PDB_PROC_TYPE_PLUGIN,
merge_run, NULL, NULL);
gimp_procedure_set_image_types (procedure, "RGB*, GRAY*");
gimp_procedure_set_sensitivity_mask (procedure,
GIMP_PROCEDURE_SENSITIVE_DRAWABLE);
gimp_procedure_set_menu_label (procedure, _("_Depth Merge..."));
gimp_procedure_add_menu_path (procedure, "<Image>/Filters/Combine");
gimp_procedure_set_documentation (procedure,
_("Combine two images using depth "
"maps (z-buffers)"),
"Taking as input two full-color, "
"full-alpha images and two "
"corresponding grayscale depth maps, "
"this plug-in combines the images based "
"on which is closer (has a lower depth "
"map value) at each point.",
name);
gimp_procedure_set_attribution (procedure,
"Sean Cier",
"Sean Cier",
PLUG_IN_VERSION);
GIMP_PROC_ARG_DRAWABLE (procedure, "source-1",
"Source 1",
"Source 1",
TRUE,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "source-2",
"Source 2",
"Source 2",
TRUE,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "depth-map-1",
"Depth map 1",
"Depth map 1",
TRUE,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "depth-map-2",
"Depth map 2",
"Depth map 2",
TRUE,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "overlap",
"Overlap",
"Overlap",
0, 2, 0,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "offset",
"Offset",
"Depth relative offset",
-1, 1, 0,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "scale-1",
"Scale 1",
"Depth relative scale 1",
-1, 1, 1,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "scale-2",
"Scale 2",
"Depth relative scale 2",
-1, 1, 1,
G_PARAM_READWRITE);
}
return procedure;
}
static GimpValueArray *
merge_run (GimpProcedure *procedure,
GimpRunMode run_mode,
GimpImage *image,
gint n_drawables,
GimpDrawable **drawables,
const GimpValueArray *args,
gpointer run_data)
{
GimpDrawable *drawable;
DepthMerge dm;
1997-11-25 06:05:25 +08:00
gegl_init (NULL, NULL);
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
if (n_drawables != 1)
{
GError *error = NULL;
g_set_error (&error, GIMP_PLUG_IN_ERROR, 0,
_("Procedure '%s' only works with one drawable."),
PLUG_IN_PROC);
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_CALLING_ERROR,
error);
}
else
{
drawable = drawables[0];
}
DepthMerge_initParams (&dm);
1997-11-25 06:05:25 +08:00
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
gimp_get_data (PLUG_IN_PROC, &dm.params);
dm.params.result_id = gimp_item_get_id (GIMP_ITEM (drawable));
if (! DepthMerge_construct (&dm))
{
gimp_procedure_new_return_values (procedure,
GIMP_PDB_SUCCESS,
NULL);
}
if (!DepthMerge_dialog (&dm))
{
gimp_procedure_new_return_values (procedure,
GIMP_PDB_CANCEL,
NULL);
}
1997-11-25 06:05:25 +08:00
break;
case GIMP_RUN_NONINTERACTIVE:
dm.params.result_id = gimp_item_get_id (GIMP_ITEM (drawable));
dm.params.source1_id = GIMP_VALUES_GET_DRAWABLE_ID (args, 0);
dm.params.source2_id = GIMP_VALUES_GET_DRAWABLE_ID (args, 1);
dm.params.depthMap1_id = GIMP_VALUES_GET_DRAWABLE_ID (args, 2);
dm.params.depthMap2_id = GIMP_VALUES_GET_DRAWABLE_ID (args, 3);
dm.params.overlap = GIMP_VALUES_GET_DOUBLE (args, 4);
dm.params.offset = GIMP_VALUES_GET_DOUBLE (args, 5);
dm.params.scale1 = GIMP_VALUES_GET_DOUBLE (args, 6);
dm.params.scale2 = GIMP_VALUES_GET_DOUBLE (args, 7);
if (! DepthMerge_construct (&dm))
{
gimp_procedure_new_return_values (procedure,
GIMP_PDB_SUCCESS,
NULL);
}
1997-11-25 06:05:25 +08:00
break;
case GIMP_RUN_WITH_LAST_VALS:
gimp_get_data (PLUG_IN_PROC, &dm.params);
if (!DepthMerge_construct (&dm))
{
gimp_procedure_new_return_values (procedure,
GIMP_PDB_SUCCESS,
NULL);
}
1997-11-25 06:05:25 +08:00
break;
}
if (! DepthMerge_execute (&dm))
{
gimp_procedure_new_return_values (procedure,
GIMP_PDB_EXECUTION_ERROR,
NULL);
}
else
{
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush ();
if (run_mode == GIMP_RUN_INTERACTIVE)
gimp_set_data (PLUG_IN_PROC, &dm.params, sizeof (DepthMergeParams));
}
DepthMerge_destroy (&dm);
1997-11-25 06:05:25 +08:00
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
1997-11-25 06:05:25 +08:00
}
/* ----- DepthMerge ----- */
static void
DepthMerge_initParams (DepthMerge *dm)
{
dm->params.result_id = -1;
dm->params.source1_id = -1;
dm->params.source2_id = -1;
dm->params.depthMap1_id = -1;
dm->params.depthMap2_id = -1;
dm->params.overlap = 0;
dm->params.offset = 0;
dm->params.scale1 = 1;
dm->params.scale2 = 1;
1997-11-25 06:05:25 +08:00
}
static gboolean
DepthMerge_construct (DepthMerge *dm)
{
1997-11-25 06:05:25 +08:00
dm->interface = NULL;
dm->resultDrawable = gimp_drawable_get_by_id (dm->params.result_id);
if (! gimp_drawable_mask_intersect (dm->resultDrawable,
&(dm->selectionX), &(dm->selectionY),
&(dm->selectionWidth),
&(dm->selectionHeight)))
{
return FALSE;
}
1997-11-25 06:05:25 +08:00
dm->resultHasAlpha = gimp_drawable_has_alpha (dm->resultDrawable);
dm->source1Drawable = gimp_drawable_get_by_id (dm->params.source1_id);
dm->source2Drawable = gimp_drawable_get_by_id (dm->params.source2_id);
dm->depthMap1Drawable = gimp_drawable_get_by_id (dm->params.depthMap1_id);
dm->depthMap2Drawable = gimp_drawable_get_by_id (dm->params.depthMap2_id);
dm->params.overlap = CLAMP (dm->params.overlap, 0, 2);
dm->params.offset = CLAMP (dm->params.offset, -1, 1);
dm->params.scale1 = CLAMP (dm->params.scale1, -1, 1);
dm->params.scale2 = CLAMP (dm->params.scale2, -1, 1);
return TRUE;
1997-11-25 06:05:25 +08:00
}
static void
DepthMerge_destroy (DepthMerge *dm)
{
if (dm->interface != NULL)
{
g_free (dm->interface->previewSource1);
g_free (dm->interface->previewSource2);
g_free (dm->interface->previewDepthMap1);
g_free (dm->interface->previewDepthMap2);
g_free (dm->interface);
}
1997-11-25 06:05:25 +08:00
}
static gint32
DepthMerge_execute (DepthMerge *dm)
{
int x, y;
GeglBuffer *source1_buffer = NULL;
GeglBuffer *source2_buffer = NULL;
GeglBuffer *depthMap1_buffer = NULL;
GeglBuffer *depthMap2_buffer = NULL;
GeglBuffer *result_buffer;
guchar *source1Row, *source2Row;
guchar *depthMap1Row, *depthMap2Row;
guchar *resultRow;
guchar *tempRow;
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
gimp_progress_init (_("Depth-merging"));
1997-11-25 06:05:25 +08:00
resultRow = g_new (guchar, dm->selectionWidth * 4);
source1Row = g_new (guchar, dm->selectionWidth * 4);
source2Row = g_new (guchar, dm->selectionWidth * 4);
depthMap1Row = g_new (guchar, dm->selectionWidth );
depthMap2Row = g_new (guchar, dm->selectionWidth );
tempRow = g_new (guchar, dm->selectionWidth * 4);
1997-11-25 06:05:25 +08:00
if (dm->source1Drawable)
{
source1_buffer = gimp_drawable_get_buffer (dm->source1Drawable);
1997-11-25 06:05:25 +08:00
}
else
{
for (x = 0; x < dm->selectionWidth; x++)
{
source1Row[4 * x ] = 0;
source1Row[4 * x + 1] = 0;
source1Row[4 * x + 2] = 0;
source1Row[4 * x + 3] = 255;
}
}
if (dm->source2Drawable)
{
source2_buffer = gimp_drawable_get_buffer (dm->source2Drawable);
1997-11-25 06:05:25 +08:00
}
else
{
for (x = 0; x < dm->selectionWidth; x++)
{
source2Row[4 * x ] = 0;
source2Row[4 * x + 1] = 0;
source2Row[4 * x + 2] = 0;
source2Row[4 * x + 3] = 255;
}
}
if (dm->depthMap1Drawable)
{
depthMap1_buffer = gimp_drawable_get_buffer (dm->depthMap1Drawable);
1997-11-25 06:05:25 +08:00
}
else
{
for (x = 0; x < dm->selectionWidth; x++)
{
depthMap1Row[x] = 0;
}
}
if (dm->depthMap2Drawable)
{
depthMap2_buffer = gimp_drawable_get_buffer (dm->depthMap2Drawable);
1997-11-25 06:05:25 +08:00
}
else
{
for (x = 0; x < dm->selectionWidth; x++)
{
depthMap2Row[x] = 0;
}
}
result_buffer = gimp_drawable_get_shadow_buffer (dm->resultDrawable);
1997-11-25 06:05:25 +08:00
for (y = dm->selectionY; y < (dm->selectionY + dm->selectionHeight); y++)
{
if (dm->source1Drawable)
{
gegl_buffer_get (source1_buffer,
GEGL_RECTANGLE (dm->selectionX, y,
dm->selectionWidth, 1), 1.0,
babl_format ("R'G'B'A u8"), source1Row,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
}
if (dm->source2Drawable)
{
gegl_buffer_get (source2_buffer,
GEGL_RECTANGLE (dm->selectionX, y,
dm->selectionWidth, 1), 1.0,
babl_format ("R'G'B'A u8"), source2Row,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
}
if (dm->depthMap1Drawable)
{
gegl_buffer_get (depthMap1_buffer,
GEGL_RECTANGLE (dm->selectionX, y,
dm->selectionWidth, 1), 1.0,
babl_format ("Y' u8"), depthMap1Row,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
}
if (dm->depthMap2Drawable)
{
gegl_buffer_get (depthMap2_buffer,
GEGL_RECTANGLE (dm->selectionX, y,
dm->selectionWidth, 1), 1.0,
babl_format ("Y' u8"), depthMap2Row,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
}
DepthMerge_executeRegion (dm,
source1Row, source2Row, depthMap1Row, depthMap2Row,
resultRow,
dm->selectionWidth);
1997-11-25 06:05:25 +08:00
gegl_buffer_set (result_buffer,
GEGL_RECTANGLE (dm->selectionX, y,
dm->selectionWidth, 1), 0,
babl_format ("R'G'B'A u8"), resultRow,
GEGL_AUTO_ROWSTRIDE);
1997-11-25 06:05:25 +08:00
gimp_progress_update ((double)(y-dm->selectionY) /
(double)(dm->selectionHeight - 1));
}
1997-11-25 06:05:25 +08:00
g_free (resultRow);
g_free (source1Row);
g_free (source2Row);
g_free (depthMap1Row);
g_free (depthMap2Row);
g_free (tempRow);
gimp_progress_update (1.0);
if (source1_buffer)
g_object_unref (source1_buffer);
if (source2_buffer)
g_object_unref (source2_buffer);
if (depthMap1_buffer)
g_object_unref (depthMap1_buffer);
if (depthMap2_buffer)
g_object_unref (depthMap2_buffer);
g_object_unref (result_buffer);
gimp_drawable_merge_shadow (dm->resultDrawable, TRUE);
gimp_drawable_update (dm->resultDrawable,
dm->selectionX, dm->selectionY,
dm->selectionWidth, dm->selectionHeight);
return TRUE;
1997-11-25 06:05:25 +08:00
}
static void
DepthMerge_executeRegion (DepthMerge *dm,
guchar *source1Row,
guchar *source2Row,
guchar *depthMap1Row,
guchar *depthMap2Row,
guchar *resultRow,
gint length)
{
gfloat scale1, scale2, offset255, invOverlap255;
gfloat frac, depth1, depth2;
gushort c1[4], c2[4];
gushort cR1[4] = { 0, 0, 0, 0 }, cR2[4] = { 0, 0, 0, 0 };
gushort cR[4], temp;
gint i, tempInt;
1997-11-25 06:05:25 +08:00
invOverlap255 = 1.0 / (MAX (dm->params.overlap, 0.001) * 255);
offset255 = dm->params.offset * 255;
scale1 = dm->params.scale1;
scale2 = dm->params.scale2;
1997-11-25 06:05:25 +08:00
for (i = 0; i < length; i++)
{
depth1 = (gfloat) depthMap1Row[i];
depth2 = (gfloat) depthMap2Row[i];
1997-11-25 06:05:25 +08:00
frac = (depth2 * scale2 - (depth1 * scale1 + offset255)) * invOverlap255;
frac = 0.5 * (frac + 1.0);
frac = CLAMP(frac, 0.0, 1.0);
1997-11-25 06:05:25 +08:00
/* c1 -> color corresponding to source1 */
c1[0] = source1Row[4 * i ];
c1[1] = source1Row[4 * i + 1];
c1[2] = source1Row[4 * i + 2];
c1[3] = source1Row[4 * i + 3];
1997-11-25 06:05:25 +08:00
/* c2 -> color corresponding to source2 */
c2[0] = source2Row[4 * i ];
c2[1] = source2Row[4 * i + 1];
c2[2] = source2Row[4 * i + 2];
c2[3] = source2Row[4 * i + 3];
if (frac != 0)
{
/* cR1 -> result if c1 is completely on top */
cR1[0] = c1[3] * c1[0] + (255 - c1[3]) * c2[0];
cR1[1] = c1[3] * c1[1] + (255 - c1[3]) * c2[1];
cR1[2] = c1[3] * c1[2] + (255 - c1[3]) * c2[2];
cR1[3] = MUL255 (c1[3]) + (255 - c1[3]) * c2[3];
}
if (frac != 1)
{
/* cR2 -> result if c2 is completely on top */
cR2[0] = c2[3] * c2[0] + (255 - c2[3]) * c1[0];
cR2[1] = c2[3] * c2[1] + (255 - c2[3]) * c1[1];
cR2[2] = c2[3] * c2[2] + (255 - c2[3]) * c1[2];
cR2[3] = MUL255 (c2[3]) + (255 - c2[3]) * c1[3];
}
if (frac == 1)
{
cR[0] = cR1[0];
cR[1] = cR1[1];
cR[2] = cR1[2];
cR[3] = cR1[3];
}
else if (frac == 0)
{
cR[0] = cR2[0];
cR[1] = cR2[1];
cR[2] = cR2[2];
cR[3] = cR2[3];
}
else
{
tempInt = LERP (frac, cR2[0], cR1[0]);
cR[0] = CLAMP (tempInt,0,255 * 255);
tempInt = LERP (frac, cR2[1], cR1[1]);
cR[1] = CLAMP (tempInt,0,255 * 255);
tempInt = LERP (frac, cR2[2], cR1[2]);
cR[2] = CLAMP (tempInt,0,255 * 255);
tempInt = LERP (frac, cR2[3], cR1[3]);
cR[3] = CLAMP (tempInt,0,255 * 255);
}
temp = DIV255 (cR[0]); resultRow[4 * i ] = MIN (temp, 255);
temp = DIV255 (cR[1]); resultRow[4 * i + 1] = MIN (temp, 255);
temp = DIV255 (cR[2]); resultRow[4 * i + 2] = MIN (temp, 255);
temp = DIV255 (cR[3]); resultRow[4 * i + 3] = MIN (temp, 255);
1997-11-25 06:05:25 +08:00
}
}
static gboolean
DepthMerge_dialog (DepthMerge *dm)
{
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *frame;
GtkWidget *grid;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *combo;
GtkWidget *scale;
gboolean run;
1997-11-25 06:05:25 +08:00
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
dm->interface = g_new0 (DepthMergeInterface, 1);
1997-11-25 06:05:25 +08:00
gimp_ui_init (PLUG_IN_BINARY);
1997-11-25 06:05:25 +08:00
dm->interface->dialog =
dialog = gimp_dialog_new (_("Depth Merge"), PLUG_IN_ROLE,
NULL, 0,
gimp_standard_help_func, PLUG_IN_PROC,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_OK"), GTK_RESPONSE_OK,
NULL);
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
Added parent window API to the GimpProgress interface and to the libgimp 2005-09-09 Michael Natterer <mitch@gimp.org> Added parent window API to the GimpProgress interface and to the libgimp progress stuff. Might look strange, but does the right thing in almost all cases (image window, file dialog, script-fu dialog etc). Fixes bug #62988. * app/core/gimpprogress.[ch]: added GimpProgress::get_window() which should return a toplevel window ID if the progress is in a window that wants to be the transient parent of plug-in dialogs. * app/widgets/gimpwidgets-utils.[ch] (gimp_window_get_native): new function which returns the window handle of a GtkWindow's GdkWindow. * app/widgets/gimpfiledialog.c: implement ::get_window(). * app/display/gimpdisplay.[ch]: ditto. Removed window handle API. * app/gui/gui-vtable.c: changed accordingly. * libgimpbase/gimpbaseenums.[ch] (enum GimpProgressCommand): added GIMP_PROGRESS_COMMAND_GET_WINDOW. * app/plug-in/plug-in-progress.[ch] (plug_in_progress_get_window): new function. Also renamed some functions to match the GimpProgress interface, and not the legacy PDB procedure names. * tools/pdbgen/pdb/progress.pdb * app/core/gimppdbprogress.c: implement get_window() on both sides of the wire, keeping backward compatibility (hopefully). * libgimp/gimpprogress.[ch]: deprecated gimp_progress_install() and added gimp_progress_install_vtable() which takes a vtable with padding to be extensible. Added get_window() vtable entry and dispatch it accordingly. Also added pulse() which was implemented in a hackish way before. Everything is of course backward compatible. * libgimp/gimpprogressbar.c: inmplement the get_window() stuff so a plug-in dialog containing a progress can be the transient parent of another dialog in another plug-in. * libgimp/gimpui.[ch] (gimp_ui_get_progress_window): new function which returns a foreign GdkWindow of this plug-ins progress window. Renamed gimp_window_set_transient_for_default_display() to gimp_window_set_transient() and make it use the progress' window handle instead of the display's (which is the right thing to do in almost all cases). * libgimp/gimp.def * libgimp/gimpui.def: add the new functions. * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/progress_cmds.c * libgimp/gimpprogress_pdb.[ch]: regenerated. * libgimp/gimpexport.c * plug-ins/*/*.c: follow API change.
2005-09-10 02:07:31 +08:00
gimp_window_set_transient (GTK_WINDOW (dialog));
2011-09-30 18:17:53 +08:00
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
1997-11-25 06:05:25 +08:00
/* Preview */
2011-09-30 18:17:53 +08:00
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
dm->interface->previewWidth = MIN (dm->selectionWidth, PREVIEW_SIZE);
dm->interface->previewHeight = MIN (dm->selectionHeight, PREVIEW_SIZE);
dm->interface->preview = gimp_preview_area_new ();
gtk_widget_set_size_request (dm->interface->preview,
dm->interface->previewWidth,
dm->interface->previewHeight);
gtk_container_add (GTK_CONTAINER (frame), dm->interface->preview);
gtk_widget_show (dm->interface->preview);
DepthMerge_buildPreviewSourceImage (dm);
1997-11-25 06:05:25 +08:00
/* Source and Depth Map selection */
2018-05-11 17:16:00 +08:00
grid = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_box_pack_start (GTK_BOX (vbox), grid, FALSE, FALSE, 0);
gtk_widget_show (grid);
label = gtk_label_new (_("Source 1:"));
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
2018-05-11 17:16:00 +08:00
gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
gtk_widget_show (label);
combo = gimp_drawable_combo_box_new (dm_constraint, dm, NULL);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dm->params.source1_id,
G_CALLBACK (dialogSource1ChangedCallback),
dm, NULL);
2018-05-11 17:16:00 +08:00
gtk_grid_attach (GTK_GRID (grid), combo, 1, 0, 2, 1);
gtk_widget_show (combo);
label = gtk_label_new(_("Depth map:"));
2018-05-11 17:16:00 +08:00
gtk_widget_set_margin_bottom (label, 6);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
2018-05-11 17:16:00 +08:00
gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
gtk_widget_show (label);
combo = gimp_drawable_combo_box_new (dm_constraint, dm, NULL);
2018-05-11 17:16:00 +08:00
gtk_widget_set_margin_bottom (combo, 6);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dm->params.depthMap1_id,
G_CALLBACK (dialogDepthMap1ChangedCallback),
dm, NULL);
2018-05-11 17:16:00 +08:00
gtk_grid_attach (GTK_GRID (grid), combo, 1, 1, 2, 1);
gtk_widget_show (combo);
label = gtk_label_new (_("Source 2:"));
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
2018-05-11 17:16:00 +08:00
gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);
gtk_widget_show (label);
combo = gimp_drawable_combo_box_new (dm_constraint, dm, NULL);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dm->params.source2_id,
G_CALLBACK (dialogSource2ChangedCallback),
dm, NULL);
2018-05-11 17:16:00 +08:00
gtk_grid_attach (GTK_GRID (grid), combo, 1, 2, 2, 1);
gtk_widget_show (combo);
label = gtk_label_new (_("Depth map:"));
2018-05-11 17:16:00 +08:00
gtk_widget_set_margin_bottom (label, 6);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
2018-05-11 17:16:00 +08:00
gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1);
gtk_widget_show (label);
combo = gimp_drawable_combo_box_new (dm_constraint, dm, NULL);
2018-05-11 17:16:00 +08:00
gtk_widget_set_margin_bottom (combo, 6);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dm->params.depthMap2_id,
G_CALLBACK (dialogDepthMap2ChangedCallback),
dm, NULL);
2018-05-11 17:16:00 +08:00
gtk_grid_attach (GTK_GRID (grid), combo, 1, 3, 2, 1);
gtk_widget_show (combo);
1997-11-25 06:05:25 +08:00
/* Numeric parameters */
scale = gimp_scale_entry_new (_("O_verlap:"), dm->params.overlap, 0, 2, 3);
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.001, 0.01);
g_signal_connect (scale, "value-changed",
app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c 2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 21:26:29 +08:00
G_CALLBACK (dialogValueScaleUpdateCallback),
&(dm->params.overlap));
g_object_set_data (G_OBJECT (scale), "dm", dm);
gtk_grid_attach (GTK_GRID (grid), scale, 0, 4, 3, 1);
gtk_widget_show (scale);
scale = gimp_scale_entry_new (_("O_ffset:"), dm->params.offset, -1, 1, 3);
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.001, 0.01);
g_signal_connect (scale, "value-changed",
app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c 2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 21:26:29 +08:00
G_CALLBACK (dialogValueScaleUpdateCallback),
&(dm->params.offset));
g_object_set_data (G_OBJECT (scale), "dm", dm);
gtk_grid_attach (GTK_GRID (grid), scale, 0, 5, 3, 1);
gtk_widget_show (scale);
scale = gimp_scale_entry_new (_("Sc_ale 1:"), dm->params.scale1, -1, 1, 3);
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.001, 0.01);
g_signal_connect (scale, "value-changed",
app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c 2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 21:26:29 +08:00
G_CALLBACK (dialogValueScaleUpdateCallback),
&(dm->params.scale1));
g_object_set_data (G_OBJECT (scale), "dm", dm);
gtk_grid_attach (GTK_GRID (grid), scale, 0, 6, 3, 1);
gtk_widget_show (scale);
scale = gimp_scale_entry_new (_("Sca_le 2:"), dm->params.scale2, -1, 1, 3);
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.001, 0.01);
g_signal_connect (scale, "value-changed",
app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c 2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 21:26:29 +08:00
G_CALLBACK (dialogValueScaleUpdateCallback),
&(dm->params.scale2));
g_object_set_data (G_OBJECT (scale), "dm", dm);
gtk_grid_attach (GTK_GRID (grid), scale, 0, 7, 3, 1);
gtk_widget_show (scale);
1997-11-25 06:05:25 +08:00
dm->interface->active = TRUE;
gtk_widget_show (dm->interface->dialog);
DepthMerge_updatePreview (dm);
1997-11-25 06:05:25 +08:00
run = (gimp_dialog_run (GIMP_DIALOG (dm->interface->dialog)) == GTK_RESPONSE_OK);
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
gtk_widget_destroy (dm->interface->dialog);
dm->interface->dialog = NULL;
1997-11-25 06:05:25 +08:00
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
return run;
1997-11-25 06:05:25 +08:00
}
static void
DepthMerge_buildPreviewSourceImage (DepthMerge *dm)
{
1997-11-25 06:05:25 +08:00
dm->interface->previewSource1 =
g_new (guchar, dm->interface->previewWidth *
dm->interface->previewHeight * 4);
util_fillReducedBuffer (dm->interface->previewSource1,
babl_format ("R'G'B'A u8"),
dm->interface->previewWidth,
dm->interface->previewHeight,
dm->source1Drawable,
dm->selectionX, dm->selectionY,
dm->selectionWidth, dm->selectionHeight);
1997-11-25 06:05:25 +08:00
dm->interface->previewSource2 =
g_new (guchar, dm->interface->previewWidth *
dm->interface->previewHeight * 4);
util_fillReducedBuffer (dm->interface->previewSource2,
babl_format ("R'G'B'A u8"),
dm->interface->previewWidth,
dm->interface->previewHeight,
dm->source2Drawable,
dm->selectionX, dm->selectionY,
dm->selectionWidth, dm->selectionHeight);
1997-11-25 06:05:25 +08:00
dm->interface->previewDepthMap1 =
g_new (guchar, dm->interface->previewWidth *
dm->interface->previewHeight * 1);
util_fillReducedBuffer (dm->interface->previewDepthMap1,
babl_format ("Y' u8"),
dm->interface->previewWidth,
dm->interface->previewHeight,
dm->depthMap1Drawable,
dm->selectionX, dm->selectionY,
dm->selectionWidth, dm->selectionHeight);
1997-11-25 06:05:25 +08:00
dm->interface->previewDepthMap2 =
g_new (guchar, dm->interface->previewWidth *
dm->interface->previewHeight * 1);
util_fillReducedBuffer (dm->interface->previewDepthMap2,
babl_format ("Y' u8"),
dm->interface->previewWidth,
dm->interface->previewHeight,
dm->depthMap2Drawable,
dm->selectionX, dm->selectionY,
dm->selectionWidth, dm->selectionHeight);
1997-11-25 06:05:25 +08:00
}
static void
DepthMerge_updatePreview (DepthMerge *dm)
{
gint y;
guchar *source1Row, *source2Row;
guchar *depthMap1Row, *depthMap2Row;
guchar *resultRGBA;
1997-11-25 06:05:25 +08:00
if (!dm->interface->active)
return;
1997-11-25 06:05:25 +08:00
resultRGBA = g_new (guchar, 4 * dm->interface->previewWidth *
dm->interface->previewHeight);
1997-11-25 06:05:25 +08:00
for (y = 0; y < dm->interface->previewHeight; y++)
{
source1Row =
&(dm->interface->previewSource1[ y * dm->interface->previewWidth * 4]);
source2Row =
&(dm->interface->previewSource2[ y * dm->interface->previewWidth * 4]);
depthMap1Row =
&(dm->interface->previewDepthMap1[y * dm->interface->previewWidth ]);
depthMap2Row =
&(dm->interface->previewDepthMap2[y * dm->interface->previewWidth ]);
DepthMerge_executeRegion(dm,
source1Row, source2Row, depthMap1Row, depthMap2Row,
resultRGBA + 4 * y * dm->interface->previewWidth,
dm->interface->previewWidth);
1997-11-25 06:05:25 +08:00
}
gimp_preview_area_draw (GIMP_PREVIEW_AREA (dm->interface->preview),
0, 0,
dm->interface->previewWidth,
dm->interface->previewHeight,
GIMP_RGBA_IMAGE,
resultRGBA,
dm->interface->previewWidth * 4);
g_free(resultRGBA);
1997-11-25 06:05:25 +08:00
}
/* ----- Callbacks ----- */
static gboolean
dm_constraint (GimpImage *image,
GimpItem *item,
gpointer data)
{
DepthMerge *dm = data;
GimpDrawable *drawable = GIMP_DRAWABLE (item);
return ((gimp_drawable_get_width (drawable) ==
gimp_drawable_get_width (dm->resultDrawable)) &&
(gimp_drawable_get_height (drawable) ==
gimp_drawable_get_height (dm->resultDrawable)) &&
((gimp_drawable_is_rgb (drawable) &&
(gimp_drawable_is_rgb (dm->resultDrawable))) ||
gimp_drawable_is_gray (drawable)));
1997-11-25 06:05:25 +08:00
}
static void
dialogSource1ChangedCallback (GtkWidget *widget,
DepthMerge *dm)
{
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
&dm->params.source1_id);
dm->source1Drawable = gimp_drawable_get_by_id (dm->params.source1_id);
1997-11-25 06:05:25 +08:00
util_fillReducedBuffer (dm->interface->previewSource1,
babl_format ("R'G'B'A u8"),
dm->interface->previewWidth,
dm->interface->previewHeight,
dm->source1Drawable,
dm->selectionX, dm->selectionY,
dm->selectionWidth, dm->selectionHeight);
DepthMerge_updatePreview (dm);
1997-11-25 06:05:25 +08:00
}
static void
dialogSource2ChangedCallback (GtkWidget *widget,
DepthMerge *dm)
{
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
&dm->params.source2_id);
dm->source2Drawable = gimp_drawable_get_by_id (dm->params.source2_id);
util_fillReducedBuffer (dm->interface->previewSource2,
babl_format ("R'G'B'A u8"),
dm->interface->previewWidth,
dm->interface->previewHeight,
dm->source2Drawable,
dm->selectionX, dm->selectionY,
dm->selectionWidth, dm->selectionHeight);
DepthMerge_updatePreview (dm);
1997-11-25 06:05:25 +08:00
}
static void
dialogDepthMap1ChangedCallback (GtkWidget *widget,
DepthMerge *dm)
{
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
&dm->params.depthMap1_id);
dm->depthMap1Drawable = gimp_drawable_get_by_id (dm->params.depthMap1_id);
util_fillReducedBuffer (dm->interface->previewDepthMap1,
babl_format ("Y' u8"),
dm->interface->previewWidth,
dm->interface->previewHeight,
dm->depthMap1Drawable,
dm->selectionX, dm->selectionY,
dm->selectionWidth, dm->selectionHeight);
1997-11-25 06:05:25 +08:00
DepthMerge_updatePreview (dm);
1997-11-25 06:05:25 +08:00
}
static void
dialogDepthMap2ChangedCallback (GtkWidget *widget,
DepthMerge *dm)
{
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
&dm->params.depthMap2_id);
dm->depthMap2Drawable = gimp_drawable_get_by_id (dm->params.depthMap2_id);
util_fillReducedBuffer (dm->interface->previewDepthMap2,
babl_format ("Y' u8"),
dm->interface->previewWidth,
dm->interface->previewHeight,
dm->depthMap2Drawable,
dm->selectionX, dm->selectionY,
dm->selectionWidth, dm->selectionHeight);
1997-11-25 06:05:25 +08:00
DepthMerge_updatePreview (dm);
1997-11-25 06:05:25 +08:00
}
static void
dialogValueScaleUpdateCallback (GimpLabelSpin *scale,
gfloat *value)
{
DepthMerge *dm = g_object_get_data (G_OBJECT (scale), "dm");
1997-11-25 06:05:25 +08:00
*value = (gfloat) gimp_label_spin_get_value (scale);
1997-11-25 06:05:25 +08:00
DepthMerge_updatePreview (dm);
1997-11-25 06:05:25 +08:00
}
/* ----- Utility routines ----- */
static void
util_fillReducedBuffer (guchar *dest,
const Babl *dest_format,
gint destWidth,
gint destHeight,
GimpDrawable *sourceDrawable,
gint x0,
gint y0,
gint sourceWidth,
gint sourceHeight)
{
GeglBuffer *buffer;
guchar *sourceBuffer, *reducedRowBuffer;
guchar *sourceBufferPos, *reducedRowBufferPos;
guchar *sourceBufferRow;
gint x, y, i, yPrime;
gint destBPP;
gint *sourceRowOffsetLookup;
destBPP = babl_format_get_bytes_per_pixel (dest_format);
if (! sourceDrawable || (sourceWidth == 0) || (sourceHeight == 0))
{
for (x = 0; x < destWidth * destHeight * destBPP; x++)
dest[x] = 0;
return;
}
1997-11-25 06:05:25 +08:00
sourceBuffer = g_new (guchar, sourceWidth * sourceHeight * destBPP);
reducedRowBuffer = g_new (guchar, destWidth * destBPP);
sourceRowOffsetLookup = g_new (int, destWidth);
buffer = gimp_drawable_get_buffer (sourceDrawable);
1997-11-25 06:05:25 +08:00
for (x = 0; x < destWidth; x++)
sourceRowOffsetLookup[x] = (x * (sourceWidth - 1) / (destWidth - 1)) * destBPP;
gegl_buffer_get (buffer,
GEGL_RECTANGLE (x0, y0, sourceWidth, sourceHeight), 1.0,
dest_format, sourceBuffer,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
for (y = 0; y < destHeight; y++)
{
yPrime = y * (sourceHeight - 1) / (destHeight - 1);
sourceBufferRow = &(sourceBuffer[yPrime * sourceWidth * destBPP]);
reducedRowBufferPos = reducedRowBuffer;
for (x = 0; x < destWidth; x++)
{
sourceBufferPos = sourceBufferRow + sourceRowOffsetLookup[x];
for (i = 0; i < destBPP; i++)
reducedRowBufferPos[i] = sourceBufferPos[i];
reducedRowBufferPos += destBPP;
}
memcpy (&(dest[y * destWidth * destBPP]), reducedRowBuffer,
destWidth * destBPP);
1997-11-25 06:05:25 +08:00
}
g_object_unref (buffer);
g_free (sourceBuffer);
g_free (reducedRowBuffer);
g_free (sourceRowOffsetLookup);
}