Makefile.am added removed

2000-03-24  Michael Natterer  <mitch@gimp.org>

	* Makefile.am
	* gimp1_0_splash.ppm: added
	* gimp1_1_splash.ppm: removed

	* gimp_splash.ppm: the image formerly known as gimp1_1_splash.ppm

	* app/app_procs.c: load gimp_splash.ppm

	The idea if shearing the data_dir between Gimp versions has
	vanished, so this seems like the right thing to do (TM).

	Keep the 1.0 splash around for sentimental reasons but don't
	install it anymore.

	* plug-ins/common/autocrop.c: indentation paranoia.
This commit is contained in:
Michael Natterer 2000-03-24 21:57:32 +00:00 committed by Michael Natterer
parent e1e5850745
commit de5268781e
9 changed files with 1012 additions and 163 deletions

View File

@ -1,3 +1,21 @@
2000-03-24 Michael Natterer <mitch@gimp.org>
* Makefile.am
* gimp1_0_splash.ppm: added
* gimp1_1_splash.ppm: removed
* gimp_splash.ppm: the image formerly known as gimp1_1_splash.ppm
* app/app_procs.c: load gimp_splash.ppm
The idea if shearing the data_dir between Gimp versions has
vanished, so this seems like the right thing to do (TM).
Keep the 1.0 splash around for sentimental reasons but don't
install it anymore.
* plug-ins/common/autocrop.c: indentation paranoia.
2000-03-24 Michael Natterer <mitch@gimp.org>
* app/plug_in.c (plug_in_proc_def_remove): pass FALSE to

View File

@ -103,7 +103,7 @@ EXTRA_DIST = \
unitrc \
gimp_logo.ppm \
gimp_splash.ppm \
gimp1_1_splash.ppm \
gimp1_0_splash.ppm \
rmshm \
user_install \
user_install.bat \
@ -122,7 +122,6 @@ gimpdata_DATA = \
unitrc \
gimp_logo.ppm \
gimp_splash.ppm \
gimp1_1_splash.ppm \
ps-menurc
gimpdata_SCRIPTS = user_install

View File

@ -162,7 +162,7 @@ splash_logo_load_size (GtkWidget *window)
if (logo_pixmap)
return TRUE;
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp1_1_splash.ppm",
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp_splash.ppm",
gimp_data_directory ());
fp = fopen (buf, "rb");
@ -199,7 +199,7 @@ splash_logo_load (GtkWidget *window)
if (logo_pixmap)
return TRUE;
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp1_1_splash.ppm",
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp_splash.ppm",
gimp_data_directory ());
fp = fopen (buf, "rb");

File diff suppressed because one or more lines are too long

Binary file not shown.

392
gimp1_0_splash.ppm Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View File

