Commit 3d3d8eac authored by Manish Singh's avatar Manish Singh

fix for indexed images

        * app/by_color_select.c: fix for indexed images

        * plug-ins/script-fu/scripts/i26-gunya2.scm: proper registration

        * plug-ins/xpm.c: fix for transparent images

        * Updated to libtool 1.0h

        * libgimp/Makefile.am: removed spurious -rpath

-Yosh
parent 41385b71
Mon Jan 5 19:30:38 PST 1998 Manish Singh <yosh@gimp.org>
* app/by_color_select.c: fix for indexed images
* plug-ins/script-fu/scripts/i26-gunya2.scm: proper registration
* plug-ins/xpm.c: fix for transparent images
* Updated to libtool 1.0h
* libgimp/Makefile.am: removed spurious -rpath
Sun Jan 4 17:43:32 PST 1998 Manish Singh <yosh@gimp.org>
* app/by_color_select.c: Prevent divide-by-zero error when
......
......@@ -157,9 +157,9 @@ by_color_select_color (GImage *gimage,
unsigned char *mask_data;
unsigned char *idata, *mdata;
unsigned char rgb[MAX_CHANNELS];
int has_alpha;
int has_alpha, indexed;
int width, height;
int bytes, alpha;
int bytes, color_bytes, alpha;
int i, j;
void * pr;
int d_type;
......@@ -172,6 +172,7 @@ by_color_select_color (GImage *gimage,
has_alpha = (d_type == RGBA_GIMAGE ||
d_type == GRAYA_GIMAGE ||
d_type == INDEXEDA_GIMAGE);
indexed = d_type == INDEXEDA_GIMAGE || d_type == INDEXED_GIMAGE;
width = gimage->width;
height = gimage->height;
pixel_region_init (&imagePR, gimage_composite (gimage), 0, 0, width, height, FALSE);
......@@ -181,12 +182,21 @@ by_color_select_color (GImage *gimage,
bytes = drawable_bytes (drawable);
d_type = drawable_type (drawable);
has_alpha = drawable_has_alpha (drawable);
indexed = drawable_indexed (drawable);
width = drawable_width (drawable);
height = drawable_height (drawable);
pixel_region_init (&imagePR, drawable_data (drawable), 0, 0, width, height, FALSE);
}
if (indexed) {
/* indexed colors are always RGB or RGBA */
color_bytes = has_alpha ? 4 : 3;
} else {
/* RGB, RGBA, GRAY and GRAYA colors are shaped just like the image */
color_bytes = bytes;
}
alpha = bytes - 1;
mask = channel_new_mask (gimage->ID, width, height);
pixel_region_init (&maskPR, mask->tiles, 0, 0, width, height, TRUE);
......@@ -208,11 +218,11 @@ by_color_select_color (GImage *gimage,
/* Plug the alpha channel in there */
if (has_alpha)
rgb[alpha] = idata[alpha];
rgb[color_bytes - 1] = idata[alpha];
/* Find how closely the colors match */
*mdata++ = is_pixel_sufficiently_different (color, rgb, antialias,
threshold, bytes, has_alpha);
threshold, color_bytes, has_alpha);
idata += bytes;
}
......@@ -321,7 +331,8 @@ by_color_select_button_release (Tool *tool,
int x, y;
int drawable_id;
Tile *tile;
unsigned char *col;
unsigned char col[MAX_CHANNELS];
unsigned char *data;
int use_offsets;
gdisp = (GDisplay *) gdisp_ptr;
......@@ -343,7 +354,7 @@ by_color_select_button_release (Tool *tool,
return;
tile = tile_manager_get_tile (gimage_composite (gdisp->gimage), x, y, 0);
tile_ref (tile);
col = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
}
else
{
......@@ -351,9 +362,12 @@ by_color_select_button_release (Tool *tool,
return;
tile = tile_manager_get_tile (drawable_data (drawable_id), x, y, 0);
tile_ref (tile);
col = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
}
gimage_get_color (gdisp->gimage, gimage_composite_type(gdisp->gimage), col, data);
tile_unref (tile, FALSE);
/* select the area */
by_color_select (gdisp->gimage, drawable_id, col,
by_color_dialog->threshold,
......@@ -363,8 +377,6 @@ by_color_select_button_release (Tool *tool,
by_color_options->feather_radius,
by_color_options->sample_merged);
tile_unref (tile, FALSE);
/* show selection on all views */
gdisplays_flush ();
......
......@@ -157,9 +157,9 @@ by_color_select_color (GImage *gimage,
unsigned char *mask_data;
unsigned char *idata, *mdata;
unsigned char rgb[MAX_CHANNELS];
int has_alpha;
int has_alpha, indexed;
int width, height;
int bytes, alpha;
int bytes, color_bytes, alpha;
int i, j;
void * pr;
int d_type;
......@@ -172,6 +172,7 @@ by_color_select_color (GImage *gimage,
has_alpha = (d_type == RGBA_GIMAGE ||
d_type == GRAYA_GIMAGE ||
d_type == INDEXEDA_GIMAGE);
indexed = d_type == INDEXEDA_GIMAGE || d_type == INDEXED_GIMAGE;
width = gimage->width;
height = gimage->height;
pixel_region_init (&imagePR, gimage_composite (gimage), 0, 0, width, height, FALSE);
......@@ -181,12 +182,21 @@ by_color_select_color (GImage *gimage,
bytes = drawable_bytes (drawable);
d_type = drawable_type (drawable);
has_alpha = drawable_has_alpha (drawable);
indexed = drawable_indexed (drawable);
width = drawable_width (drawable);
height = drawable_height (drawable);
pixel_region_init (&imagePR, drawable_data (drawable), 0, 0, width, height, FALSE);
}
if (indexed) {
/* indexed colors are always RGB or RGBA */
color_bytes = has_alpha ? 4 : 3;
} else {
/* RGB, RGBA, GRAY and GRAYA colors are shaped just like the image */
color_bytes = bytes;
}
alpha = bytes - 1;
mask = channel_new_mask (gimage->ID, width, height);
pixel_region_init (&maskPR, mask->tiles, 0, 0, width, height, TRUE);
......@@ -208,11 +218,11 @@ by_color_select_color (GImage *gimage,
/* Plug the alpha channel in there */
if (has_alpha)
rgb[alpha] = idata[alpha];
rgb[color_bytes - 1] = idata[alpha];
/* Find how closely the colors match */
*mdata++ = is_pixel_sufficiently_different (color, rgb, antialias,
threshold, bytes, has_alpha);
threshold, color_bytes, has_alpha);
idata += bytes;
}
......@@ -321,7 +331,8 @@ by_color_select_button_release (Tool *tool,
int x, y;
int drawable_id;
Tile *tile;
unsigned char *col;
unsigned char col[MAX_CHANNELS];
unsigned char *data;
int use_offsets;
gdisp = (GDisplay *) gdisp_ptr;
......@@ -343,7 +354,7 @@ by_color_select_button_release (Tool *tool,
return;
tile = tile_manager_get_tile (gimage_composite (gdisp->gimage), x, y, 0);
tile_ref (tile);
col = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
}
else
{
......@@ -351,9 +362,12 @@ by_color_select_button_release (Tool *tool,
return;
tile = tile_manager_get_tile (drawable_data (drawable_id), x, y, 0);
tile_ref (tile);
col = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
}
gimage_get_color (gdisp->gimage, gimage_composite_type(gdisp->gimage), col, data);
tile_unref (tile, FALSE);
/* select the area */
by_color_select (gdisp->gimage, drawable_id, col,
by_color_dialog->threshold,
......@@ -363,8 +377,6 @@ by_color_select_button_release (Tool *tool,
by_color_options->feather_radius,
by_color_options->sample_merged);
tile_unref (tile, FALSE);
/* show selection on all views */
gdisplays_flush ();
......
......@@ -157,9 +157,9 @@ by_color_select_color (GImage *gimage,
unsigned char *mask_data;
unsigned char *idata, *mdata;
unsigned char rgb[MAX_CHANNELS];
int has_alpha;
int has_alpha, indexed;
int width, height;
int bytes, alpha;
int bytes, color_bytes, alpha;
int i, j;
void * pr;
int d_type;
......@@ -172,6 +172,7 @@ by_color_select_color (GImage *gimage,
has_alpha = (d_type == RGBA_GIMAGE ||
d_type == GRAYA_GIMAGE ||
d_type == INDEXEDA_GIMAGE);
indexed = d_type == INDEXEDA_GIMAGE || d_type == INDEXED_GIMAGE;
width = gimage->width;
height = gimage->height;
pixel_region_init (&imagePR, gimage_composite (gimage), 0, 0, width, height, FALSE);
......@@ -181,12 +182,21 @@ by_color_select_color (GImage *gimage,
bytes = drawable_bytes (drawable);
d_type = drawable_type (drawable);
has_alpha = drawable_has_alpha (drawable);
indexed = drawable_indexed (drawable);
width = drawable_width (drawable);
height = drawable_height (drawable);
pixel_region_init (&imagePR, drawable_data (drawable), 0, 0, width, height, FALSE);
}
if (indexed) {
/* indexed colors are always RGB or RGBA */
color_bytes = has_alpha ? 4 : 3;
} else {
/* RGB, RGBA, GRAY and GRAYA colors are shaped just like the image */
color_bytes = bytes;
}
alpha = bytes - 1;
mask = channel_new_mask (gimage->ID, width, height);
pixel_region_init (&maskPR, mask->tiles, 0, 0, width, height, TRUE);
......@@ -208,11 +218,11 @@ by_color_select_color (GImage *gimage,
/* Plug the alpha channel in there */
if (has_alpha)
rgb[alpha] = idata[alpha];
rgb[color_bytes - 1] = idata[alpha];
/* Find how closely the colors match */
*mdata++ = is_pixel_sufficiently_different (color, rgb, antialias,
threshold, bytes, has_alpha);
threshold, color_bytes, has_alpha);
idata += bytes;
}
......@@ -321,7 +331,8 @@ by_color_select_button_release (Tool *tool,
int x, y;
int drawable_id;
Tile *tile;
unsigned char *col;
unsigned char col[MAX_CHANNELS];
unsigned char *data;
int use_offsets;
gdisp = (GDisplay *) gdisp_ptr;
......@@ -343,7 +354,7 @@ by_color_select_button_release (Tool *tool,
return;
tile = tile_manager_get_tile (gimage_composite (gdisp->gimage), x, y, 0);
tile_ref (tile);
col = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
}
else
{
......@@ -351,9 +362,12 @@ by_color_select_button_release (Tool *tool,
return;
tile = tile_manager_get_tile (drawable_data (drawable_id), x, y, 0);
tile_ref (tile);
col = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
}
gimage_get_color (gdisp->gimage, gimage_composite_type(gdisp->gimage), col, data);
tile_unref (tile, FALSE);
/* select the area */
by_color_select (gdisp->gimage, drawable_id, col,
by_color_dialog->threshold,
......@@ -363,8 +377,6 @@ by_color_select_button_release (Tool *tool,
by_color_options->feather_radius,
by_color_options->sample_merged);
tile_unref (tile, FALSE);
/* show selection on all views */
gdisplays_flush ();
......
......@@ -34,8 +34,8 @@ gimpinclude_HEADERS = gimp.h \
gimpmenu.h \
gimpui.h
libgimp_la_LDFLAGS = -version-info 1:0:0 -rpath $(libdir)
libgimpui_la_LDFLAGS = -version-info 1:0:0 -rpath $(libdir)
libgimp_la_LDFLAGS = -version-info 1:0:0
libgimpui_la_LDFLAGS = -version-info 1:0:0
INCLUDES = \
$(X_CFLAGS) \
......
This diff is collapsed.
This diff is collapsed.
......@@ -348,6 +348,9 @@ parse_colors (XpmImage *xpm_image, guchar **cmap)
else if (xpm_color->m_color)
colorspec = xpm_color->m_color;
if (strcmp(colorspec, "none") == 0)
colorspec = "None";
/* parse if it's not transparent. the assumption is that
g_new will memset the buffer to zeros */
if (strcmp(colorspec, "None") != 0) {
......
......@@ -80,7 +80,12 @@
(script-fu-register "i26-gunya2"
"<Toolbox>/Xtns/Script-Fu/Logos/Imigre-26"
"Two-colored text by hand"
"Shuji Narazaki"
"Shuji Narazaki"
"1997"
""
SF-VALUE "Text" "\"The GIMP\""
SF-COLOR "Text Color" '(255 0 0)
SF-COLOR "Frame Color" '(0 34 255)
......@@ -88,4 +93,4 @@
SF-VALUE "Font Size" "100"
SF-VALUE "Frame Size" "2")
;;; i26-gunya2.scm ends here
\ No newline at end of file
;;; i26-gunya2.scm ends here
......@@ -348,6 +348,9 @@ parse_colors (XpmImage *xpm_image, guchar **cmap)
else if (xpm_color->m_color)
colorspec = xpm_color->m_color;
if (strcmp(colorspec, "none") == 0)
colorspec = "None";
/* parse if it's not transparent. the assumption is that
g_new will memset the buffer to zeros */
if (strcmp(colorspec, "None") != 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment