1997-11-25 06:05:25 +08:00
|
|
|
/*
|
|
|
|
* Autocrop plug-in version 1.00
|
|
|
|
* by Tim Newsome <drz@froody.bloke.com>
|
|
|
|
*/
|
|
|
|
|
2004-05-10 02:45:14 +08:00
|
|
|
/* 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.
|
2004-05-06 21:51:56 +08:00
|
|
|
*/
|
1999-04-09 07:54:14 +08:00
|
|
|
|
2000-05-01 05:03:44 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1999-05-29 09:28:24 +08:00
|
|
|
#include <string.h>
|
2000-05-01 05:03:44 +08:00
|
|
|
|
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
|
1999-09-09 15:09:33 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-01 05:03:44 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Declare local functions. */
|
2004-05-29 19:29:37 +08:00
|
|
|
static void query (void);
|
|
|
|
static void run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
|
|
|
|
|
|
|
static gboolean colors_equal (const guchar *col1,
|
|
|
|
const guchar *col2,
|
|
|
|
gint bytes);
|
|
|
|
static gint guess_bgcolor (GimpPixelRgn *pr,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint bytes,
|
|
|
|
guchar *color);
|
|
|
|
|
2004-09-05 23:06:53 +08:00
|
|
|
static void autocrop (GimpDrawable *drawable,
|
2004-05-29 19:29:37 +08:00
|
|
|
gint32 image_id,
|
|
|
|
gboolean show_progress,
|
|
|
|
gboolean layer_only);
|
2001-07-07 22:53:42 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpPlugInInfo PLUG_IN_INFO =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-12-24 06:07:06 +08:00
|
|
|
NULL, /* init_proc */
|
2000-03-25 05:57:32 +08:00
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
2003-12-24 06:07:06 +08:00
|
|
|
run, /* run_proc */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2000-03-25 05:57:32 +08:00
|
|
|
static gint bytes;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2000-05-01 05:03:44 +08:00
|
|
|
MAIN ()
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-03-25 05:57:32 +08:00
|
|
|
static void
|
|
|
|
query (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpParamDef args[] =
|
1999-04-09 07:54:14 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
|
|
|
|
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
|
|
|
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" }
|
1999-04-09 07:54:14 +08:00
|
|
|
};
|
1999-09-09 15:09:33 +08:00
|
|
|
|
2000-03-25 05:57:32 +08:00
|
|
|
gimp_install_procedure ("plug_in_autocrop",
|
2004-06-01 18:45:15 +08:00
|
|
|
"Automagically crops an image.",
|
2003-12-24 06:07:06 +08:00
|
|
|
"",
|
|
|
|
"Tim Newsome",
|
|
|
|
"Tim Newsome",
|
|
|
|
"1997",
|
2004-06-01 18:45:15 +08:00
|
|
|
N_("_Autocrop Image"),
|
2003-12-24 06:07:06 +08:00
|
|
|
"RGB*, GRAY*, INDEXED*",
|
|
|
|
GIMP_PLUGIN,
|
|
|
|
G_N_ELEMENTS (args), 0,
|
|
|
|
args, NULL);
|
2004-05-07 08:30:24 +08:00
|
|
|
|
|
|
|
gimp_plugin_menu_register ("plug_in_autocrop",
|
|
|
|
N_("<Image>/Image/Crop"));
|
2004-05-29 19:29:37 +08:00
|
|
|
|
|
|
|
gimp_install_procedure ("plug_in_autocrop_layer",
|
|
|
|
"Automagically crops a layer.",
|
|
|
|
"",
|
|
|
|
"Tim Newsome",
|
|
|
|
"Tim Newsome",
|
|
|
|
"1997",
|
2004-06-01 18:45:15 +08:00
|
|
|
N_("_Autocrop Layer"),
|
2004-05-29 19:29:37 +08:00
|
|
|
"RGB*, GRAY*, INDEXED*",
|
|
|
|
GIMP_PLUGIN,
|
|
|
|
G_N_ELEMENTS (args), 0,
|
|
|
|
args, NULL);
|
|
|
|
|
|
|
|
gimp_plugin_menu_register ("plug_in_autocrop_layer",
|
|
|
|
N_("<Image>/Layer/Crop"));
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-03-25 05:57:32 +08:00
|
|
|
static void
|
2003-07-02 02:54:28 +08:00
|
|
|
run (const gchar *name,
|
|
|
|
gint n_params,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-07 22:53:42 +08:00
|
|
|
static GimpParam values[1];
|
|
|
|
GimpDrawable *drawable;
|
2003-07-02 02:54:28 +08:00
|
|
|
GimpRunMode run_mode;
|
2001-07-07 22:53:42 +08:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
|
|
|
gint32 image_id;
|
|
|
|
gboolean interactive;
|
2000-12-12 19:53:47 +08:00
|
|
|
|
1999-04-09 07:54:14 +08:00
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = values;
|
2004-05-06 21:51:56 +08:00
|
|
|
|
1999-04-09 07:54:14 +08:00
|
|
|
run_mode = param[0].data.d_int32;
|
2000-12-12 19:53:47 +08:00
|
|
|
interactive = (run_mode != GIMP_RUN_NONINTERACTIVE);
|
1999-09-09 15:09:33 +08:00
|
|
|
|
|
|
|
INIT_I18N();
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2000-12-12 19:53:47 +08:00
|
|
|
if (n_params != 3)
|
2000-03-25 05:57:32 +08:00
|
|
|
{
|
2000-12-12 19:53:47 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
goto out;
|
2000-03-25 05:57:32 +08:00
|
|
|
}
|
|
|
|
|
2000-12-12 19:53:47 +08:00
|
|
|
/* Get the specified drawable */
|
|
|
|
drawable = gimp_drawable_get (param[2].data.d_drawable);
|
|
|
|
image_id = param[1].data.d_image;
|
2000-03-25 05:57:32 +08:00
|
|
|
|
2000-12-12 19:53:47 +08:00
|
|
|
/* Make sure that the drawable is gray or RGB color */
|
2001-06-15 04:07:38 +08:00
|
|
|
if (gimp_drawable_is_rgb (drawable->drawable_id) ||
|
|
|
|
gimp_drawable_is_gray (drawable->drawable_id) ||
|
2004-05-06 21:51:56 +08:00
|
|
|
gimp_drawable_is_indexed (drawable->drawable_id))
|
2000-12-12 19:53:47 +08:00
|
|
|
{
|
|
|
|
if (interactive)
|
|
|
|
gimp_progress_init (_("Cropping..."));
|
|
|
|
|
|
|
|
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width() + 1));
|
|
|
|
|
2004-09-05 23:06:53 +08:00
|
|
|
autocrop (drawable, image_id, interactive,
|
|
|
|
! strcmp (name, "plug_in_autocrop_layer"));
|
2000-12-12 19:53:47 +08:00
|
|
|
|
|
|
|
if (interactive)
|
|
|
|
gimp_displays_flush ();
|
2004-05-06 21:51:56 +08:00
|
|
|
}
|
|
|
|
else
|
2000-12-12 19:53:47 +08:00
|
|
|
{
|
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
|
|
|
values[0].data.d_status = status;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-03-25 05:57:32 +08:00
|
|
|
static void
|
2004-09-05 23:06:53 +08:00
|
|
|
autocrop (GimpDrawable *drawable,
|
|
|
|
gint32 image_id,
|
|
|
|
gboolean show_progress,
|
|
|
|
gboolean layer_only)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-07 22:53:42 +08:00
|
|
|
GimpPixelRgn srcPR;
|
|
|
|
gint width, height;
|
2004-09-05 23:06:53 +08:00
|
|
|
gint off_x, off_y;
|
|
|
|
gint x1, y1, x2, y2, i;
|
|
|
|
gboolean abort;
|
2001-07-07 22:53:42 +08:00
|
|
|
guchar *buffer;
|
|
|
|
guchar color[4] = {0, 0, 0, 0};
|
2004-05-29 19:29:37 +08:00
|
|
|
gint32 layer_id = 0;
|
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
width = drawable->width;
|
1999-04-09 07:54:14 +08:00
|
|
|
height = drawable->height;
|
2001-07-07 22:53:42 +08:00
|
|
|
bytes = drawable->bpp;
|
2004-09-05 23:06:53 +08:00
|
|
|
gimp_drawable_offsets (drawable->drawable_id, &off_x, &off_y);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2004-05-29 19:29:37 +08:00
|
|
|
if (layer_only)
|
|
|
|
{
|
|
|
|
layer_id = gimp_image_get_active_layer (image_id);
|
|
|
|
if (layer_id == -1)
|
|
|
|
{
|
|
|
|
gimp_drawable_detach (drawable);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-09 07:54:14 +08:00
|
|
|
/* initialize the pixel regions */
|
2000-03-25 05:57:32 +08:00
|
|
|
gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
1999-04-09 07:54:14 +08:00
|
|
|
/* First, let's figure out what exactly to crop. */
|
2000-03-25 05:57:32 +08:00
|
|
|
buffer = g_malloc ((width > height ? width : height) * bytes);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2000-03-25 05:57:32 +08:00
|
|
|
guess_bgcolor (&srcPR, width, height, bytes, color);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
1999-04-09 07:54:14 +08:00
|
|
|
/* Check how many of the top lines are uniform. */
|
2004-09-05 23:06:53 +08:00
|
|
|
abort = FALSE;
|
|
|
|
for (y1 = 0; y1 < height; y1++)
|
2000-03-25 05:57:32 +08:00
|
|
|
{
|
2004-09-05 23:06:53 +08:00
|
|
|
gimp_pixel_rgn_get_row (&srcPR, buffer, 0, y1, width);
|
|
|
|
for (i = 0; i < width && !abort; i++)
|
|
|
|
abort = !colors_equal (color, buffer + i * bytes, bytes);
|
|
|
|
|
|
|
|
if (abort) break;
|
2000-03-25 05:57:32 +08:00
|
|
|
}
|
2004-09-05 23:06:53 +08:00
|
|
|
if (y1 == height - 1 && !abort)
|
2000-03-25 05:57:32 +08:00
|
|
|
{
|
2004-09-05 23:06:53 +08:00
|
|
|
/* whee - a plain color drawable. Do nothing. */
|
2000-03-25 05:57:32 +08:00
|
|
|
g_free (buffer);
|
|
|
|
gimp_drawable_detach (drawable);
|
|
|
|
return;
|
1999-04-09 07:54:14 +08:00
|
|
|
}
|
2000-12-12 19:53:47 +08:00
|
|
|
|
|
|
|
if (show_progress)
|
|
|
|
gimp_progress_update (0.25);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
1999-04-09 07:54:14 +08:00
|
|
|
/* Check how many of the bottom lines are uniform. */
|
2004-09-05 23:06:53 +08:00
|
|
|
abort = FALSE;
|
|
|
|
for (y2 = height - 1; y2 >= 0; y2--)
|
2000-03-25 05:57:32 +08:00
|
|
|
{
|
2004-09-05 23:06:53 +08:00
|
|
|
gimp_pixel_rgn_get_row (&srcPR, buffer, 0, y2, width);
|
|
|
|
for (i = 0; i < width && !abort; i++)
|
|
|
|
abort = !colors_equal (color, buffer + i * bytes, bytes);
|
|
|
|
|
|
|
|
if (abort) break;
|
1999-04-09 07:54:14 +08:00
|
|
|
}
|
2004-09-05 23:06:53 +08:00
|
|
|
|
|
|
|
y2 += 1; /* to make y2 - y1 == height */
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2000-12-12 19:53:47 +08:00
|
|
|
if (show_progress)
|
|
|
|
gimp_progress_update (0.5);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
1999-04-09 07:54:14 +08:00
|
|
|
/* Check how many of the left lines are uniform. */
|
2004-09-05 23:06:53 +08:00
|
|
|
abort = FALSE;
|
|
|
|
for (x1 = 0; x1 < width; x1++)
|
2000-03-25 05:57:32 +08:00
|
|
|
{
|
2004-09-05 23:06:53 +08:00
|
|
|
gimp_pixel_rgn_get_col (&srcPR, buffer, x1, y1, y2-y1);
|
|
|
|
for (i = 0; i < y2-y1 && !abort; i++)
|
|
|
|
abort = !colors_equal (color, buffer + i * bytes, bytes);
|
|
|
|
|
|
|
|
if (abort) break;
|
1999-04-09 07:54:14 +08:00
|
|
|
}
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2000-12-12 19:53:47 +08:00
|
|
|
if (show_progress)
|
|
|
|
gimp_progress_update (0.75);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
1999-04-09 07:54:14 +08:00
|
|
|
/* Check how many of the right lines are uniform. */
|
2004-09-05 23:06:53 +08:00
|
|
|
abort = FALSE;
|
|
|
|
for (x2 = width - 1; x2 >= 0; x2--)
|
2000-03-25 05:57:32 +08:00
|
|
|
{
|
2004-09-05 23:06:53 +08:00
|
|
|
gimp_pixel_rgn_get_col (&srcPR, buffer, x2, y1, y2-y1);
|
|
|
|
for (i = 0; i < y2-y1 && !abort; i++)
|
|
|
|
abort = !colors_equal (color, buffer + i * bytes, bytes);
|
|
|
|
|
|
|
|
if (abort) break;
|
1999-04-09 07:54:14 +08:00
|
|
|
}
|
2004-09-05 23:06:53 +08:00
|
|
|
|
|
|
|
x2 += 1; /* to make x2 - x1 == width */
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2000-03-25 05:57:32 +08:00
|
|
|
g_free (buffer);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2000-03-25 05:57:32 +08:00
|
|
|
gimp_drawable_detach (drawable);
|
2000-08-01 08:38:38 +08:00
|
|
|
|
2004-09-05 23:06:53 +08:00
|
|
|
if (x2-x1 != width || y2-y1 != height)
|
2004-05-29 19:29:37 +08:00
|
|
|
{
|
|
|
|
if (layer_only)
|
2004-09-05 23:06:53 +08:00
|
|
|
{
|
|
|
|
gimp_layer_resize (layer_id, x2-x1, y2-y1, -x1, -y1);
|
|
|
|
}
|
2004-05-29 19:29:37 +08:00
|
|
|
else
|
2004-09-05 23:06:53 +08:00
|
|
|
{
|
|
|
|
/* convert to image coordinates */
|
|
|
|
x1 += off_x; x2 += off_x;
|
|
|
|
y1 += off_y; y2 += off_y;
|
|
|
|
|
|
|
|
gimp_image_undo_group_start (image_id);
|
|
|
|
|
|
|
|
if (x1 < 0 || y1 < 0 ||
|
|
|
|
x2 > gimp_image_width (image_id) ||
|
|
|
|
y2 > gimp_image_height (image_id))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* partially outside the image area, we need to
|
|
|
|
* resize the image to be able to crop properly.
|
|
|
|
*/
|
|
|
|
gimp_image_resize (image_id, x2-x1, y2-y1, -x1, -y1);
|
|
|
|
x2 -= x1;
|
|
|
|
y2 -= y1;
|
|
|
|
x1 = y1 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_image_crop (image_id, x2-x1, y2-y1, x1, y1);
|
|
|
|
|
|
|
|
gimp_image_undo_group_end (image_id);
|
|
|
|
}
|
2004-05-29 19:29:37 +08:00
|
|
|
}
|
2000-12-12 19:53:47 +08:00
|
|
|
|
|
|
|
if (show_progress)
|
|
|
|
gimp_progress_update (1.00);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-03-25 05:57:32 +08:00
|
|
|
static gint
|
2000-08-22 09:26:57 +08:00
|
|
|
guess_bgcolor (GimpPixelRgn *pr,
|
2003-12-24 06:07:06 +08:00
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint bytes,
|
|
|
|
guchar *color)
|
2000-03-25 05:57:32 +08:00
|
|
|
{
|
1999-04-09 07:54:14 +08:00
|
|
|
guchar tl[4], tr[4], bl[4], br[4];
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2000-03-25 05:57:32 +08:00
|
|
|
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);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
1999-04-09 07:54:14 +08:00
|
|
|
/* Algorithm pinched from pnmcrop.
|
|
|
|
* To guess the background, first see if 3 corners are equal.
|
|
|
|
* Then if two are equal.
|
|
|
|
* Otherwise average the colors.
|
|
|
|
*/
|
|
|
|
|
2000-03-25 05:57:32 +08:00
|
|
|
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) ||
|
2003-12-24 06:07:06 +08:00
|
|
|
colors_equal (tl, br, bytes))
|
2000-03-25 05:57:32 +08:00
|
|
|
{
|
|
|
|
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--)
|
2003-12-24 06:07:06 +08:00
|
|
|
{
|
|
|
|
color[bytes] = (tl[bytes] + tr[bytes] + bl[bytes] + br[bytes]) / 4;
|
|
|
|
}
|
2000-03-25 05:57:32 +08:00
|
|
|
return 0;
|
1999-04-09 07:54:14 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-05-10 02:45:14 +08:00
|
|
|
static gboolean
|
|
|
|
colors_equal (const guchar *col1,
|
|
|
|
const guchar *col2,
|
|
|
|
gint bytes)
|
2000-03-25 05:57:32 +08:00
|
|
|
{
|
2004-05-10 02:45:14 +08:00
|
|
|
gboolean equal = TRUE;
|
2000-03-25 05:57:32 +08:00
|
|
|
gint b;
|
1999-10-07 23:05:49 +08:00
|
|
|
|
2003-12-24 06:07:06 +08:00
|
|
|
if ((bytes == 2 || bytes == 4) && /* HACK! */
|
1999-10-07 23:05:49 +08:00
|
|
|
col1[bytes-1] == 0 &&
|
2000-03-25 05:57:32 +08:00
|
|
|
col2[bytes-1] == 0)
|
|
|
|
{
|
2004-05-10 02:45:14 +08:00
|
|
|
return TRUE; /* handle zero alpha */
|
2000-03-25 05:57:32 +08:00
|
|
|
}
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2000-03-25 05:57:32 +08:00
|
|
|
for (b = 0; b < bytes; b++)
|
|
|
|
{
|
|
|
|
if (col1[b] != col2[b])
|
2003-12-24 06:07:06 +08:00
|
|
|
{
|
2004-05-10 02:45:14 +08:00
|
|
|
equal = FALSE;
|
2003-12-24 06:07:06 +08:00
|
|
|
break;
|
|
|
|
}
|
1999-04-09 07:54:14 +08:00
|
|
|
}
|
2004-05-06 21:51:56 +08:00
|
|
|
|
1999-04-09 07:54:14 +08:00
|
|
|
return equal;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|