@ -18,61 +18,69 @@
#include "libgimp/stdplugins-intl.h"
/* Declare local functions. */
static void query(void);
static void run(char *name,
int nparams,
GParam * param,
int *nreturn_vals,
GParam ** return_vals);
static int colors_equal(guchar *col1, guchar *col2, int bytes);
static int guess_bgcolor(GPixelRgn *pr, int width, int height, int bytes,
guchar *color);
static void query (void);
static void run (gchar *name,
gint nparams,
GParam *param,
gint *nreturn_vals,
GParam **return_vals);
static void doit(GDrawable *drawable, gint32);
static gint colors_equal (guchar *col1,
guchar *col2,
gint bytes);
static gint guess_bgcolor (GPixelRgn *pr,
gint width,
gint height,
gint bytes,
guchar *color);
static void doit (GDrawable *drawable,
gint32 image_id);
GPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
};
gint bytes;
gint sx1, sy1, sx2, sy2;
int run_flag = 0;
static gint bytes;
static gint sx1, sy1, sx2, sy2;
static gint run_flag = FALSE;
MAIN()
static void query()
static void
query (void)
{
static GParamDef args[] =
{
{PARAM_INT32, "run_mode", "Interactive, non-interactive"},
{PARAM_IMAGE, "image", "Input image"},
{PARAM_DRAWABLE, "drawable", "Input drawable"},
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
{ PARAM_IMAGE, "image", "Input image" },
{ PARAM_DRAWABLE, "drawable", "Input drawable" },
};
static GParamDef *return_vals = NULL;
static int nargs = sizeof(args) / sizeof(args[0]);
static int nreturn_vals = 0;
static gint nargs = sizeof (args) / sizeof (args[0]);
INIT_I18N();
gimp_install_procedure("plug_in_autocrop",
"Automagically crops a picture.",
"",
"Tim Newsome",
"Tim Newsome",
"1997",
N_("<Image>/Image/Transforms/Autocrop"),
"RGB*, GRAY*, INDEXED*",
PROC_PLUG_IN,
nargs, nreturn_vals,
args, return_vals);
gimp_install_procedure ("plug_in_autocrop",
"Automagically crops a picture.",
"",
"Tim Newsome",
"Tim Newsome",
"1997",
N_("<Image>/Image/Transforms/Autocrop"),
"RGB*, GRAY*, INDEXED*",
PROC_PLUG_IN,
nargs, 0,
args, NULL);
}
static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
GParam ** return_vals)
static void
run (gchar *name,
gint n_params,
GParam *param,
gint *nreturn_vals,
GParam **return_vals)
{
static GParam values[1];
GDrawable *drawable;
@ -87,47 +95,51 @@ static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
INIT_I18N();
if (run_mode == RUN_NONINTERACTIVE) {
if (n_params != 3)
status = STATUS_CALLING_ERROR;
}
if (run_mode == RUN_NONINTERACTIVE)
{
if (n_params != 3)
status = STATUS_CALLING_ERROR;
}
if (status == STATUS_SUCCESS) {
/* Get the specified drawable */
drawable = gimp_drawable_get(param[2].data.d_drawable);
image_id = param[1].data.d_image;
/* Make sure that the drawable is gray or RGB color */
if (gimp_drawable_is_rgb(drawable->id) ||
gimp_drawable_is_gray(drawable->id) ||
gimp_drawable_is_indexed(drawable->id))
{
gimp_progress_init(_("Cropping..."));
gimp_tile_cache_ntiles(2 * (drawable->width / gimp_tile_width() + 1));
doit(drawable, image_id);
if (run_mode != RUN_NONINTERACTIVE)
gimp_displays_flush();
}
else
{
status = STATUS_EXECUTION_ERROR;
}
if (status == STATUS_SUCCESS)
{
/* Get the specified drawable */
drawable = gimp_drawable_get (param[2].data.d_drawable);
image_id = param[1].data.d_image;
values[0].type = PARAM_STATUS;
values[0].data.d_status = status;
}
/* Make sure that the drawable is gray or RGB color */
if (gimp_drawable_is_rgb (drawable->id) ||
gimp_drawable_is_gray (drawable->id) ||
gimp_drawable_is_indexed (drawable->id))
{
gimp_progress_init (_("Cropping..."));
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width() + 1));
doit (drawable, image_id);
if (run_mode != RUN_NONINTERACTIVE)
gimp_displays_flush ();
}
else
{
status = STATUS_EXECUTION_ERROR;
}
values[0].type = PARAM_STATUS;
values[0].data.d_status = status;
}
}
static void doit(GDrawable *drawable, gint32 image_id)
static void
doit (GDrawable *drawable,
gint32 image_id)
{
GPixelRgn srcPR;
gint width, height;
int x, y, abort;
gint x, y, abort;
gint32 nx, ny, nw, nh;
guchar *buffer;
guchar color[4] = {0, 0, 0, 0};
int nreturn_vals;
gint nreturn_vals;
width = drawable->width;
height = drawable->height;
@ -139,90 +151,105 @@ static void doit(GDrawable *drawable, gint32 image_id)
nh = height;
/* initialize the pixel regions */
gimp_pixel_rgn_init(&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
/* First, let's figure out what exactly to crop. */
buffer = g_malloc((width > height ? width : height) * bytes);
buffer = g_malloc ((width > height ? width : height) * bytes);
guess_bgcolor(&srcPR, width, height, bytes, color);
guess_bgcolor (&srcPR, width, height, bytes, color);
/* Check how many of the top lines are uniform. */
abort = 0;
for (y = 0; y < height && !abort; y++) {
gimp_pixel_rgn_get_row(&srcPR, buffer, 0, y, width);
for (x = 0; x < width && !abort; x++) {
abort = !colors_equal(color, buffer + x * bytes, bytes);
for (y = 0; y < height && !abort; y++)
{
gimp_pixel_rgn_get_row (&srcPR, buffer, 0, y, width);
for (x = 0; x < width && !abort; x++)
{
abort = !colors_equal (color, buffer + x * bytes, bytes);
}
}
if (y == height && !abort)
{
g_free (buffer);
gimp_drawable_detach (drawable);
return;
}
}
if (y == height && !abort) {
g_free(buffer);
gimp_drawable_detach(drawable);
return;
}
y--;
ny = y;
nh = height - y;
gimp_progress_update(.25);
gimp_progress_update (0.25);
/* Check how many of the bottom lines are uniform. */
abort = 0;
for (y = height - 1; y >= 0 && !abort; y--) {
gimp_pixel_rgn_get_row(&srcPR, buffer, 0, y, width);
for (x = 0; x < width && !abort; x++) {
abort = !colors_equal(color, buffer + x * bytes, bytes);
for (y = height - 1; y >= 0 && !abort; y--)
{
gimp_pixel_rgn_get_row (&srcPR, buffer, 0, y, width);
for (x = 0; x < width && !abort; x++)
{
abort = !colors_equal (color, buffer + x * bytes, bytes);
}
}
}
nh = y - ny + 2;
gimp_progress_update(.5);
gimp_progress_update (0.5);
/* Check how many of the left lines are uniform. */
abort = 0;
for (x = 0; x < width && !abort; x++) {
gimp_pixel_rgn_get_col(&srcPR, buffer, x, ny, nh);
for (y = 0; y < nh && !abort; y++) {
abort = !colors_equal(color, buffer + y * bytes, bytes);
for (x = 0; x < width && !abort; x++)
{
gimp_pixel_rgn_get_col (&srcPR, buffer, x, ny, nh);
for (y = 0; y < nh && !abort; y++)
{
abort = !colors_equal (color, buffer + y * bytes, bytes);
}
}
}
x--;
nx = x;
nw = width - x;
gimp_progress_update(.75);
gimp_progress_update (0.75);
/* Check how many of the right lines are uniform. */
abort = 0;
for (x = width - 1; x >= 0 && !abort; x--) {
gimp_pixel_rgn_get_col(&srcPR, buffer, x, ny, nh);
for (y = 0; y < nh && !abort; y++) {
abort = !colors_equal(color, buffer + y * bytes, bytes);
for (x = width - 1; x >= 0 && !abort; x--)
{
gimp_pixel_rgn_get_col (&srcPR, buffer, x, ny, nh);
for (y = 0; y < nh && !abort; y++)
{
abort = !colors_equal (color, buffer + y * bytes, bytes);
}
}
}
nw = x - nx + 2;
g_free(buffer);
g_free (buffer);
gimp_drawable_detach(drawable);
if (nw != width || nh != height) {
gimp_run_procedure("gimp_crop", &nreturn_vals,
PARAM_IMAGE, image_id,
PARAM_INT32, nw,
PARAM_INT32, nh,
PARAM_INT32, nx,
PARAM_INT32, ny,
PARAM_END);
}
gimp_drawable_detach (drawable);
if (nw != width || nh != height)
{
gimp_run_procedure ("gimp_crop", &nreturn_vals,
PARAM_IMAGE, image_id,
PARAM_INT32, nw,
PARAM_INT32, nh,
PARAM_INT32, nx,
PARAM_INT32, ny,
PARAM_END);
}
}
static int guess_bgcolor(GPixelRgn *pr, int width, int height, int bytes,
guchar *color) {
static gint
guess_bgcolor (GPixelRgn *pr,
gint width,
gint height,
gint bytes,
guchar *color)
{
guchar tl[4], tr[4], bl[4], br[4];
gimp_pixel_rgn_get_pixel(pr, tl, 0, 0);
gimp_pixel_rgn_get_pixel(pr, tr, width - 1, 0);
gimp_pixel_rgn_get_pixel(pr, bl, 0, height - 1);
gimp_pixel_rgn_get_pixel(pr, br, width - 1, height - 1);
gimp_pixel_rgn_get_pixel (pr, tl, 0, 0);
gimp_pixel_rgn_get_pixel (pr, tr, width - 1, 0);
gimp_pixel_rgn_get_pixel (pr, bl, 0, height - 1);
gimp_pixel_rgn_get_pixel (pr, br, width - 1, height - 1);
/* Algorithm pinched from pnmcrop.
* To guess the background, first see if 3 corners are equal.
@ -230,54 +257,75 @@ static int guess_bgcolor(GPixelRgn *pr, int width, int height, int bytes,
* Otherwise average the colors.
*/
if (colors_equal(tr, bl, bytes) && colors_equal(tr, br, bytes)) {
memcpy(color, tr, bytes);
return 3;
} else if (colors_equal(tl, bl, bytes) && colors_equal(tl, br, bytes)) {
memcpy(color, tl, bytes);
return 3;
} else if (colors_equal(tl, tr, bytes) && colors_equal(tl, br, bytes)) {
memcpy(color, tl, bytes);
return 3;
} else if (colors_equal(tl, tr, bytes) && colors_equal(tl, bl, bytes)) {
memcpy(color, tl, bytes);
return 3;
} else if (colors_equal(tl, tr, bytes) || colors_equal(tl, bl, bytes) ||
colors_equal(tl, br, bytes)) {
memcpy(color, tl, bytes);
return 2;
} else if (colors_equal(tr, bl, bytes) || colors_equal(tr, bl, bytes)) {
memcpy(color, tr, bytes);
return 2;
} else if (colors_equal(br, bl, bytes)) {
memcpy(color, br, bytes);
return 2;
} else {
while (bytes--) {
color[bytes] = (tl[bytes] + tr[bytes] + bl[bytes] + br[bytes]) / 4;
if (colors_equal (tr, bl, bytes) && colors_equal (tr, br, bytes))
{
memcpy (color, tr, bytes);
return 3;
}
else if (colors_equal (tl, bl, bytes) && colors_equal (tl, br, bytes))
{
memcpy (color, tl, bytes);
return 3;
}
else if (colors_equal (tl, tr, bytes) && colors_equal (tl, br, bytes))
{
memcpy (color, tl, bytes);
return 3;
}
else if (colors_equal (tl, tr, bytes) && colors_equal (tl, bl, bytes))
{
memcpy (color, tl, bytes);
return 3;
}
else if (colors_equal (tl, tr, bytes) || colors_equal (tl, bl, bytes) ||
colors_equal (tl, br, bytes))
{
memcpy (color, tl, bytes);
return 2;
}
else if (colors_equal (tr, bl, bytes) || colors_equal (tr, bl, bytes))
{
memcpy (color, tr, bytes);
return 2;
}
else if (colors_equal (br, bl, bytes))
{
memcpy (color, br, bytes);
return 2;
}
else
{
while (bytes--)
{
color[bytes] = (tl[bytes] + tr[bytes] + bl[bytes] + br[bytes]) / 4;
}
return 0;
}
return 0;
}
}
static int
colors_equal(guchar *col1, guchar *col2, int bytes) {
int equal = 1;
int b;
static gint
colors_equal (guchar *col1,
guchar *col2,
gint bytes)
{
gint equal = 1;
gint b;
if ((bytes == 2 || bytes == 4) && /* HACK! */
col1[bytes-1] == 0 &&
col2[bytes-1] == 0) {
return 1; /* handle zero alpha */
}
for (b = 0; b < bytes; b++) {
if (col1[b] != col2[b]) {
equal = 0;
break;
col2[bytes-1] == 0)
{
return 1; /* handle zero alpha */
}
for (b = 0; b < bytes; b++)
{
if (col1[b] != col2[b])
{
equal = 0;
break;
}
}
}
return equal;
}