2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +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
|
2009-01-18 06:28:01 +08:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This filter tiles an image to arbitrary width and height
|
|
|
|
*/
|
2000-01-26 01:46:56 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <string.h>
|
2000-01-09 04:00:10 +08:00
|
|
|
|
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-02 04:22:55 +08:00
|
|
|
|
2005-08-16 06:42:34 +08:00
|
|
|
#define PLUG_IN_PROC "plug-in-tile"
|
|
|
|
#define PLUG_IN_BINARY "tile"
|
|
|
|
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
gint new_width;
|
|
|
|
gint new_height;
|
|
|
|
gint constrain;
|
|
|
|
gint new_image;
|
|
|
|
} TileVals;
|
|
|
|
|
2000-11-09 06:41:13 +08:00
|
|
|
|
|
|
|
/* Declare local functions.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2004-05-20 08:50:05 +08:00
|
|
|
static void query (void);
|
|
|
|
static void run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2004-05-20 08:50:05 +08:00
|
|
|
static gint32 tile (gint32 image_id,
|
|
|
|
gint32 drawable_id,
|
|
|
|
gint32 *layer_id);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-05-20 08:50:05 +08:00
|
|
|
static gboolean tile_dialog (gint32 image_ID,
|
|
|
|
gint32 drawable_ID);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2006-05-16 20:26:20 +08:00
|
|
|
const GimpPlugInInfo PLUG_IN_INFO =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
|
|
|
run, /* run_proc */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static TileVals tvals =
|
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
1, /* new_width */
|
|
|
|
1, /* new_height */
|
|
|
|
TRUE, /* constrain */
|
|
|
|
TRUE /* new_image */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2000-11-09 06:41:13 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
MAIN ()
|
|
|
|
|
|
|
|
static void
|
2000-01-26 01:46:56 +08:00
|
|
|
query (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-16 20:26:20 +08:00
|
|
|
static const GimpParamDef args[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2009-01-20 04:11:36 +08:00
|
|
|
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
|
2000-11-09 06:41:13 +08:00
|
|
|
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
|
|
|
|
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
|
2005-08-16 06:42:34 +08:00
|
|
|
{ GIMP_PDB_INT32, "new-width", "New (tiled) image width" },
|
|
|
|
{ GIMP_PDB_INT32, "new-height", "New (tiled) image height" },
|
|
|
|
{ GIMP_PDB_INT32, "new-image", "Create a new image?" }
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
2000-05-02 04:22:55 +08:00
|
|
|
|
2006-05-16 20:26:20 +08:00
|
|
|
static const GimpParamDef return_vals[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2007-07-31 15:48:26 +08:00
|
|
|
{ GIMP_PDB_IMAGE, "new-image", "Output image (-1 if new-image == FALSE)" },
|
|
|
|
{ GIMP_PDB_LAYER, "new-layer", "Output layer (-1 if new-image == FALSE)" }
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2005-08-16 06:42:34 +08:00
|
|
|
gimp_install_procedure (PLUG_IN_PROC,
|
2007-07-31 15:48:26 +08:00
|
|
|
N_("Create an array of copies of the image"),
|
|
|
|
"This function creates a new image with a single "
|
|
|
|
"layer sized to the specified 'new_width' and "
|
|
|
|
"'new_height' parameters. The specified drawable "
|
|
|
|
"is tiled into this layer. The new layer will have "
|
|
|
|
"the same type as the specified drawable and the "
|
|
|
|
"new image will have a corresponding base type.",
|
|
|
|
"Spencer Kimball & Peter Mattis",
|
|
|
|
"Spencer Kimball & Peter Mattis",
|
|
|
|
"1996-1997",
|
|
|
|
N_("_Tile..."),
|
|
|
|
"RGB*, GRAY*, INDEXED*",
|
|
|
|
GIMP_PLUGIN,
|
|
|
|
G_N_ELEMENTS (args),
|
2001-12-06 10:28:58 +08:00
|
|
|
G_N_ELEMENTS (return_vals),
|
2007-07-31 15:48:26 +08:00
|
|
|
args, return_vals);
|
2004-05-07 21:15:52 +08:00
|
|
|
|
2005-08-16 06:42:34 +08:00
|
|
|
gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Filters/Map");
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-07-02 21:00:16 +08:00
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-11-09 06:41:13 +08:00
|
|
|
static GimpParam values[3];
|
2002-01-08 17:20:02 +08:00
|
|
|
GimpRunMode run_mode;
|
2005-07-18 04:35:32 +08:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
|
|
|
gint32 new_layer = -1;
|
2002-01-08 17:20:02 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
run_mode = param[0].data.d_int32;
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
*nreturn_vals = 3;
|
2000-11-09 06:41:13 +08:00
|
|
|
*return_vals = values;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-11-09 06:41:13 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
1997-11-25 06:05:25 +08:00
|
|
|
values[0].data.d_status = status;
|
2000-11-09 06:41:13 +08:00
|
|
|
values[1].type = GIMP_PDB_IMAGE;
|
|
|
|
values[2].type = GIMP_PDB_LAYER;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-11-09 06:41:13 +08:00
|
|
|
width = gimp_drawable_width (param[2].data.d_drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
height = gimp_drawable_height (param[2].data.d_drawable);
|
|
|
|
|
|
|
|
switch (run_mode)
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Possibly retrieve data */
|
2005-08-16 06:42:34 +08:00
|
|
|
gimp_get_data (PLUG_IN_PROC, &tvals);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* First acquire information with a dialog */
|
2000-02-03 01:59:44 +08:00
|
|
|
if (! tile_dialog (param[1].data.d_image,
|
2007-07-31 15:48:26 +08:00
|
|
|
param[2].data.d_drawable))
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Make sure all the arguments are there! */
|
|
|
|
if (nparams != 6)
|
2007-07-31 15:48:26 +08:00
|
|
|
{
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
2000-02-03 01:59:44 +08:00
|
|
|
else
|
2007-07-31 15:48:26 +08:00
|
|
|
{
|
|
|
|
tvals.new_width = param[3].data.d_int32;
|
|
|
|
tvals.new_height = param[4].data.d_int32;
|
|
|
|
tvals.new_image = param[5].data.d_int32 ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if (tvals.new_width < 0 || tvals.new_height < 0)
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Possibly retrieve data */
|
2005-08-16 06:42:34 +08:00
|
|
|
gimp_get_data (PLUG_IN_PROC, &tvals);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-09-30 16:16:10 +08:00
|
|
|
gimp_progress_init (_("Tiling"));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-03 01:59:44 +08:00
|
|
|
values[1].data.d_image = tile (param[1].data.d_image,
|
2007-07-31 15:48:26 +08:00
|
|
|
param[2].data.d_drawable,
|
|
|
|
&new_layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
values[2].data.d_layer = new_layer;
|
|
|
|
|
|
|
|
/* Store data */
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode == GIMP_RUN_INTERACTIVE)
|
2007-07-31 15:48:26 +08:00
|
|
|
gimp_set_data (PLUG_IN_PROC, &tvals, sizeof (TileVals));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
2007-07-31 15:48:26 +08:00
|
|
|
{
|
|
|
|
if (tvals.new_image)
|
|
|
|
gimp_display_new (values[1].data.d_image);
|
|
|
|
else
|
|
|
|
gimp_displays_flush ();
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
values[0].data.d_status = status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint32
|
2000-01-26 01:46:56 +08:00
|
|
|
tile (gint32 image_id,
|
|
|
|
gint32 drawable_id,
|
|
|
|
gint32 *layer_id)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-11-09 06:41:13 +08:00
|
|
|
GimpPixelRgn src_rgn;
|
|
|
|
GimpPixelRgn dest_rgn;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpDrawable *new_layer;
|
2007-07-31 15:48:26 +08:00
|
|
|
GimpImageBaseType image_type = GIMP_RGB;
|
|
|
|
gint32 new_image_id = 0;
|
|
|
|
gint old_width;
|
|
|
|
gint old_height;
|
|
|
|
gint i, j;
|
|
|
|
gint progress;
|
|
|
|
gint max_progress;
|
|
|
|
gpointer pr;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-11-09 06:41:13 +08:00
|
|
|
/* sanity check parameters */
|
|
|
|
if (tvals.new_width < 1 || tvals.new_height < 1)
|
|
|
|
{
|
|
|
|
*layer_id = -1;
|
|
|
|
return -1;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-11-09 06:41:13 +08:00
|
|
|
/* initialize */
|
|
|
|
old_width = gimp_drawable_width (drawable_id);
|
1997-11-25 06:05:25 +08:00
|
|
|
old_height = gimp_drawable_height (drawable_id);
|
|
|
|
|
|
|
|
if (tvals.new_image)
|
|
|
|
{
|
|
|
|
/* create a new image */
|
|
|
|
switch (gimp_drawable_type (drawable_id))
|
2007-07-31 15:48:26 +08:00
|
|
|
{
|
|
|
|
case GIMP_RGB_IMAGE:
|
|
|
|
case GIMP_RGBA_IMAGE:
|
|
|
|
image_type = GIMP_RGB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_GRAY_IMAGE:
|
|
|
|
case GIMP_GRAYA_IMAGE:
|
|
|
|
image_type = GIMP_GRAY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_INDEXED_IMAGE:
|
|
|
|
case GIMP_INDEXEDA_IMAGE:
|
|
|
|
image_type = GIMP_INDEXED;
|
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
new_image_id = gimp_image_new (tvals.new_width, tvals.new_height,
|
2007-07-31 15:48:26 +08:00
|
|
|
image_type);
|
2004-04-17 01:45:30 +08:00
|
|
|
gimp_image_undo_disable (new_image_id);
|
2007-06-27 16:15:54 +08:00
|
|
|
|
2000-01-09 14:02:20 +08:00
|
|
|
*layer_id = gimp_layer_new (new_image_id, _("Background"),
|
2007-07-31 15:48:26 +08:00
|
|
|
tvals.new_width, tvals.new_height,
|
|
|
|
gimp_drawable_type (drawable_id),
|
|
|
|
100, GIMP_NORMAL_MODE);
|
2000-11-09 06:41:13 +08:00
|
|
|
|
|
|
|
if (*layer_id == -1)
|
2007-07-31 15:48:26 +08:00
|
|
|
return -1;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_image_add_layer (new_image_id, *layer_id, 0);
|
|
|
|
new_layer = gimp_drawable_get (*layer_id);
|
|
|
|
|
2007-06-27 16:15:54 +08:00
|
|
|
/* Get the source drawable */
|
1997-11-25 06:05:25 +08:00
|
|
|
drawable = gimp_drawable_get (drawable_id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-12-05 22:18:47 +08:00
|
|
|
gimp_image_undo_group_start (image_id);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_image_resize (image_id,
|
2007-07-31 15:48:26 +08:00
|
|
|
tvals.new_width, tvals.new_height,
|
|
|
|
0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-17 08:07:55 +08:00
|
|
|
if (gimp_drawable_is_layer (drawable_id))
|
2007-07-31 15:48:26 +08:00
|
|
|
gimp_layer_resize (drawable_id,
|
|
|
|
tvals.new_width, tvals.new_height,
|
|
|
|
0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2007-06-27 16:15:54 +08:00
|
|
|
/* Get the source drawable */
|
1997-11-25 06:05:25 +08:00
|
|
|
drawable = gimp_drawable_get (drawable_id);
|
|
|
|
new_layer = drawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* progress */
|
|
|
|
progress = 0;
|
|
|
|
max_progress = tvals.new_width * tvals.new_height;
|
|
|
|
|
|
|
|
/* tile... */
|
|
|
|
for (i = 0; i < tvals.new_height; i += old_height)
|
|
|
|
{
|
2007-07-31 15:48:26 +08:00
|
|
|
gint height = old_height;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (height + i > tvals.new_height)
|
2007-07-31 15:48:26 +08:00
|
|
|
height = tvals.new_height - i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (j = 0; j < tvals.new_width; j += old_width)
|
2007-07-31 15:48:26 +08:00
|
|
|
{
|
|
|
|
gint width = old_width;
|
|
|
|
gint c;
|
|
|
|
|
|
|
|
if (width + j > tvals.new_width)
|
|
|
|
width = tvals.new_width - j;
|
|
|
|
|
|
|
|
gimp_pixel_rgn_init (&src_rgn, drawable,
|
|
|
|
0, 0, width, height, FALSE, FALSE);
|
|
|
|
gimp_pixel_rgn_init (&dest_rgn, new_layer,
|
|
|
|
j, i, width, height, TRUE, FALSE);
|
|
|
|
|
|
|
|
for (pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn), c = 0;
|
|
|
|
pr != NULL;
|
|
|
|
pr = gimp_pixel_rgns_process (pr), c++)
|
|
|
|
{
|
|
|
|
gint k;
|
|
|
|
|
|
|
|
for (k = 0; k < src_rgn.h; k++)
|
|
|
|
memcpy (dest_rgn.data + k * dest_rgn.rowstride,
|
|
|
|
src_rgn.data + k * src_rgn.rowstride,
|
|
|
|
src_rgn.w * src_rgn.bpp);
|
|
|
|
|
|
|
|
progress += src_rgn.w * src_rgn.h;
|
|
|
|
|
2008-01-06 08:50:40 +08:00
|
|
|
if (c % 16 == 0)
|
2007-07-31 15:48:26 +08:00
|
|
|
gimp_progress_update ((gdouble) progress /
|
|
|
|
(gdouble) max_progress);
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2007-06-27 16:15:54 +08:00
|
|
|
gimp_drawable_update (new_layer->drawable_id,
|
|
|
|
0, 0, new_layer->width, new_layer->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2007-06-27 16:15:54 +08:00
|
|
|
gimp_drawable_detach (drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (tvals.new_image)
|
|
|
|
{
|
|
|
|
gimp_drawable_detach (new_layer);
|
2007-06-27 16:15:54 +08:00
|
|
|
|
|
|
|
/* copy the colormap, if necessary */
|
|
|
|
if (image_type == GIMP_INDEXED)
|
|
|
|
{
|
|
|
|
guchar *cmap;
|
2007-07-31 15:48:26 +08:00
|
|
|
gint ncols;
|
2007-06-27 16:15:54 +08:00
|
|
|
|
|
|
|
cmap = gimp_image_get_colormap (image_id, &ncols);
|
|
|
|
gimp_image_set_colormap (new_image_id, cmap, ncols);
|
|
|
|
g_free (cmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_image_undo_enable (new_image_id);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
2003-12-05 22:18:47 +08:00
|
|
|
{
|
|
|
|
gimp_image_undo_group_end (image_id);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return new_image_id;
|
|
|
|
}
|
|
|
|
|
2004-05-20 08:50:05 +08:00
|
|
|
static gboolean
|
2000-02-03 01:59:44 +08:00
|
|
|
tile_dialog (gint32 image_ID,
|
2007-07-31 15:48:26 +08:00
|
|
|
gint32 drawable_ID)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GtkWidget *dlg;
|
2004-05-20 08:50:05 +08:00
|
|
|
GtkWidget *vbox;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *frame;
|
2000-02-03 01:59:44 +08:00
|
|
|
GtkWidget *sizeentry;
|
2003-11-06 23:27:05 +08:00
|
|
|
GtkWidget *chainbutton;
|
2000-01-26 01:46:56 +08:00
|
|
|
GtkWidget *toggle;
|
2000-11-09 06:41:13 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
gdouble xres;
|
|
|
|
gdouble yres;
|
|
|
|
GimpUnit unit;
|
2003-11-06 23:27:05 +08:00
|
|
|
gboolean run;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-16 06:42:34 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-03 01:59:44 +08:00
|
|
|
width = gimp_drawable_width (drawable_ID);
|
|
|
|
height = gimp_drawable_height (drawable_ID);
|
|
|
|
unit = gimp_image_get_unit (image_ID);
|
|
|
|
gimp_image_get_resolution (image_ID, &xres, &yres);
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
tvals.new_width = width;
|
1997-11-25 06:05:25 +08:00
|
|
|
tvals.new_height = height;
|
|
|
|
|
2005-08-16 06:42:34 +08:00
|
|
|
dlg = gimp_dialog_new (_("Tile"), PLUG_IN_BINARY,
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL, 0,
|
2007-07-31 15:48:26 +08:00
|
|
|
gimp_standard_help_func, PLUG_IN_PROC,
|
2000-01-09 04:00:10 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2000-01-09 04:00:10 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-02-09 04:40:33 +08:00
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dlg),
|
2005-08-16 06:42:34 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2005-02-09 04:40:33 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gimp_window_set_transient (GTK_WINDOW (dlg));
|
2005-09-06 05:40:29 +08:00
|
|
|
|
2004-05-20 08:50:05 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 12);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), vbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
frame = gimp_frame_new (_("Tile to New Size"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
2000-02-03 01:59:44 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2002-09-07 04:44:47 +08:00
|
|
|
sizeentry = gimp_coordinates_new (unit, "%a", TRUE, TRUE, 8,
|
2007-07-31 15:48:26 +08:00
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
2000-02-03 01:59:44 +08:00
|
|
|
|
2007-07-31 15:48:26 +08:00
|
|
|
tvals.constrain, TRUE,
|
2000-02-03 01:59:44 +08:00
|
|
|
|
2007-07-31 15:48:26 +08:00
|
|
|
_("_Width:"), width, xres,
|
|
|
|
1, GIMP_MAX_IMAGE_SIZE,
|
|
|
|
0, width,
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2007-07-31 15:48:26 +08:00
|
|
|
_("_Height:"), height, yres,
|
|
|
|
1, GIMP_MAX_IMAGE_SIZE,
|
|
|
|
0, height);
|
2000-02-03 01:59:44 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), sizeentry);
|
2004-05-20 08:50:05 +08:00
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (sizeentry), 1, 6);
|
2000-02-03 01:59:44 +08:00
|
|
|
gtk_widget_show (sizeentry);
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
chainbutton = GTK_WIDGET (GIMP_COORDINATES_CHAINBUTTON (sizeentry));
|
2000-02-03 01:59:44 +08:00
|
|
|
|
2005-08-23 08:18:08 +08:00
|
|
|
toggle = gtk_check_button_new_with_mnemonic (_("C_reate new image"));
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), tvals.new_image);
|
2004-05-20 08:50:05 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (toggle);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2002-01-08 17:20:02 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&tvals.new_image);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (dlg);
|
|
|
|
|
2003-11-12 02:11:56 +08:00
|
|
|
run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (run)
|
|
|
|
{
|
|
|
|
tvals.new_width =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (sizeentry), 0));
|
|
|
|
tvals.new_height =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (sizeentry), 1));
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
tvals.constrain =
|
|
|
|
gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (chainbutton));
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
gtk_widget_destroy (dlg);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
return run;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|