Commit 8a678c09 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

removed useless assignments.

2002-12-04  Sven Neumann  <sven@gimp.org>

	* app/display/gimpdisplayshell-render.c (render_image_tile_fault):
	removed useless assignments.

	* plug-ins/common/aa.c: removed wrong assertions that caused the
	plug-in to crash on images with odd width or height (#100344).
	Added support for RGB images as well as alpha channel while I was
	on it.
parent 7e87f779
2002-12-04 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-render.c (render_image_tile_fault):
removed useless assignments.
* plug-ins/common/aa.c: removed wrong assertions that caused the
plug-in to crash on images with odd width or height (#100344).
Added support for RGB images as well as alpha channel while I was
on it.
2002-12-04 Michael Natterer <mitch@gimp.org>
 
* app/Makefile.am: added -DGIMP_APP_GLUE_COMPILATION to
......
......@@ -178,7 +178,8 @@ render_setup_notify (GObject *config,
/* allocate a buffer for arranging information from a row of tiles */
if (! tile_buf)
tile_buf = g_new (guchar, GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH * MAX_CHANNELS);
tile_buf = g_new (guchar,
GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH * MAX_CHANNELS);
if (! render_blend_dark_check)
render_blend_dark_check = g_new (guchar, 65536);
......@@ -852,7 +853,8 @@ render_image_init_info (RenderInfo *info,
info->dest_bpl = info->dest_bpp * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH;
info->dest_width = info->w * info->dest_bpp;
info->byte_order = GDK_MSB_FIRST;
info->scale = render_image_accelerate_scaling (w, info->x, info->scalex);
info->scale = render_image_accelerate_scaling (w,
info->x, info->scalex);
info->alpha = NULL;
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_image_projection_type (shell->gdisp->gimage)))
......@@ -921,7 +923,6 @@ render_image_tile_fault (RenderInfo *info)
gint width;
gint tilex;
gint tiley;
gint srctilex, srctiley;
gint step;
gint bpp = info->src_bpp;
gint x, b;
......@@ -930,7 +931,7 @@ render_image_tile_fault (RenderInfo *info)
tiley = info->src_y / TILE_HEIGHT;
tile = tile_manager_get_tile (info->src_tiles,
srctilex=info->src_x, srctiley=info->src_y,
info->src_x, info->src_y,
TRUE, FALSE);
if (!tile)
return NULL;
......@@ -960,14 +961,16 @@ render_image_tile_fault (RenderInfo *info)
tile_release (tile, FALSE);
tilex += 1;
tile = tile_manager_get_tile (info->src_tiles, srctilex=x,
srctiley=info->src_y, TRUE, FALSE);
tile = tile_manager_get_tile (info->src_tiles,
x, info->src_y,
TRUE, FALSE);
if (!tile)
return tile_buf;
data = tile_data_pointer (tile,
x % TILE_WIDTH,
info->src_y % TILE_HEIGHT);
x % TILE_WIDTH,
info->src_y % TILE_HEIGHT);
}
}
}
......
......@@ -85,7 +85,7 @@ query (void)
"Tim Newsome <nuisance@cmu.edu>",
"1997",
"<Save>/AA",
"GRAY", /* FIXME: add support for other formats ? */
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (save_args), 0,
save_args, NULL);
......@@ -150,7 +150,8 @@ run (gchar *name,
INIT_I18N_UI();
gimp_ui_init ("aa", FALSE);
export = gimp_export_image (&image_ID, &drawable_ID, "AA",
(GIMP_EXPORT_CAN_HANDLE_GRAY |
(GIMP_EXPORT_CAN_HANDLE_RGB |
GIMP_EXPORT_CAN_HANDLE_GRAY |
GIMP_EXPORT_CAN_HANDLE_ALPHA ));
if (export == GIMP_EXPORT_CANCEL)
{
......@@ -163,7 +164,8 @@ run (gchar *name,
break;
}
if (!gimp_drawable_is_gray (drawable_ID))
if (! (gimp_drawable_is_rgb (drawable_ID) ||
gimp_drawable_is_gray (drawable_ID)))
{
status = GIMP_PDB_CALLING_ERROR;
}
......@@ -244,9 +246,6 @@ save_aa (gint32 drawable_ID,
if (!context)
return FALSE;
g_assert (aa_imgwidth (context) == gimp_drawable_width (drawable_ID));
g_assert (aa_imgheight (context) == gimp_drawable_height (drawable_ID));
gimp2aa (drawable_ID, context);
aa_flush (context);
aa_close (context);
......@@ -267,6 +266,7 @@ gimp2aa (gint32 drawable_ID,
gint x, y;
gint bpp;
guchar *buffer;
guchar *p;
drawable = gimp_drawable_get (drawable_ID);
......@@ -283,11 +283,35 @@ gimp2aa (gint32 drawable_ID,
for (y = 0; y < height; y++)
{
gimp_pixel_rgn_get_row (&pixel_rgn, buffer, 0, y, width);
for (x = 0; x < width; x++)
{
/* FIXME: add support for alpha channel */
aa_putpixel (context, x, y, buffer[x * bpp]);
}
switch (bpp)
{
case 1: /* GRAY */
for (x = 0, p = buffer; x < width; x++, p++)
aa_putpixel (context, x, y, *p);
break;
case 2: /* GRAYA, blend over black */
for (x = 0, p = buffer; x < width; x++, p += 2)
aa_putpixel (context, x, y, (p[0] * (p[1] + 1)) >> 8);
break;
case 3: /* RGB */
for (x = 0, p = buffer; x < width; x++, p += 3)
aa_putpixel (context, x, y, INTENSITY (p[0], p[1], p[2]));
break;
case 4: /* RGBA, blend over black */
for (x = 0, p = buffer; x < width; x++, p += 4)
aa_putpixel (context, x, y,
((guchar) INTENSITY (p[0], p[1], p[2]) * (p[3] + 1))
>> 8);
break;
default:
g_assert_not_reached ();
break;
}
}
g_free (buffer);
......
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