1998-09-01 22:22:59 +00:00
|
|
|
/*
|
|
|
|
* Guillotine plug-in v0.9 by Adam D. Moss, adam@foxbox.org. 1998/09/01
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* HISTORY:
|
|
|
|
* 0.9 : 1998/09/01
|
|
|
|
* Initial release.
|
|
|
|
*/
|
|
|
|
|
2000-04-30 21:03:44 +00:00
|
|
|
#include "config.h"
|
1998-09-01 22:22:59 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
2000-04-30 21:03:44 +00:00
|
|
|
|
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
|
1999-09-09 07:09:33 +00:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1998-09-01 22:22:59 +00:00
|
|
|
|
2000-04-30 21:03:44 +00:00
|
|
|
|
1998-09-01 22:22:59 +00:00
|
|
|
/* Declare local functions.
|
|
|
|
*/
|
|
|
|
static void query (void);
|
2000-04-30 21:03:44 +00:00
|
|
|
static void run (gchar *name,
|
|
|
|
gint nparams,
|
2000-08-22 01:26:57 +00:00
|
|
|
GimpParam *param,
|
2000-04-30 21:03:44 +00:00
|
|
|
gint *nreturn_vals,
|
2000-08-22 01:26:57 +00:00
|
|
|
GimpParam **return_vals);
|
1998-09-01 22:22:59 +00:00
|
|
|
|
2000-04-30 21:03:44 +00:00
|
|
|
static void guillotine (gint32 image_ID);
|
1998-09-01 22:22:59 +00:00
|
|
|
|
|
|
|
|
2000-08-22 01:26:57 +00:00
|
|
|
GimpPlugInInfo PLUG_IN_INFO =
|
1998-09-01 22:22:59 +00:00
|
|
|
{
|
2000-04-30 21:03:44 +00:00
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
|
|
|
run, /* run_proc */
|
1998-09-01 22:22:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
MAIN ()
|
|
|
|
|
|
|
|
static void
|
1999-06-21 20:04:04 +00:00
|
|
|
query (void)
|
1998-09-01 22:22:59 +00:00
|
|
|
{
|
2000-08-22 01:26:57 +00:00
|
|
|
static GimpParamDef args[] =
|
1998-09-01 22:22:59 +00:00
|
|
|
{
|
2000-08-22 01:26:57 +00:00
|
|
|
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
|
|
|
|
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
|
|
|
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable (unused)" }
|
1998-09-01 22:22:59 +00:00
|
|
|
};
|
2000-04-30 21:03:44 +00:00
|
|
|
static gint nargs = sizeof (args) / sizeof (args[0]);
|
1999-09-09 07:09:33 +00:00
|
|
|
|
1998-09-01 22:22:59 +00:00
|
|
|
gimp_install_procedure ("plug_in_guillotine",
|
2000-01-31 02:32:30 +00:00
|
|
|
"Slice up the image into subimages, cutting along the image's Guides. Fooey to you and your broccoli, Pokey.",
|
|
|
|
"This function takes an image and blah blah. Hooray!",
|
1998-09-01 22:22:59 +00:00
|
|
|
"Adam D. Moss (adam@foxbox.org)",
|
|
|
|
"Adam D. Moss (adam@foxbox.org)",
|
|
|
|
"1998",
|
1999-11-23 20:29:20 +00:00
|
|
|
N_("<Image>/Image/Transforms/Guillotine"),
|
1998-09-01 22:22:59 +00:00
|
|
|
"RGB*, INDEXED*, GRAY*",
|
2000-08-22 01:26:57 +00:00
|
|
|
GIMP_PLUGIN,
|
2000-04-30 21:03:44 +00:00
|
|
|
nargs, 0,
|
|
|
|
args, NULL);
|
1998-09-01 22:22:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-04-30 21:03:44 +00:00
|
|
|
run (gchar *name,
|
|
|
|
gint nparams,
|
2000-08-22 01:26:57 +00:00
|
|
|
GimpParam *param,
|
2000-04-30 21:03:44 +00:00
|
|
|
gint *nreturn_vals,
|
2000-08-22 01:26:57 +00:00
|
|
|
GimpParam **return_vals)
|
1998-09-01 22:22:59 +00:00
|
|
|
{
|
2000-08-22 01:26:57 +00:00
|
|
|
static GimpParam values[1];
|
1998-09-01 22:22:59 +00:00
|
|
|
gint32 image_ID;
|
2000-08-22 01:26:57 +00:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
1998-09-01 22:22:59 +00:00
|
|
|
|
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = values;
|
|
|
|
|
2000-08-22 01:26:57 +00:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
1998-09-01 22:22:59 +00:00
|
|
|
values[0].data.d_status = status;
|
|
|
|
|
1999-09-09 07:09:33 +00:00
|
|
|
INIT_I18N();
|
1998-09-01 22:22:59 +00:00
|
|
|
|
|
|
|
/* Get the specified drawable */
|
|
|
|
image_ID = param[1].data.d_image;
|
|
|
|
|
2000-08-22 01:26:57 +00:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
1998-09-01 22:22:59 +00:00
|
|
|
{
|
1999-09-09 07:09:33 +00:00
|
|
|
gimp_progress_init (_("Guillotine..."));
|
1998-09-01 22:22:59 +00:00
|
|
|
guillotine (image_ID);
|
|
|
|
gimp_displays_flush ();
|
|
|
|
}
|
|
|
|
|
|
|
|
values[0].data.d_status = status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-30 21:03:44 +00:00
|
|
|
static gint
|
|
|
|
unexciting (const void *a,
|
|
|
|
const void *b)
|
1998-09-01 22:22:59 +00:00
|
|
|
{
|
2000-04-30 21:03:44 +00:00
|
|
|
gint j = * (gint *) a;
|
|
|
|
gint k = * (gint *) b;
|
1998-09-01 22:22:59 +00:00
|
|
|
|
2000-04-30 21:03:44 +00:00
|
|
|
return (j - k);
|
1998-09-01 22:22:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2000-04-30 21:03:44 +00:00
|
|
|
guillotine (gint32 image_ID)
|
1998-09-01 22:22:59 +00:00
|
|
|
{
|
|
|
|
gint num_vguides;
|
|
|
|
gint num_hguides;
|
|
|
|
gint guide_num;
|
|
|
|
gint* hguides;
|
|
|
|
gint* vguides;
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-14 23:23:52 +00:00
|
|
|
gchar filename[1024];
|
1998-09-01 22:22:59 +00:00
|
|
|
gint i,x,y;
|
|
|
|
|
|
|
|
num_vguides = 0;
|
|
|
|
num_hguides = 0;
|
1999-04-28 07:03:35 +00:00
|
|
|
guide_num = gimp_image_find_next_guide(image_ID, 0);
|
1998-09-01 22:22:59 +00:00
|
|
|
|
|
|
|
/* Count the guides so we can allocate appropriate memory */
|
2000-04-30 21:03:44 +00:00
|
|
|
if (guide_num > 0)
|
1998-09-01 22:22:59 +00:00
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
switch (gimp_image_get_guide_orientation(image_ID, guide_num))
|
|
|
|
{
|
2000-08-22 01:26:57 +00:00
|
|
|
case GIMP_VERTICAL:
|
1998-09-01 22:22:59 +00:00
|
|
|
num_vguides++; break;
|
2000-08-22 01:26:57 +00:00
|
|
|
case GIMP_HORIZONTAL:
|
1998-09-01 22:22:59 +00:00
|
|
|
num_hguides++; break;
|
|
|
|
default:
|
2000-04-30 21:03:44 +00:00
|
|
|
g_print ("Aie! Aie! Aie!\n");
|
|
|
|
gimp_quit ();
|
1998-09-01 22:22:59 +00:00
|
|
|
}
|
2000-04-30 21:03:44 +00:00
|
|
|
guide_num = gimp_image_find_next_guide (image_ID, guide_num);
|
1998-09-01 22:22:59 +00:00
|
|
|
}
|
2000-04-30 21:03:44 +00:00
|
|
|
while (guide_num > 0);
|
1998-09-01 22:22:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (num_vguides+num_hguides)
|
|
|
|
{
|
2000-08-01 00:38:38 +00:00
|
|
|
g_print ("Yay... found %d horizontal guides and %d vertical guides.\n",
|
|
|
|
num_hguides, num_vguides);
|
1998-09-01 22:22:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-08-01 00:38:38 +00:00
|
|
|
g_print ("Poopy, no guides.\n");
|
1998-09-01 22:22:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Allocate memory for the arrays of guide offsets, build arrays */
|
|
|
|
vguides = g_malloc ((num_vguides+2) * sizeof(gint));
|
|
|
|
hguides = g_malloc ((num_hguides+2) * sizeof(gint));
|
|
|
|
num_vguides = 0;
|
|
|
|
num_hguides = 0;
|
|
|
|
vguides[num_vguides++] = 0;
|
|
|
|
hguides[num_hguides++] = 0;
|
1999-04-28 07:03:35 +00:00
|
|
|
guide_num = gimp_image_find_next_guide(image_ID, 0);
|
1998-09-01 22:22:59 +00:00
|
|
|
if (guide_num>0)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
switch (gimp_image_get_guide_orientation(image_ID, guide_num))
|
|
|
|
{
|
2000-08-22 01:26:57 +00:00
|
|
|
case GIMP_VERTICAL:
|
1998-09-01 22:22:59 +00:00
|
|
|
vguides[num_vguides++] =
|
|
|
|
gimp_image_get_guide_position(image_ID, guide_num); break;
|
2000-08-22 01:26:57 +00:00
|
|
|
case GIMP_HORIZONTAL:
|
1998-09-01 22:22:59 +00:00
|
|
|
hguides[num_hguides++] =
|
|
|
|
gimp_image_get_guide_position(image_ID, guide_num); break;
|
|
|
|
default:
|
2000-08-01 00:38:38 +00:00
|
|
|
g_print ("Aie! Aie! Aie! Too!\n");
|
1998-09-01 22:22:59 +00:00
|
|
|
gimp_quit();
|
|
|
|
}
|
1999-04-28 07:03:35 +00:00
|
|
|
guide_num = gimp_image_find_next_guide(image_ID, guide_num);
|
1998-09-01 22:22:59 +00:00
|
|
|
}
|
|
|
|
while (guide_num>0);
|
|
|
|
}
|
|
|
|
vguides[num_vguides++] = gimp_image_width(image_ID);
|
|
|
|
hguides[num_hguides++] = gimp_image_height(image_ID);
|
|
|
|
|
|
|
|
qsort(hguides, num_hguides, sizeof(gint), &unexciting);
|
|
|
|
qsort(vguides, num_vguides, sizeof(gint), &unexciting);
|
|
|
|
|
|
|
|
for (i=0;i<num_vguides;i++)
|
2000-08-01 00:38:38 +00:00
|
|
|
g_print ("%d,",vguides[i]);
|
|
|
|
g_print ("\n");
|
1998-09-01 22:22:59 +00:00
|
|
|
for (i=0;i<num_hguides;i++)
|
2000-08-01 00:38:38 +00:00
|
|
|
g_print ("%d,",hguides[i]);
|
|
|
|
g_print ("\n");
|
1998-09-01 22:22:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Do the actual dup'ing and cropping... this isn't a too naive a
|
|
|
|
way to do this since we got copy-on-write tiles, either. */
|
|
|
|
for (y=0; y<num_hguides-1; y++)
|
|
|
|
{
|
|
|
|
for (x=0; x<num_vguides-1; x++)
|
|
|
|
{
|
|
|
|
gint32 new_image;
|
|
|
|
|
2000-08-01 00:38:38 +00:00
|
|
|
new_image = gimp_channel_ops_duplicate (image_ID);
|
1998-09-01 22:22:59 +00:00
|
|
|
|
2000-08-01 00:38:38 +00:00
|
|
|
if (new_image == -1)
|
1998-09-01 22:22:59 +00:00
|
|
|
{
|
2000-08-01 00:38:38 +00:00
|
|
|
g_print ("Aie3!\n");
|
1998-09-01 22:22:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-10-17 00:07:55 +00:00
|
|
|
gimp_image_undo_disable (new_image);
|
1998-09-01 22:22:59 +00:00
|
|
|
|
2000-01-14 21:38:47 +00:00
|
|
|
/* gimp_undo_push_group_start (new_image); */
|
1998-09-01 22:22:59 +00:00
|
|
|
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-14 23:23:52 +00:00
|
|
|
/* printf("(%dx%d:%d,%d:%d,%d)\n", */
|
|
|
|
/* (vguides[x+1]-vguides[x]), */
|
|
|
|
/* (hguides[y+1]-hguides[y]), */
|
|
|
|
/* vguides[x], hguides[y],x, y); */
|
|
|
|
|
1998-09-01 22:22:59 +00:00
|
|
|
|
2000-08-01 00:38:38 +00:00
|
|
|
gimp_crop (new_image,
|
|
|
|
vguides[x+1] - vguides[x], hguides[y+1] - hguides[y],
|
|
|
|
vguides[x], hguides[y]);
|
1998-09-01 22:22:59 +00:00
|
|
|
|
2000-01-14 21:38:47 +00:00
|
|
|
/* gimp_undo_push_group_end (new_image); */
|
1998-09-01 22:22:59 +00:00
|
|
|
|
1999-10-17 00:07:55 +00:00
|
|
|
gimp_image_undo_enable (new_image);
|
1998-09-01 22:22:59 +00:00
|
|
|
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-14 23:23:52 +00:00
|
|
|
/* show the rough coordinates of the image in the title */
|
2000-08-01 00:38:38 +00:00
|
|
|
g_snprintf (filename, sizeof (filename), "%s-(%i,%i)", gimp_image_get_filename (image_ID),
|
|
|
|
x, y);
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-14 23:23:52 +00:00
|
|
|
gimp_image_set_filename(new_image, filename);
|
|
|
|
|
1998-09-01 22:22:59 +00:00
|
|
|
gimp_display_new (new_image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|