prefixed all global variables with "render_" (we had a global variable

2001-01-30  Michael Natterer  <mitch@gimp.org>

	* app/image_render.[ch]: prefixed all global variables with
	"render_" (we had a global variable named "temp_buf", brrrr),
	general cleanup.

	* app/colormap_dialog.c
	* app/layers_dialog.c: changed accordingly.
This commit is contained in:
Michael Natterer 2001-01-30 03:17:26 +00:00 committed by Michael Natterer
parent 14bc89f1ed
commit 12212f907b
12 changed files with 919 additions and 841 deletions

View File

@ -1,3 +1,12 @@
2001-01-30 Michael Natterer <mitch@gimp.org>
* app/image_render.[ch]: prefixed all global variables with
"render_" (we had a global variable named "temp_buf", brrrr),
general cleanup.
* app/colormap_dialog.c
* app/layers_dialog.c: changed accordingly.
2001-01-29 Michael Natterer <mitch@gimp.org> 2001-01-29 Michael Natterer <mitch@gimp.org>
* app/dialog_types.h: removed because it was unused. * app/dialog_types.h: removed because it was unused.

View File

@ -606,7 +606,7 @@ ipal_draw (GimpColormapDialog* ipal)
for (l = j * cellsize; l < xn * cellsize; l++) for (l = j * cellsize; l < xn * cellsize; l++)
for (b = 0; b < 3; b++) for (b = 0; b < 3; b++)
row[l * 3 + b] = ((((i * cellsize + k) & 0x4) ? (l) : (l + 0x4)) & 0x4) ? row[l * 3 + b] = ((((i * cellsize + k) & 0x4) ? (l) : (l + 0x4)) & 0x4) ?
blend_light_check[0] : blend_dark_check[0]; render_blend_light_check[0] : render_blend_dark_check[0];
gtk_preview_draw_row (ipal->palette, row, 0, gtk_preview_draw_row (ipal->palette, row, 0,
i * cellsize + k, cellsize * xn); i * cellsize + k, cellsize * xn);
@ -709,7 +709,8 @@ ipal_clear (GimpColormapDialog* ipal)
for (j = 0; j < width; j++) for (j = 0; j < width; j++)
{ {
row[j * 3 + 0] = row[j * 3 + 1] = row[j * 3 + 2] = row[j * 3 + 0] = row[j * 3 + 1] = row[j * 3 + 2] =
((j + offset) & 0x4) ? blend_light_check[0] : blend_dark_check[0]; ((j + offset) & 0x4) ?
render_blend_light_check[0] : render_blend_dark_check[0];
} }
for (j = 0; j < 4 && i+j < height; j++) for (j = 0; j < 4 && i+j < height; j++)

View File

@ -38,57 +38,63 @@
typedef struct _RenderInfo RenderInfo; typedef struct _RenderInfo RenderInfo;
typedef void (*RenderFunc) (RenderInfo *info);
typedef void (* RenderFunc) (RenderInfo *info);
struct _RenderInfo struct _RenderInfo
{ {
GDisplay *gdisp; GDisplay *gdisp;
TileManager *src_tiles; TileManager *src_tiles;
guint *alpha; guint *alpha;
guchar *scale; guchar *scale;
guchar *src; guchar *src;
guchar *dest; guchar *dest;
int x, y; gint x, y;
int w, h; gint w, h;
float scalex; gfloat scalex;
float scaley; gfloat scaley;
int src_x, src_y; gint src_x, src_y;
int src_bpp; gint src_bpp;
int dest_bpp; gint dest_bpp;
int dest_bpl; gint dest_bpl;
int dest_width; gint dest_width;
int byte_order; gint byte_order;
}; };
/* accelerate transparency of image scaling */ /* accelerate transparency of image scaling */
guchar *blend_dark_check = NULL; guchar *render_check_buf = NULL;
guchar *blend_light_check = NULL; guchar *render_empty_buf = NULL;
guchar *tile_buf = NULL; guchar *render_temp_buf = NULL;
guchar *check_buf = NULL; guchar *render_blend_dark_check = NULL;
guchar *empty_buf = NULL; guchar *render_blend_light_check = NULL;
guchar *temp_buf = NULL;
static guint check_mod;
static guint check_shift; static guchar *tile_buf = NULL;
static guint tile_shift; static guint check_mod = 0;
static guint check_shift = 0;
static guint tile_shift = 0;
static guchar check_combos[6][2] = static guchar check_combos[6][2] =
{ {
{ 204, 255 }, { 204, 255 },
{ 102, 153 }, { 102, 153 },
{ 0, 51 }, { 0, 51 },
{ 255, 255 }, { 255, 255 },
{ 127, 127 }, { 127, 127 },
{ 0, 0 } { 0, 0 }
}; };
void void
render_setup (int check_type, render_setup (GimpCheckType check_type,
int check_size) GimpCheckSize check_size)
{ {
int i, j; gint i, j;
if (check_type < LIGHT_CHECKS || check_type > BLACK_ONLY)
g_error ("invalid check_type argument to render_setup: %d", check_type);
if (check_size < SMALL_CHECKS || check_size > LARGE_CHECKS)
g_error ("invalid check_size argument to render_setup: %d", check_size);
/* based on the tile size, determine the tile shift amount /* based on the tile size, determine the tile shift amount
* (assume here that tile_height and tile_width are equal) * (assume here that tile_height and tile_width are equal)
@ -98,79 +104,72 @@ render_setup (int check_type,
tile_shift++; tile_shift++;
/* allocate a buffer for arranging information from a row of tiles */ /* allocate a buffer for arranging information from a row of tiles */
if (!tile_buf) if (! tile_buf)
tile_buf = g_new (guchar, GXIMAGE_WIDTH * MAX_CHANNELS); tile_buf = g_new (guchar, GXIMAGE_WIDTH * MAX_CHANNELS);
if (check_type < 0 || check_type > 5) if (! render_blend_dark_check)
g_error ("invalid check_type argument to render_setup: %d", check_type); render_blend_dark_check = g_new (guchar, 65536);
if (check_size < 0 || check_size > 2) if (! render_blend_light_check)
g_error ("invalid check_size argument to render_setup: %d", check_size); render_blend_light_check = g_new (guchar, 65536);
if (!blend_dark_check)
blend_dark_check = g_new (guchar, 65536);
if (!blend_light_check)
blend_light_check = g_new (guchar, 65536);
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
for (j = 0; j < 256; j++) for (j = 0; j < 256; j++)
{ {
blend_dark_check [(i << 8) + j] = (guchar) render_blend_dark_check [(i << 8) + j] = (guchar)
((j * i + check_combos[check_type][0] * (255 - i)) / 255); ((j * i + check_combos[check_type][0] * (255 - i)) / 255);
blend_light_check [(i << 8) + j] = (guchar) render_blend_light_check [(i << 8) + j] = (guchar)
((j * i + check_combos[check_type][1] * (255 - i)) / 255); ((j * i + check_combos[check_type][1] * (255 - i)) / 255);
} }
switch (check_size) switch (check_size)
{ {
case SMALL_CHECKS: case SMALL_CHECKS:
check_mod = 0x3; check_mod = 0x3;
check_shift = 2; check_shift = 2;
break; break;
case MEDIUM_CHECKS: case MEDIUM_CHECKS:
check_mod = 0x7; check_mod = 0x7;
check_shift = 3; check_shift = 3;
break; break;
case LARGE_CHECKS: case LARGE_CHECKS:
check_mod = 0xf; check_mod = 0xf;
check_shift = 4; check_shift = 4;
break; break;
} }
g_free (render_check_buf);
g_free (render_empty_buf);
g_free (render_temp_buf);
/* calculate check buffer for previews */ /* calculate check buffer for previews */
if (preview_size) if (preview_size)
{ {
if (check_buf) render_check_buf = g_new (guchar, (preview_size + 4) * 3);
g_free (check_buf);
if (empty_buf)
g_free (empty_buf);
if (temp_buf)
g_free (temp_buf);
check_buf = (unsigned char *) g_malloc ((preview_size + 4) * 3);
for (i = 0; i < (preview_size + 4); i++) for (i = 0; i < (preview_size + 4); i++)
{ {
if (i & 0x4) if (i & 0x4)
{ {
check_buf[i * 3 + 0] = blend_dark_check[0]; render_check_buf[i * 3 + 0] = render_blend_dark_check[0];
check_buf[i * 3 + 1] = blend_dark_check[0]; render_check_buf[i * 3 + 1] = render_blend_dark_check[0];
check_buf[i * 3 + 2] = blend_dark_check[0]; render_check_buf[i * 3 + 2] = render_blend_dark_check[0];
} }
else else
{ {
check_buf[i * 3 + 0] = blend_light_check[0]; render_check_buf[i * 3 + 0] = render_blend_light_check[0];
check_buf[i * 3 + 1] = blend_light_check[0]; render_check_buf[i * 3 + 1] = render_blend_light_check[0];
check_buf[i * 3 + 2] = blend_light_check[0]; render_check_buf[i * 3 + 2] = render_blend_light_check[0];
} }
} }
empty_buf = (unsigned char *) g_malloc ((preview_size + 4) * 3);
memset (empty_buf, 0, (preview_size + 4) * 3); render_empty_buf = g_new0 (guchar, (preview_size + 4) * 3);
temp_buf = (unsigned char *) g_malloc ((preview_size + 4) * 3); render_temp_buf = g_new (guchar, (preview_size + 4) * 3);
} }
else else
{ {
check_buf = NULL; render_check_buf = NULL;
empty_buf = NULL; render_empty_buf = NULL;
temp_buf = NULL; render_temp_buf = NULL;
} }
} }
@ -178,39 +177,40 @@ void
render_free (void) render_free (void)
{ {
g_free (tile_buf); g_free (tile_buf);
g_free (check_buf); g_free (render_check_buf);
} }
/* Render Image functions */ /* Render Image functions */
static void render_image_rgb (RenderInfo *info); static void render_image_rgb (RenderInfo *info);
static void render_image_rgb_a (RenderInfo *info); static void render_image_rgb_a (RenderInfo *info);
static void render_image_gray (RenderInfo *info); static void render_image_gray (RenderInfo *info);
static void render_image_gray_a (RenderInfo *info); static void render_image_gray_a (RenderInfo *info);
static void render_image_indexed (RenderInfo *info); static void render_image_indexed (RenderInfo *info);
static void render_image_indexed_a (RenderInfo *info); static void render_image_indexed_a (RenderInfo *info);
static void render_image_init_info (RenderInfo *info, static void render_image_init_info (RenderInfo *info,
GDisplay *gdisp, GDisplay *gdisp,
int x, gint x,
int y, gint y,
int w, gint w,
int h); gint h);
static guint* render_image_init_alpha (int mult); static guint * render_image_init_alpha (gint mult);
static guchar* render_image_accelerate_scaling (int width, static guchar * render_image_accelerate_scaling (gint width,
int start, gint start,
float scalex); gfloat scalex);
static guchar* render_image_tile_fault (RenderInfo *info); static guchar * render_image_tile_fault (RenderInfo *info);
static RenderFunc render_funcs[6] = static RenderFunc render_funcs[6] =
{ {
render_image_rgb, render_image_rgb,
render_image_rgb_a, render_image_rgb_a,
render_image_gray, render_image_gray,
render_image_gray_a, render_image_gray_a,
render_image_indexed, render_image_indexed,
render_image_indexed_a, render_image_indexed_a,
}; };
@ -223,17 +223,18 @@ static RenderFunc render_funcs[6] =
void void
render_image (GDisplay *gdisp, render_image (GDisplay *gdisp,
int x, gint x,
int y, gint y,
int w, gint w,
int h) gint h)
{ {
RenderInfo info; RenderInfo info;
int image_type; gint image_type;
render_image_init_info (&info, gdisp, x, y, w, h); render_image_init_info (&info, gdisp, x, y, w, h);
image_type = gimp_image_projection_type (gdisp->gimage); image_type = gimp_image_projection_type (gdisp->gimage);
if ((image_type < 0) || (image_type > 5)) if ((image_type < 0) || (image_type > 5))
{ {
g_message ("unknown gimage projection type: %d", g_message ("unknown gimage projection type: %d",
@ -248,7 +249,8 @@ render_image (GDisplay *gdisp,
} }
/* Currently, only RGBA and GRAYA projection types are used - the rest /* Currently, only RGBA and GRAYA projection types are used - the rest
* are in case of future need. -- austin, 28th Nov 1998. */ * are in case of future need. -- austin, 28th Nov 1998.
*/
if (image_type != RGBA_GIMAGE && image_type != GRAYA_GIMAGE) if (image_type != RGBA_GIMAGE && image_type != GRAYA_GIMAGE)
g_warning ("using untested projection type %d", image_type); g_warning ("using untested projection type %d", image_type);
@ -256,7 +258,6 @@ render_image (GDisplay *gdisp,
} }
/*************************/ /*************************/
/* 8 Bit functions */ /* 8 Bit functions */
/*************************/ /*************************/
@ -267,24 +268,24 @@ render_image_indexed (RenderInfo *info)
guchar *src; guchar *src;
guchar *dest; guchar *dest;
guchar *cmap; guchar *cmap;
gulong val; gulong val;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
cmap = gimp_image_cmap (info->gdisp->gimage); cmap = gimp_image_cmap (info->gdisp->gimage);
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -293,14 +294,16 @@ render_image_indexed (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0)) if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
dest = info->dest; dest = info->dest;
g_return_if_fail (src != NULL); g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++) for (x = info->x; x < xe; x++)
{ {
val = src[INDEXED_PIX] * 3; val = src[INDEXED_PIX] * 3;
@ -334,30 +337,30 @@ render_image_indexed_a (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
guint *alpha; guint *alpha;
guchar *cmap; guchar *cmap;
gulong r, g, b; gulong r, g, b;
gulong val; gulong val;
guint a; guint a;
int dark_light; gint dark_light;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
cmap = gimp_image_cmap (info->gdisp->gimage); cmap = gimp_image_cmap (info->gdisp->gimage);
alpha = info->alpha; alpha = info->alpha;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -366,7 +369,9 @@ render_image_indexed_a (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0) && (y & check_mod)) if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -384,15 +389,15 @@ render_image_indexed_a (RenderInfo *info)
if (dark_light & 0x1) if (dark_light & 0x1)
{ {
r = blend_dark_check[(a | cmap[val+0])]; r = render_blend_dark_check[(a | cmap[val + 0])];
g = blend_dark_check[(a | cmap[val+1])]; g = render_blend_dark_check[(a | cmap[val + 1])];
b = blend_dark_check[(a | cmap[val+2])]; b = render_blend_dark_check[(a | cmap[val + 2])];
} }
else else
{ {
r = blend_light_check[(a | cmap[val+0])]; r = render_blend_light_check[(a | cmap[val + 0])];
g = blend_light_check[(a | cmap[val+1])]; g = render_blend_light_check[(a | cmap[val + 1])];
b = blend_light_check[(a | cmap[val+2])]; b = render_blend_light_check[(a | cmap[val + 2])];
} }
dest[0] = r; dest[0] = r;
@ -426,22 +431,22 @@ render_image_gray (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
gulong val; gulong val;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -450,7 +455,9 @@ render_image_gray (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0)) if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -491,27 +498,27 @@ render_image_gray_a (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
guint *alpha; guint *alpha;
gulong val; gulong val;
guint a; guint a;
int dark_light; gint dark_light;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
alpha = info->alpha; alpha = info->alpha;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -520,7 +527,9 @@ render_image_gray_a (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0) && (y & check_mod)) if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -534,9 +543,9 @@ render_image_gray_a (RenderInfo *info)
{ {
a = alpha[src[ALPHA_G_PIX]]; a = alpha[src[ALPHA_G_PIX]];
if (dark_light & 0x1) if (dark_light & 0x1)
val = blend_dark_check[(a | src[GRAY_PIX])]; val = render_blend_dark_check[(a | src[GRAY_PIX])];
else else
val = blend_light_check[(a | src[GRAY_PIX])]; val = render_blend_light_check[(a | src[GRAY_PIX])];
src += 2; src += 2;
dest[0] = val; dest[0] = val;
@ -570,21 +579,21 @@ render_image_rgb (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= (int)error - step; error -= (gint) error - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -593,7 +602,9 @@ render_image_rgb (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0)) if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -629,34 +640,32 @@ render_image_rgb (RenderInfo *info)
} }
} }
static void static void
render_image_rgb_a (RenderInfo *info) render_image_rgb_a (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
guint *alpha; guint *alpha;
gulong r, g, b; gulong r, g, b;
guint a; guint a;
int dark_light; gint dark_light;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
alpha = info->alpha; alpha = info->alpha;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -665,7 +674,9 @@ render_image_rgb_a (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0) && (y & check_mod)) if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -680,15 +691,15 @@ render_image_rgb_a (RenderInfo *info)
a = alpha[src[ALPHA_PIX]]; a = alpha[src[ALPHA_PIX]];
if (dark_light & 0x1) if (dark_light & 0x1)
{ {
r = blend_dark_check[(a | src[RED_PIX])]; r = render_blend_dark_check[(a | src[RED_PIX])];
g = blend_dark_check[(a | src[GREEN_PIX])]; g = render_blend_dark_check[(a | src[GREEN_PIX])];
b = blend_dark_check[(a | src[BLUE_PIX])]; b = render_blend_dark_check[(a | src[BLUE_PIX])];
} }
else else
{ {
r = blend_light_check[(a | src[RED_PIX])]; r = render_blend_light_check[(a | src[RED_PIX])];
g = blend_light_check[(a | src[GREEN_PIX])]; g = render_blend_light_check[(a | src[GREEN_PIX])];
b = blend_light_check[(a | src[BLUE_PIX])]; b = render_blend_light_check[(a | src[BLUE_PIX])];
} }
src += 4; src += 4;
@ -722,36 +733,37 @@ render_image_rgb_a (RenderInfo *info)
static void static void
render_image_init_info (RenderInfo *info, render_image_init_info (RenderInfo *info,
GDisplay *gdisp, GDisplay *gdisp,
int x, gint x,
int y, gint y,
int w, gint w,
int h) gint h)
{ {
info->gdisp = gdisp; info->gdisp = gdisp;
info->src_tiles = gimp_image_projection (gdisp->gimage); info->src_tiles = gimp_image_projection (gdisp->gimage);
info->x = x + gdisp->offset_x; info->x = x + gdisp->offset_x;
info->y = y + gdisp->offset_y; info->y = y + gdisp->offset_y;
info->w = w; info->w = w;
info->h = h; info->h = h;
info->scalex = SCALEFACTOR_X (gdisp); info->scalex = SCALEFACTOR_X (gdisp);
info->scaley = SCALEFACTOR_Y (gdisp); info->scaley = SCALEFACTOR_Y (gdisp);
info->src_x = UNSCALEX (gdisp, info->x); info->src_x = UNSCALEX (gdisp, info->x);
info->src_y = UNSCALEY (gdisp, info->y); info->src_y = UNSCALEY (gdisp, info->y);
info->src_bpp = gimp_image_projection_bytes (gdisp->gimage); info->src_bpp = gimp_image_projection_bytes (gdisp->gimage);
info->dest = gximage_get_data (); info->dest = gximage_get_data ();
info->dest_bpp = gximage_get_bpp (); info->dest_bpp = gximage_get_bpp ();
info->dest_bpl = gximage_get_bpl (); info->dest_bpl = gximage_get_bpl ();
info->dest_width = info->w * info->dest_bpp; info->dest_width = info->w * info->dest_bpp;
info->byte_order = gximage_get_byte_order (); info->byte_order = gximage_get_byte_order ();
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; info->alpha = NULL;
switch (gimp_image_projection_type (gdisp->gimage)) switch (gimp_image_projection_type (gdisp->gimage))
{ {
case RGBA_GIMAGE: case RGBA_GIMAGE:
case GRAYA_GIMAGE: case GRAYA_GIMAGE:
case INDEXEDA_GIMAGE: case INDEXEDA_GIMAGE:
info->alpha = render_image_init_alpha (gimp_image_projection_opacity (gdisp->gimage)); info->alpha =
render_image_init_alpha (gimp_image_projection_opacity (gdisp->gimage));
break; break;
default: default:
/* nothing special needs doing */ /* nothing special needs doing */
@ -760,11 +772,12 @@ render_image_init_info (RenderInfo *info,
} }
static guint* static guint*
render_image_init_alpha (int mult) render_image_init_alpha (gint mult)
{ {
static guint *alpha_mult = NULL; static guint *alpha_mult = NULL;
static int alpha_val = -1; static gint alpha_val = -1;
int i;
gint i;
if (alpha_val != mult) if (alpha_val != mult)
{ {
@ -780,14 +793,15 @@ render_image_init_alpha (int mult)
} }
static guchar* static guchar*
render_image_accelerate_scaling (int width, render_image_accelerate_scaling (gint width,
int start, gint start,
float scalex) gfloat scalex)
{ {
static guchar *scale = NULL; static guchar *scale = NULL;
float error;
float step; gfloat error;
int i; gfloat step;
gint i;
if (!scale) if (!scale)
scale = g_new (guchar, GXIMAGE_WIDTH + 1); scale = g_new (guchar, GXIMAGE_WIDTH + 1);
@ -806,20 +820,20 @@ render_image_accelerate_scaling (int width,
return scale; return scale;
} }
static guchar* static guchar *
render_image_tile_fault (RenderInfo *info) render_image_tile_fault (RenderInfo *info)
{ {
Tile *tile; Tile *tile;
guchar *data; guchar *data;
guchar *dest; guchar *dest;
guchar *scale; guchar *scale;
int width; gint width;
int tilex; gint tilex;
int tiley; gint tiley;
int srctilex, srctiley; gint srctilex, srctiley;
int step; gint step;
int bpp = info->src_bpp; gint bpp = info->src_bpp;
int x, b; gint x, b;
tilex = info->src_x / TILE_WIDTH; tilex = info->src_x / TILE_WIDTH;
tiley = info->src_y / TILE_HEIGHT; tiley = info->src_y / TILE_HEIGHT;
@ -834,9 +848,9 @@ render_image_tile_fault (RenderInfo *info)
info->src_x % TILE_WIDTH, info->src_x % TILE_WIDTH,
info->src_y % TILE_HEIGHT); info->src_y % TILE_HEIGHT);
scale = info->scale; scale = info->scale;
dest = tile_buf; dest = tile_buf;
x = info->src_x; x = info->src_x;
width = info->w; width = info->w;
while (width--) while (width--)
@ -868,5 +882,6 @@ render_image_tile_fault (RenderInfo *info)
} }
tile_release (tile, FALSE); tile_release (tile, FALSE);
return tile_buf; return tile_buf;
} }

View File

@ -22,35 +22,42 @@
/* Transparency representation */ /* Transparency representation */
#define LIGHT_CHECKS 0 typedef enum
#define GRAY_CHECKS 1 {
#define DARK_CHECKS 2 LIGHT_CHECKS = 0,
#define WHITE_ONLY 3 GRAY_CHECKS = 1,
#define GRAY_ONLY 4 DARK_CHECKS = 2,
#define BLACK_ONLY 5 WHITE_ONLY = 3,
GRAY_ONLY = 4,
BLACK_ONLY = 5
} GimpCheckType;
typedef enum
{
SMALL_CHECKS = 0,
MEDIUM_CHECKS = 1,
LARGE_CHECKS = 2
} GimpCheckSize;
#define SMALL_CHECKS 0
#define MEDIUM_CHECKS 1
#define LARGE_CHECKS 2
/* Functions */ /* Functions */
void render_setup (gint check_type, void render_setup (GimpCheckType check_type,
gint check_size); GimpCheckSize check_size);
void render_free (void); void render_free (void);
void render_image (GDisplay *gdisp, void render_image (GDisplay *gdisp,
gint x, gint x,
gint y, gint y,
gint w, gint w,
gint h); gint h);
/* /*
* Extern variables * Extern variables
*/ */
extern guchar *check_buf; extern guchar *render_check_buf;
extern guchar *empty_buf; extern guchar *render_empty_buf;
extern guchar *temp_buf; extern guchar *render_temp_buf;
extern guchar *blend_dark_check; extern guchar *render_blend_dark_check;
extern guchar *blend_light_check; extern guchar *render_blend_light_check;
#endif /* __IMAGE_RENDER_H__ */ #endif /* __IMAGE_RENDER_H__ */

View File

@ -38,57 +38,63 @@
typedef struct _RenderInfo RenderInfo; typedef struct _RenderInfo RenderInfo;
typedef void (*RenderFunc) (RenderInfo *info);
typedef void (* RenderFunc) (RenderInfo *info);
struct _RenderInfo struct _RenderInfo
{ {
GDisplay *gdisp; GDisplay *gdisp;
TileManager *src_tiles; TileManager *src_tiles;
guint *alpha; guint *alpha;
guchar *scale; guchar *scale;
guchar *src; guchar *src;
guchar *dest; guchar *dest;
int x, y; gint x, y;
int w, h; gint w, h;
float scalex; gfloat scalex;
float scaley; gfloat scaley;
int src_x, src_y; gint src_x, src_y;
int src_bpp; gint src_bpp;
int dest_bpp; gint dest_bpp;
int dest_bpl; gint dest_bpl;
int dest_width; gint dest_width;
int byte_order; gint byte_order;
}; };
/* accelerate transparency of image scaling */ /* accelerate transparency of image scaling */
guchar *blend_dark_check = NULL; guchar *render_check_buf = NULL;
guchar *blend_light_check = NULL; guchar *render_empty_buf = NULL;
guchar *tile_buf = NULL; guchar *render_temp_buf = NULL;
guchar *check_buf = NULL; guchar *render_blend_dark_check = NULL;
guchar *empty_buf = NULL; guchar *render_blend_light_check = NULL;
guchar *temp_buf = NULL;
static guint check_mod;
static guint check_shift; static guchar *tile_buf = NULL;
static guint tile_shift; static guint check_mod = 0;
static guint check_shift = 0;
static guint tile_shift = 0;
static guchar check_combos[6][2] = static guchar check_combos[6][2] =
{ {
{ 204, 255 }, { 204, 255 },
{ 102, 153 }, { 102, 153 },
{ 0, 51 }, { 0, 51 },
{ 255, 255 }, { 255, 255 },
{ 127, 127 }, { 127, 127 },
{ 0, 0 } { 0, 0 }
}; };
void void
render_setup (int check_type, render_setup (GimpCheckType check_type,
int check_size) GimpCheckSize check_size)
{ {
int i, j; gint i, j;
if (check_type < LIGHT_CHECKS || check_type > BLACK_ONLY)
g_error ("invalid check_type argument to render_setup: %d", check_type);
if (check_size < SMALL_CHECKS || check_size > LARGE_CHECKS)
g_error ("invalid check_size argument to render_setup: %d", check_size);
/* based on the tile size, determine the tile shift amount /* based on the tile size, determine the tile shift amount
* (assume here that tile_height and tile_width are equal) * (assume here that tile_height and tile_width are equal)
@ -98,79 +104,72 @@ render_setup (int check_type,
tile_shift++; tile_shift++;
/* allocate a buffer for arranging information from a row of tiles */ /* allocate a buffer for arranging information from a row of tiles */
if (!tile_buf) if (! tile_buf)
tile_buf = g_new (guchar, GXIMAGE_WIDTH * MAX_CHANNELS); tile_buf = g_new (guchar, GXIMAGE_WIDTH * MAX_CHANNELS);
if (check_type < 0 || check_type > 5) if (! render_blend_dark_check)
g_error ("invalid check_type argument to render_setup: %d", check_type); render_blend_dark_check = g_new (guchar, 65536);
if (check_size < 0 || check_size > 2) if (! render_blend_light_check)
g_error ("invalid check_size argument to render_setup: %d", check_size); render_blend_light_check = g_new (guchar, 65536);
if (!blend_dark_check)
blend_dark_check = g_new (guchar, 65536);
if (!blend_light_check)
blend_light_check = g_new (guchar, 65536);
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
for (j = 0; j < 256; j++) for (j = 0; j < 256; j++)
{ {
blend_dark_check [(i << 8) + j] = (guchar) render_blend_dark_check [(i << 8) + j] = (guchar)
((j * i + check_combos[check_type][0] * (255 - i)) / 255); ((j * i + check_combos[check_type][0] * (255 - i)) / 255);
blend_light_check [(i << 8) + j] = (guchar) render_blend_light_check [(i << 8) + j] = (guchar)
((j * i + check_combos[check_type][1] * (255 - i)) / 255); ((j * i + check_combos[check_type][1] * (255 - i)) / 255);
} }
switch (check_size) switch (check_size)
{ {
case SMALL_CHECKS: case SMALL_CHECKS:
check_mod = 0x3; check_mod = 0x3;
check_shift = 2; check_shift = 2;
break; break;
case MEDIUM_CHECKS: case MEDIUM_CHECKS:
check_mod = 0x7; check_mod = 0x7;
check_shift = 3; check_shift = 3;
break; break;
case LARGE_CHECKS: case LARGE_CHECKS:
check_mod = 0xf; check_mod = 0xf;
check_shift = 4; check_shift = 4;
break; break;
} }
g_free (render_check_buf);
g_free (render_empty_buf);
g_free (render_temp_buf);
/* calculate check buffer for previews */ /* calculate check buffer for previews */
if (preview_size) if (preview_size)
{ {
if (check_buf) render_check_buf = g_new (guchar, (preview_size + 4) * 3);
g_free (check_buf);
if (empty_buf)
g_free (empty_buf);
if (temp_buf)
g_free (temp_buf);
check_buf = (unsigned char *) g_malloc ((preview_size + 4) * 3);
for (i = 0; i < (preview_size + 4); i++) for (i = 0; i < (preview_size + 4); i++)
{ {
if (i & 0x4) if (i & 0x4)
{ {
check_buf[i * 3 + 0] = blend_dark_check[0]; render_check_buf[i * 3 + 0] = render_blend_dark_check[0];
check_buf[i * 3 + 1] = blend_dark_check[0]; render_check_buf[i * 3 + 1] = render_blend_dark_check[0];
check_buf[i * 3 + 2] = blend_dark_check[0]; render_check_buf[i * 3 + 2] = render_blend_dark_check[0];
} }
else else
{ {
check_buf[i * 3 + 0] = blend_light_check[0]; render_check_buf[i * 3 + 0] = render_blend_light_check[0];
check_buf[i * 3 + 1] = blend_light_check[0]; render_check_buf[i * 3 + 1] = render_blend_light_check[0];
check_buf[i * 3 + 2] = blend_light_check[0]; render_check_buf[i * 3 + 2] = render_blend_light_check[0];
} }
} }
empty_buf = (unsigned char *) g_malloc ((preview_size + 4) * 3);
memset (empty_buf, 0, (preview_size + 4) * 3); render_empty_buf = g_new0 (guchar, (preview_size + 4) * 3);
temp_buf = (unsigned char *) g_malloc ((preview_size + 4) * 3); render_temp_buf = g_new (guchar, (preview_size + 4) * 3);
} }
else else
{ {
check_buf = NULL; render_check_buf = NULL;
empty_buf = NULL; render_empty_buf = NULL;
temp_buf = NULL; render_temp_buf = NULL;
} }
} }
@ -178,39 +177,40 @@ void
render_free (void) render_free (void)
{ {
g_free (tile_buf); g_free (tile_buf);
g_free (check_buf); g_free (render_check_buf);
} }
/* Render Image functions */ /* Render Image functions */
static void render_image_rgb (RenderInfo *info); static void render_image_rgb (RenderInfo *info);
static void render_image_rgb_a (RenderInfo *info); static void render_image_rgb_a (RenderInfo *info);
static void render_image_gray (RenderInfo *info); static void render_image_gray (RenderInfo *info);
static void render_image_gray_a (RenderInfo *info); static void render_image_gray_a (RenderInfo *info);
static void render_image_indexed (RenderInfo *info); static void render_image_indexed (RenderInfo *info);
static void render_image_indexed_a (RenderInfo *info); static void render_image_indexed_a (RenderInfo *info);
static void render_image_init_info (RenderInfo *info, static void render_image_init_info (RenderInfo *info,
GDisplay *gdisp, GDisplay *gdisp,
int x, gint x,
int y, gint y,
int w, gint w,
int h); gint h);
static guint* render_image_init_alpha (int mult); static guint * render_image_init_alpha (gint mult);
static guchar* render_image_accelerate_scaling (int width, static guchar * render_image_accelerate_scaling (gint width,
int start, gint start,
float scalex); gfloat scalex);
static guchar* render_image_tile_fault (RenderInfo *info); static guchar * render_image_tile_fault (RenderInfo *info);
static RenderFunc render_funcs[6] = static RenderFunc render_funcs[6] =
{ {
render_image_rgb, render_image_rgb,
render_image_rgb_a, render_image_rgb_a,
render_image_gray, render_image_gray,
render_image_gray_a, render_image_gray_a,
render_image_indexed, render_image_indexed,
render_image_indexed_a, render_image_indexed_a,
}; };
@ -223,17 +223,18 @@ static RenderFunc render_funcs[6] =
void void
render_image (GDisplay *gdisp, render_image (GDisplay *gdisp,
int x, gint x,
int y, gint y,
int w, gint w,
int h) gint h)
{ {
RenderInfo info; RenderInfo info;
int image_type; gint image_type;
render_image_init_info (&info, gdisp, x, y, w, h); render_image_init_info (&info, gdisp, x, y, w, h);
image_type = gimp_image_projection_type (gdisp->gimage); image_type = gimp_image_projection_type (gdisp->gimage);
if ((image_type < 0) || (image_type > 5)) if ((image_type < 0) || (image_type > 5))
{ {
g_message ("unknown gimage projection type: %d", g_message ("unknown gimage projection type: %d",
@ -248,7 +249,8 @@ render_image (GDisplay *gdisp,
} }
/* Currently, only RGBA and GRAYA projection types are used - the rest /* Currently, only RGBA and GRAYA projection types are used - the rest
* are in case of future need. -- austin, 28th Nov 1998. */ * are in case of future need. -- austin, 28th Nov 1998.
*/
if (image_type != RGBA_GIMAGE && image_type != GRAYA_GIMAGE) if (image_type != RGBA_GIMAGE && image_type != GRAYA_GIMAGE)
g_warning ("using untested projection type %d", image_type); g_warning ("using untested projection type %d", image_type);
@ -256,7 +258,6 @@ render_image (GDisplay *gdisp,
} }
/*************************/ /*************************/
/* 8 Bit functions */ /* 8 Bit functions */
/*************************/ /*************************/
@ -267,24 +268,24 @@ render_image_indexed (RenderInfo *info)
guchar *src; guchar *src;
guchar *dest; guchar *dest;
guchar *cmap; guchar *cmap;
gulong val; gulong val;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
cmap = gimp_image_cmap (info->gdisp->gimage); cmap = gimp_image_cmap (info->gdisp->gimage);
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -293,14 +294,16 @@ render_image_indexed (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0)) if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
dest = info->dest; dest = info->dest;
g_return_if_fail (src != NULL); g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++) for (x = info->x; x < xe; x++)
{ {
val = src[INDEXED_PIX] * 3; val = src[INDEXED_PIX] * 3;
@ -334,30 +337,30 @@ render_image_indexed_a (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
guint *alpha; guint *alpha;
guchar *cmap; guchar *cmap;
gulong r, g, b; gulong r, g, b;
gulong val; gulong val;
guint a; guint a;
int dark_light; gint dark_light;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
cmap = gimp_image_cmap (info->gdisp->gimage); cmap = gimp_image_cmap (info->gdisp->gimage);
alpha = info->alpha; alpha = info->alpha;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -366,7 +369,9 @@ render_image_indexed_a (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0) && (y & check_mod)) if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -384,15 +389,15 @@ render_image_indexed_a (RenderInfo *info)
if (dark_light & 0x1) if (dark_light & 0x1)
{ {
r = blend_dark_check[(a | cmap[val+0])]; r = render_blend_dark_check[(a | cmap[val + 0])];
g = blend_dark_check[(a | cmap[val+1])]; g = render_blend_dark_check[(a | cmap[val + 1])];
b = blend_dark_check[(a | cmap[val+2])]; b = render_blend_dark_check[(a | cmap[val + 2])];
} }
else else
{ {
r = blend_light_check[(a | cmap[val+0])]; r = render_blend_light_check[(a | cmap[val + 0])];
g = blend_light_check[(a | cmap[val+1])]; g = render_blend_light_check[(a | cmap[val + 1])];
b = blend_light_check[(a | cmap[val+2])]; b = render_blend_light_check[(a | cmap[val + 2])];
} }
dest[0] = r; dest[0] = r;
@ -426,22 +431,22 @@ render_image_gray (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
gulong val; gulong val;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -450,7 +455,9 @@ render_image_gray (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0)) if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -491,27 +498,27 @@ render_image_gray_a (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
guint *alpha; guint *alpha;
gulong val; gulong val;
guint a; guint a;
int dark_light; gint dark_light;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
alpha = info->alpha; alpha = info->alpha;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -520,7 +527,9 @@ render_image_gray_a (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0) && (y & check_mod)) if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -534,9 +543,9 @@ render_image_gray_a (RenderInfo *info)
{ {
a = alpha[src[ALPHA_G_PIX]]; a = alpha[src[ALPHA_G_PIX]];
if (dark_light & 0x1) if (dark_light & 0x1)
val = blend_dark_check[(a | src[GRAY_PIX])]; val = render_blend_dark_check[(a | src[GRAY_PIX])];
else else
val = blend_light_check[(a | src[GRAY_PIX])]; val = render_blend_light_check[(a | src[GRAY_PIX])];
src += 2; src += 2;
dest[0] = val; dest[0] = val;
@ -570,21 +579,21 @@ render_image_rgb (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= (int)error - step; error -= (gint) error - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -593,7 +602,9 @@ render_image_rgb (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0)) if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -629,34 +640,32 @@ render_image_rgb (RenderInfo *info)
} }
} }
static void static void
render_image_rgb_a (RenderInfo *info) render_image_rgb_a (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
guint *alpha; guint *alpha;
gulong r, g, b; gulong r, g, b;
guint a; guint a;
int dark_light; gint dark_light;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
alpha = info->alpha; alpha = info->alpha;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -665,7 +674,9 @@ render_image_rgb_a (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0) && (y & check_mod)) if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -680,15 +691,15 @@ render_image_rgb_a (RenderInfo *info)
a = alpha[src[ALPHA_PIX]]; a = alpha[src[ALPHA_PIX]];
if (dark_light & 0x1) if (dark_light & 0x1)
{ {
r = blend_dark_check[(a | src[RED_PIX])]; r = render_blend_dark_check[(a | src[RED_PIX])];
g = blend_dark_check[(a | src[GREEN_PIX])]; g = render_blend_dark_check[(a | src[GREEN_PIX])];
b = blend_dark_check[(a | src[BLUE_PIX])]; b = render_blend_dark_check[(a | src[BLUE_PIX])];
} }
else else
{ {
r = blend_light_check[(a | src[RED_PIX])]; r = render_blend_light_check[(a | src[RED_PIX])];
g = blend_light_check[(a | src[GREEN_PIX])]; g = render_blend_light_check[(a | src[GREEN_PIX])];
b = blend_light_check[(a | src[BLUE_PIX])]; b = render_blend_light_check[(a | src[BLUE_PIX])];
} }
src += 4; src += 4;
@ -722,36 +733,37 @@ render_image_rgb_a (RenderInfo *info)
static void static void
render_image_init_info (RenderInfo *info, render_image_init_info (RenderInfo *info,
GDisplay *gdisp, GDisplay *gdisp,
int x, gint x,
int y, gint y,
int w, gint w,
int h) gint h)
{ {
info->gdisp = gdisp; info->gdisp = gdisp;
info->src_tiles = gimp_image_projection (gdisp->gimage); info->src_tiles = gimp_image_projection (gdisp->gimage);
info->x = x + gdisp->offset_x; info->x = x + gdisp->offset_x;
info->y = y + gdisp->offset_y; info->y = y + gdisp->offset_y;
info->w = w; info->w = w;
info->h = h; info->h = h;
info->scalex = SCALEFACTOR_X (gdisp); info->scalex = SCALEFACTOR_X (gdisp);
info->scaley = SCALEFACTOR_Y (gdisp); info->scaley = SCALEFACTOR_Y (gdisp);
info->src_x = UNSCALEX (gdisp, info->x); info->src_x = UNSCALEX (gdisp, info->x);
info->src_y = UNSCALEY (gdisp, info->y); info->src_y = UNSCALEY (gdisp, info->y);
info->src_bpp = gimp_image_projection_bytes (gdisp->gimage); info->src_bpp = gimp_image_projection_bytes (gdisp->gimage);
info->dest = gximage_get_data (); info->dest = gximage_get_data ();
info->dest_bpp = gximage_get_bpp (); info->dest_bpp = gximage_get_bpp ();
info->dest_bpl = gximage_get_bpl (); info->dest_bpl = gximage_get_bpl ();
info->dest_width = info->w * info->dest_bpp; info->dest_width = info->w * info->dest_bpp;
info->byte_order = gximage_get_byte_order (); info->byte_order = gximage_get_byte_order ();
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; info->alpha = NULL;
switch (gimp_image_projection_type (gdisp->gimage)) switch (gimp_image_projection_type (gdisp->gimage))
{ {
case RGBA_GIMAGE: case RGBA_GIMAGE:
case GRAYA_GIMAGE: case GRAYA_GIMAGE:
case INDEXEDA_GIMAGE: case INDEXEDA_GIMAGE:
info->alpha = render_image_init_alpha (gimp_image_projection_opacity (gdisp->gimage)); info->alpha =
render_image_init_alpha (gimp_image_projection_opacity (gdisp->gimage));
break; break;
default: default:
/* nothing special needs doing */ /* nothing special needs doing */
@ -760,11 +772,12 @@ render_image_init_info (RenderInfo *info,
} }
static guint* static guint*
render_image_init_alpha (int mult) render_image_init_alpha (gint mult)
{ {
static guint *alpha_mult = NULL; static guint *alpha_mult = NULL;
static int alpha_val = -1; static gint alpha_val = -1;
int i;
gint i;
if (alpha_val != mult) if (alpha_val != mult)
{ {
@ -780,14 +793,15 @@ render_image_init_alpha (int mult)
} }
static guchar* static guchar*
render_image_accelerate_scaling (int width, render_image_accelerate_scaling (gint width,
int start, gint start,
float scalex) gfloat scalex)
{ {
static guchar *scale = NULL; static guchar *scale = NULL;
float error;
float step; gfloat error;
int i; gfloat step;
gint i;
if (!scale) if (!scale)
scale = g_new (guchar, GXIMAGE_WIDTH + 1); scale = g_new (guchar, GXIMAGE_WIDTH + 1);
@ -806,20 +820,20 @@ render_image_accelerate_scaling (int width,
return scale; return scale;
} }
static guchar* static guchar *
render_image_tile_fault (RenderInfo *info) render_image_tile_fault (RenderInfo *info)
{ {
Tile *tile; Tile *tile;
guchar *data; guchar *data;
guchar *dest; guchar *dest;
guchar *scale; guchar *scale;
int width; gint width;
int tilex; gint tilex;
int tiley; gint tiley;
int srctilex, srctiley; gint srctilex, srctiley;
int step; gint step;
int bpp = info->src_bpp; gint bpp = info->src_bpp;
int x, b; gint x, b;
tilex = info->src_x / TILE_WIDTH; tilex = info->src_x / TILE_WIDTH;
tiley = info->src_y / TILE_HEIGHT; tiley = info->src_y / TILE_HEIGHT;
@ -834,9 +848,9 @@ render_image_tile_fault (RenderInfo *info)
info->src_x % TILE_WIDTH, info->src_x % TILE_WIDTH,
info->src_y % TILE_HEIGHT); info->src_y % TILE_HEIGHT);
scale = info->scale; scale = info->scale;
dest = tile_buf; dest = tile_buf;
x = info->src_x; x = info->src_x;
width = info->w; width = info->w;
while (width--) while (width--)
@ -868,5 +882,6 @@ render_image_tile_fault (RenderInfo *info)
} }
tile_release (tile, FALSE); tile_release (tile, FALSE);
return tile_buf; return tile_buf;
} }

View File

@ -22,35 +22,42 @@
/* Transparency representation */ /* Transparency representation */
#define LIGHT_CHECKS 0 typedef enum
#define GRAY_CHECKS 1 {
#define DARK_CHECKS 2 LIGHT_CHECKS = 0,
#define WHITE_ONLY 3 GRAY_CHECKS = 1,
#define GRAY_ONLY 4 DARK_CHECKS = 2,
#define BLACK_ONLY 5 WHITE_ONLY = 3,
GRAY_ONLY = 4,
BLACK_ONLY = 5
} GimpCheckType;
typedef enum
{
SMALL_CHECKS = 0,
MEDIUM_CHECKS = 1,
LARGE_CHECKS = 2
} GimpCheckSize;
#define SMALL_CHECKS 0
#define MEDIUM_CHECKS 1
#define LARGE_CHECKS 2
/* Functions */ /* Functions */
void render_setup (gint check_type, void render_setup (GimpCheckType check_type,
gint check_size); GimpCheckSize check_size);
void render_free (void); void render_free (void);
void render_image (GDisplay *gdisp, void render_image (GDisplay *gdisp,
gint x, gint x,
gint y, gint y,
gint w, gint w,
gint h); gint h);
/* /*
* Extern variables * Extern variables
*/ */
extern guchar *check_buf; extern guchar *render_check_buf;
extern guchar *empty_buf; extern guchar *render_empty_buf;
extern guchar *temp_buf; extern guchar *render_temp_buf;
extern guchar *blend_dark_check; extern guchar *render_blend_dark_check;
extern guchar *blend_light_check; extern guchar *render_blend_light_check;
#endif /* __IMAGE_RENDER_H__ */ #endif /* __IMAGE_RENDER_H__ */

View File

@ -606,7 +606,7 @@ ipal_draw (GimpColormapDialog* ipal)
for (l = j * cellsize; l < xn * cellsize; l++) for (l = j * cellsize; l < xn * cellsize; l++)
for (b = 0; b < 3; b++) for (b = 0; b < 3; b++)
row[l * 3 + b] = ((((i * cellsize + k) & 0x4) ? (l) : (l + 0x4)) & 0x4) ? row[l * 3 + b] = ((((i * cellsize + k) & 0x4) ? (l) : (l + 0x4)) & 0x4) ?
blend_light_check[0] : blend_dark_check[0]; render_blend_light_check[0] : render_blend_dark_check[0];
gtk_preview_draw_row (ipal->palette, row, 0, gtk_preview_draw_row (ipal->palette, row, 0,
i * cellsize + k, cellsize * xn); i * cellsize + k, cellsize * xn);
@ -709,7 +709,8 @@ ipal_clear (GimpColormapDialog* ipal)
for (j = 0; j < width; j++) for (j = 0; j < width; j++)
{ {
row[j * 3 + 0] = row[j * 3 + 1] = row[j * 3 + 2] = row[j * 3 + 0] = row[j * 3 + 1] = row[j * 3 + 2] =
((j + offset) & 0x4) ? blend_light_check[0] : blend_dark_check[0]; ((j + offset) & 0x4) ?
render_blend_light_check[0] : render_blend_dark_check[0];
} }
for (j = 0; j < 4 && i+j < height; j++) for (j = 0; j < 4 && i+j < height; j++)

View File

@ -775,13 +775,13 @@ render_preview (TempBuf *preview_buf,
if (has_alpha) if (has_alpha)
{ {
buf = check_buf; buf = render_check_buf;
alpha = ((color) ? ALPHA_PIX : alpha = ((color) ? ALPHA_PIX :
((channel != -1) ? (preview_buf->bytes - 1) : ((channel != -1) ? (preview_buf->bytes - 1) :
ALPHA_G_PIX)); ALPHA_G_PIX));
} }
else else
buf = empty_buf; buf = render_empty_buf;
x1 = CLAMP (preview_buf->x, 0, width); x1 = CLAMP (preview_buf->x, 0, width);
y1 = CLAMP (preview_buf->y, 0, height); y1 = CLAMP (preview_buf->y, 0, height);
@ -815,7 +815,7 @@ render_preview (TempBuf *preview_buf,
/* Handle the leading transparency */ /* Handle the leading transparency */
for (j = 0; j < x1; j++) for (j = 0; j < x1; j++)
for (b = 0; b < image_bytes; b++) for (b = 0; b < image_bytes; b++)
temp_buf[j * image_bytes + b] = cb[j * 3 + b]; render_temp_buf[j * image_bytes + b] = cb[j * 3 + b];
/* The stuff in the middle */ /* The stuff in the middle */
s = src; s = src;
@ -829,28 +829,28 @@ render_preview (TempBuf *preview_buf,
if ((j + offset) & 0x4) if ((j + offset) & 0x4)
{ {
temp_buf[j * 3 + 0] = render_temp_buf[j * 3 + 0] =
blend_dark_check [(a | s[RED_PIX])]; render_blend_dark_check [(a | s[RED_PIX])];
temp_buf[j * 3 + 1] = render_temp_buf[j * 3 + 1] =
blend_dark_check [(a | s[GREEN_PIX])]; render_blend_dark_check [(a | s[GREEN_PIX])];
temp_buf[j * 3 + 2] = render_temp_buf[j * 3 + 2] =
blend_dark_check [(a | s[BLUE_PIX])]; render_blend_dark_check [(a | s[BLUE_PIX])];
} }
else else
{ {
temp_buf[j * 3 + 0] = render_temp_buf[j * 3 + 0] =
blend_light_check [(a | s[RED_PIX])]; render_blend_light_check [(a | s[RED_PIX])];
temp_buf[j * 3 + 1] = render_temp_buf[j * 3 + 1] =
blend_light_check [(a | s[GREEN_PIX])]; render_blend_light_check [(a | s[GREEN_PIX])];
temp_buf[j * 3 + 2] = render_temp_buf[j * 3 + 2] =
blend_light_check [(a | s[BLUE_PIX])]; render_blend_light_check [(a | s[BLUE_PIX])];
} }
} }
else else
{ {
temp_buf[j * 3 + 0] = s[RED_PIX]; render_temp_buf[j * 3 + 0] = s[RED_PIX];
temp_buf[j * 3 + 1] = s[GREEN_PIX]; render_temp_buf[j * 3 + 1] = s[GREEN_PIX];
temp_buf[j * 3 + 2] = s[BLUE_PIX]; render_temp_buf[j * 3 + 2] = s[BLUE_PIX];
} }
} }
else else
@ -863,43 +863,43 @@ render_preview (TempBuf *preview_buf,
{ {
if (color_buf) if (color_buf)
{ {
temp_buf[j * 3 + 0] = render_temp_buf[j * 3 + 0] =
blend_dark_check [(a | s[GRAY_PIX])]; render_blend_dark_check [(a | s[GRAY_PIX])];
temp_buf[j * 3 + 1] = render_temp_buf[j * 3 + 1] =
blend_dark_check [(a | s[GRAY_PIX])]; render_blend_dark_check [(a | s[GRAY_PIX])];
temp_buf[j * 3 + 2] = render_temp_buf[j * 3 + 2] =
blend_dark_check [(a | s[GRAY_PIX])]; render_blend_dark_check [(a | s[GRAY_PIX])];
} }
else else
temp_buf[j] = render_temp_buf[j] =
blend_dark_check [(a | s[GRAY_PIX + channel])]; render_blend_dark_check [(a | s[GRAY_PIX + channel])];
} }
else else
{ {
if (color_buf) if (color_buf)
{ {
temp_buf[j * 3 + 0] = render_temp_buf[j * 3 + 0] =
blend_light_check [(a | s[GRAY_PIX])]; render_blend_light_check [(a | s[GRAY_PIX])];
temp_buf[j * 3 + 1] = render_temp_buf[j * 3 + 1] =
blend_light_check [(a | s[GRAY_PIX])]; render_blend_light_check [(a | s[GRAY_PIX])];
temp_buf[j * 3 + 2] = render_temp_buf[j * 3 + 2] =
blend_light_check [(a | s[GRAY_PIX])]; render_blend_light_check [(a | s[GRAY_PIX])];
} }
else else
temp_buf[j] = render_temp_buf[j] =
blend_light_check [(a | s[GRAY_PIX + channel])]; render_blend_light_check [(a | s[GRAY_PIX + channel])];
} }
} }
else else
{ {
if (color_buf) if (color_buf)
{ {
temp_buf[j * 3 + 0] = s[GRAY_PIX]; render_temp_buf[j * 3 + 0] = s[GRAY_PIX];
temp_buf[j * 3 + 1] = s[GRAY_PIX]; render_temp_buf[j * 3 + 1] = s[GRAY_PIX];
temp_buf[j * 3 + 2] = s[GRAY_PIX]; render_temp_buf[j * 3 + 2] = s[GRAY_PIX];
} }
else else
temp_buf[j] = s[GRAY_PIX + channel]; render_temp_buf[j] = s[GRAY_PIX + channel];
} }
} }
@ -909,7 +909,7 @@ render_preview (TempBuf *preview_buf,
/* Handle the trailing transparency */ /* Handle the trailing transparency */
for (j = x2; j < width; j++) for (j = x2; j < width; j++)
for (b = 0; b < image_bytes; b++) for (b = 0; b < image_bytes; b++)
temp_buf[j * image_bytes + b] = cb[j * 3 + b]; render_temp_buf[j * image_bytes + b] = cb[j * 3 + b];
src += rowstride; src += rowstride;
} }
@ -917,11 +917,11 @@ render_preview (TempBuf *preview_buf,
{ {
for (j = 0; j < width; j++) for (j = 0; j < width; j++)
for (b = 0; b < image_bytes; b++) for (b = 0; b < image_bytes; b++)
temp_buf[j * image_bytes + b] = cb[j * 3 + b]; render_temp_buf[j * image_bytes + b] = cb[j * 3 + b];
} }
gtk_preview_draw_row (GTK_PREVIEW (preview_widget), gtk_preview_draw_row (GTK_PREVIEW (preview_widget),
temp_buf, 0, i, width); render_temp_buf, 0, i, width);
} }
} }

View File

@ -38,57 +38,63 @@
typedef struct _RenderInfo RenderInfo; typedef struct _RenderInfo RenderInfo;
typedef void (*RenderFunc) (RenderInfo *info);
typedef void (* RenderFunc) (RenderInfo *info);
struct _RenderInfo struct _RenderInfo
{ {
GDisplay *gdisp; GDisplay *gdisp;
TileManager *src_tiles; TileManager *src_tiles;
guint *alpha; guint *alpha;
guchar *scale; guchar *scale;
guchar *src; guchar *src;
guchar *dest; guchar *dest;
int x, y; gint x, y;
int w, h; gint w, h;
float scalex; gfloat scalex;
float scaley; gfloat scaley;
int src_x, src_y; gint src_x, src_y;
int src_bpp; gint src_bpp;
int dest_bpp; gint dest_bpp;
int dest_bpl; gint dest_bpl;
int dest_width; gint dest_width;
int byte_order; gint byte_order;
}; };
/* accelerate transparency of image scaling */ /* accelerate transparency of image scaling */
guchar *blend_dark_check = NULL; guchar *render_check_buf = NULL;
guchar *blend_light_check = NULL; guchar *render_empty_buf = NULL;
guchar *tile_buf = NULL; guchar *render_temp_buf = NULL;
guchar *check_buf = NULL; guchar *render_blend_dark_check = NULL;
guchar *empty_buf = NULL; guchar *render_blend_light_check = NULL;
guchar *temp_buf = NULL;
static guint check_mod;
static guint check_shift; static guchar *tile_buf = NULL;
static guint tile_shift; static guint check_mod = 0;
static guint check_shift = 0;
static guint tile_shift = 0;
static guchar check_combos[6][2] = static guchar check_combos[6][2] =
{ {
{ 204, 255 }, { 204, 255 },
{ 102, 153 }, { 102, 153 },
{ 0, 51 }, { 0, 51 },
{ 255, 255 }, { 255, 255 },
{ 127, 127 }, { 127, 127 },
{ 0, 0 } { 0, 0 }
}; };
void void
render_setup (int check_type, render_setup (GimpCheckType check_type,
int check_size) GimpCheckSize check_size)
{ {
int i, j; gint i, j;
if (check_type < LIGHT_CHECKS || check_type > BLACK_ONLY)
g_error ("invalid check_type argument to render_setup: %d", check_type);
if (check_size < SMALL_CHECKS || check_size > LARGE_CHECKS)
g_error ("invalid check_size argument to render_setup: %d", check_size);
/* based on the tile size, determine the tile shift amount /* based on the tile size, determine the tile shift amount
* (assume here that tile_height and tile_width are equal) * (assume here that tile_height and tile_width are equal)
@ -98,79 +104,72 @@ render_setup (int check_type,
tile_shift++; tile_shift++;
/* allocate a buffer for arranging information from a row of tiles */ /* allocate a buffer for arranging information from a row of tiles */
if (!tile_buf) if (! tile_buf)
tile_buf = g_new (guchar, GXIMAGE_WIDTH * MAX_CHANNELS); tile_buf = g_new (guchar, GXIMAGE_WIDTH * MAX_CHANNELS);
if (check_type < 0 || check_type > 5) if (! render_blend_dark_check)
g_error ("invalid check_type argument to render_setup: %d", check_type); render_blend_dark_check = g_new (guchar, 65536);
if (check_size < 0 || check_size > 2) if (! render_blend_light_check)
g_error ("invalid check_size argument to render_setup: %d", check_size); render_blend_light_check = g_new (guchar, 65536);
if (!blend_dark_check)
blend_dark_check = g_new (guchar, 65536);
if (!blend_light_check)
blend_light_check = g_new (guchar, 65536);
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
for (j = 0; j < 256; j++) for (j = 0; j < 256; j++)
{ {
blend_dark_check [(i << 8) + j] = (guchar) render_blend_dark_check [(i << 8) + j] = (guchar)
((j * i + check_combos[check_type][0] * (255 - i)) / 255); ((j * i + check_combos[check_type][0] * (255 - i)) / 255);
blend_light_check [(i << 8) + j] = (guchar) render_blend_light_check [(i << 8) + j] = (guchar)
((j * i + check_combos[check_type][1] * (255 - i)) / 255); ((j * i + check_combos[check_type][1] * (255 - i)) / 255);
} }
switch (check_size) switch (check_size)
{ {
case SMALL_CHECKS: case SMALL_CHECKS:
check_mod = 0x3; check_mod = 0x3;
check_shift = 2; check_shift = 2;
break; break;
case MEDIUM_CHECKS: case MEDIUM_CHECKS:
check_mod = 0x7; check_mod = 0x7;
check_shift = 3; check_shift = 3;
break; break;
case LARGE_CHECKS: case LARGE_CHECKS:
check_mod = 0xf; check_mod = 0xf;
check_shift = 4; check_shift = 4;
break; break;
} }
g_free (render_check_buf);
g_free (render_empty_buf);
g_free (render_temp_buf);
/* calculate check buffer for previews */ /* calculate check buffer for previews */
if (preview_size) if (preview_size)
{ {
if (check_buf) render_check_buf = g_new (guchar, (preview_size + 4) * 3);
g_free (check_buf);
if (empty_buf)
g_free (empty_buf);
if (temp_buf)
g_free (temp_buf);
check_buf = (unsigned char *) g_malloc ((preview_size + 4) * 3);
for (i = 0; i < (preview_size + 4); i++) for (i = 0; i < (preview_size + 4); i++)
{ {
if (i & 0x4) if (i & 0x4)
{ {
check_buf[i * 3 + 0] = blend_dark_check[0]; render_check_buf[i * 3 + 0] = render_blend_dark_check[0];
check_buf[i * 3 + 1] = blend_dark_check[0]; render_check_buf[i * 3 + 1] = render_blend_dark_check[0];
check_buf[i * 3 + 2] = blend_dark_check[0]; render_check_buf[i * 3 + 2] = render_blend_dark_check[0];
} }
else else
{ {
check_buf[i * 3 + 0] = blend_light_check[0]; render_check_buf[i * 3 + 0] = render_blend_light_check[0];
check_buf[i * 3 + 1] = blend_light_check[0]; render_check_buf[i * 3 + 1] = render_blend_light_check[0];
check_buf[i * 3 + 2] = blend_light_check[0]; render_check_buf[i * 3 + 2] = render_blend_light_check[0];
} }
} }
empty_buf = (unsigned char *) g_malloc ((preview_size + 4) * 3);
memset (empty_buf, 0, (preview_size + 4) * 3); render_empty_buf = g_new0 (guchar, (preview_size + 4) * 3);
temp_buf = (unsigned char *) g_malloc ((preview_size + 4) * 3); render_temp_buf = g_new (guchar, (preview_size + 4) * 3);
} }
else else
{ {
check_buf = NULL; render_check_buf = NULL;
empty_buf = NULL; render_empty_buf = NULL;
temp_buf = NULL; render_temp_buf = NULL;
} }
} }
@ -178,39 +177,40 @@ void
render_free (void) render_free (void)
{ {
g_free (tile_buf); g_free (tile_buf);
g_free (check_buf); g_free (render_check_buf);
} }
/* Render Image functions */ /* Render Image functions */
static void render_image_rgb (RenderInfo *info); static void render_image_rgb (RenderInfo *info);
static void render_image_rgb_a (RenderInfo *info); static void render_image_rgb_a (RenderInfo *info);
static void render_image_gray (RenderInfo *info); static void render_image_gray (RenderInfo *info);
static void render_image_gray_a (RenderInfo *info); static void render_image_gray_a (RenderInfo *info);
static void render_image_indexed (RenderInfo *info); static void render_image_indexed (RenderInfo *info);
static void render_image_indexed_a (RenderInfo *info); static void render_image_indexed_a (RenderInfo *info);
static void render_image_init_info (RenderInfo *info, static void render_image_init_info (RenderInfo *info,
GDisplay *gdisp, GDisplay *gdisp,
int x, gint x,
int y, gint y,
int w, gint w,
int h); gint h);
static guint* render_image_init_alpha (int mult); static guint * render_image_init_alpha (gint mult);
static guchar* render_image_accelerate_scaling (int width, static guchar * render_image_accelerate_scaling (gint width,
int start, gint start,
float scalex); gfloat scalex);
static guchar* render_image_tile_fault (RenderInfo *info); static guchar * render_image_tile_fault (RenderInfo *info);
static RenderFunc render_funcs[6] = static RenderFunc render_funcs[6] =
{ {
render_image_rgb, render_image_rgb,
render_image_rgb_a, render_image_rgb_a,
render_image_gray, render_image_gray,
render_image_gray_a, render_image_gray_a,
render_image_indexed, render_image_indexed,
render_image_indexed_a, render_image_indexed_a,
}; };
@ -223,17 +223,18 @@ static RenderFunc render_funcs[6] =
void void
render_image (GDisplay *gdisp, render_image (GDisplay *gdisp,
int x, gint x,
int y, gint y,
int w, gint w,
int h) gint h)
{ {
RenderInfo info; RenderInfo info;
int image_type; gint image_type;
render_image_init_info (&info, gdisp, x, y, w, h); render_image_init_info (&info, gdisp, x, y, w, h);
image_type = gimp_image_projection_type (gdisp->gimage); image_type = gimp_image_projection_type (gdisp->gimage);
if ((image_type < 0) || (image_type > 5)) if ((image_type < 0) || (image_type > 5))
{ {
g_message ("unknown gimage projection type: %d", g_message ("unknown gimage projection type: %d",
@ -248,7 +249,8 @@ render_image (GDisplay *gdisp,
} }
/* Currently, only RGBA and GRAYA projection types are used - the rest /* Currently, only RGBA and GRAYA projection types are used - the rest
* are in case of future need. -- austin, 28th Nov 1998. */ * are in case of future need. -- austin, 28th Nov 1998.
*/
if (image_type != RGBA_GIMAGE && image_type != GRAYA_GIMAGE) if (image_type != RGBA_GIMAGE && image_type != GRAYA_GIMAGE)
g_warning ("using untested projection type %d", image_type); g_warning ("using untested projection type %d", image_type);
@ -256,7 +258,6 @@ render_image (GDisplay *gdisp,
} }
/*************************/ /*************************/
/* 8 Bit functions */ /* 8 Bit functions */
/*************************/ /*************************/
@ -267,24 +268,24 @@ render_image_indexed (RenderInfo *info)
guchar *src; guchar *src;
guchar *dest; guchar *dest;
guchar *cmap; guchar *cmap;
gulong val; gulong val;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
cmap = gimp_image_cmap (info->gdisp->gimage); cmap = gimp_image_cmap (info->gdisp->gimage);
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -293,14 +294,16 @@ render_image_indexed (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0)) if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
dest = info->dest; dest = info->dest;
g_return_if_fail (src != NULL); g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++) for (x = info->x; x < xe; x++)
{ {
val = src[INDEXED_PIX] * 3; val = src[INDEXED_PIX] * 3;
@ -334,30 +337,30 @@ render_image_indexed_a (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
guint *alpha; guint *alpha;
guchar *cmap; guchar *cmap;
gulong r, g, b; gulong r, g, b;
gulong val; gulong val;
guint a; guint a;
int dark_light; gint dark_light;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
cmap = gimp_image_cmap (info->gdisp->gimage); cmap = gimp_image_cmap (info->gdisp->gimage);
alpha = info->alpha; alpha = info->alpha;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -366,7 +369,9 @@ render_image_indexed_a (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0) && (y & check_mod)) if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -384,15 +389,15 @@ render_image_indexed_a (RenderInfo *info)
if (dark_light & 0x1) if (dark_light & 0x1)
{ {
r = blend_dark_check[(a | cmap[val+0])]; r = render_blend_dark_check[(a | cmap[val + 0])];
g = blend_dark_check[(a | cmap[val+1])]; g = render_blend_dark_check[(a | cmap[val + 1])];
b = blend_dark_check[(a | cmap[val+2])]; b = render_blend_dark_check[(a | cmap[val + 2])];
} }
else else
{ {
r = blend_light_check[(a | cmap[val+0])]; r = render_blend_light_check[(a | cmap[val + 0])];
g = blend_light_check[(a | cmap[val+1])]; g = render_blend_light_check[(a | cmap[val + 1])];
b = blend_light_check[(a | cmap[val+2])]; b = render_blend_light_check[(a | cmap[val + 2])];
} }
dest[0] = r; dest[0] = r;
@ -426,22 +431,22 @@ render_image_gray (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
gulong val; gulong val;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -450,7 +455,9 @@ render_image_gray (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0)) if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -491,27 +498,27 @@ render_image_gray_a (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
guint *alpha; guint *alpha;
gulong val; gulong val;
guint a; guint a;
int dark_light; gint dark_light;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
alpha = info->alpha; alpha = info->alpha;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -520,7 +527,9 @@ render_image_gray_a (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0) && (y & check_mod)) if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -534,9 +543,9 @@ render_image_gray_a (RenderInfo *info)
{ {
a = alpha[src[ALPHA_G_PIX]]; a = alpha[src[ALPHA_G_PIX]];
if (dark_light & 0x1) if (dark_light & 0x1)
val = blend_dark_check[(a | src[GRAY_PIX])]; val = render_blend_dark_check[(a | src[GRAY_PIX])];
else else
val = blend_light_check[(a | src[GRAY_PIX])]; val = render_blend_light_check[(a | src[GRAY_PIX])];
src += 2; src += 2;
dest[0] = val; dest[0] = val;
@ -570,21 +579,21 @@ render_image_rgb (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= (int)error - step; error -= (gint) error - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -593,7 +602,9 @@ render_image_rgb (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0)) if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -629,34 +640,32 @@ render_image_rgb (RenderInfo *info)
} }
} }
static void static void
render_image_rgb_a (RenderInfo *info) render_image_rgb_a (RenderInfo *info)
{ {
guchar *src; guchar *src;
guchar *dest; guchar *dest;
guint *alpha; guint *alpha;
gulong r, g, b; gulong r, g, b;
guint a; guint a;
int dark_light; gint dark_light;
int byte_order; gint byte_order;
int y, ye; gint y, ye;
int x, xe; gint x, xe;
int initial; gint initial;
float error; gfloat error;
float step; gfloat step;
alpha = info->alpha; alpha = info->alpha;
y = info->y; y = info->y;
ye = info->y + info->h; ye = info->y + info->h;
xe = info->x + info->w; xe = info->x + info->w;
step = 1.0 / info->scaley; step = 1.0 / info->scaley;
error = y * step; error = y * step;
error -= ((int)error) - step; error -= ((gint) error) - step;
initial = TRUE; initial = TRUE;
byte_order = info->byte_order; byte_order = info->byte_order;
@ -665,7 +674,9 @@ render_image_rgb_a (RenderInfo *info)
for (; y < ye; y++) for (; y < ye; y++)
{ {
if (!initial && (error < 1.0) && (y & check_mod)) if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width); {
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else else
{ {
src = info->src; src = info->src;
@ -680,15 +691,15 @@ render_image_rgb_a (RenderInfo *info)
a = alpha[src[ALPHA_PIX]]; a = alpha[src[ALPHA_PIX]];
if (dark_light & 0x1) if (dark_light & 0x1)
{ {
r = blend_dark_check[(a | src[RED_PIX])]; r = render_blend_dark_check[(a | src[RED_PIX])];
g = blend_dark_check[(a | src[GREEN_PIX])]; g = render_blend_dark_check[(a | src[GREEN_PIX])];
b = blend_dark_check[(a | src[BLUE_PIX])]; b = render_blend_dark_check[(a | src[BLUE_PIX])];
} }
else else
{ {
r = blend_light_check[(a | src[RED_PIX])]; r = render_blend_light_check[(a | src[RED_PIX])];
g = blend_light_check[(a | src[GREEN_PIX])]; g = render_blend_light_check[(a | src[GREEN_PIX])];
b = blend_light_check[(a | src[BLUE_PIX])]; b = render_blend_light_check[(a | src[BLUE_PIX])];
} }
src += 4; src += 4;
@ -722,36 +733,37 @@ render_image_rgb_a (RenderInfo *info)
static void static void
render_image_init_info (RenderInfo *info, render_image_init_info (RenderInfo *info,
GDisplay *gdisp, GDisplay *gdisp,
int x, gint x,
int y, gint y,
int w, gint w,
int h) gint h)
{ {
info->gdisp = gdisp; info->gdisp = gdisp;
info->src_tiles = gimp_image_projection (gdisp->gimage); info->src_tiles = gimp_image_projection (gdisp->gimage);
info->x = x + gdisp->offset_x; info->x = x + gdisp->offset_x;
info->y = y + gdisp->offset_y; info->y = y + gdisp->offset_y;
info->w = w; info->w = w;
info->h = h; info->h = h;
info->scalex = SCALEFACTOR_X (gdisp); info->scalex = SCALEFACTOR_X (gdisp);
info->scaley = SCALEFACTOR_Y (gdisp); info->scaley = SCALEFACTOR_Y (gdisp);
info->src_x = UNSCALEX (gdisp, info->x); info->src_x = UNSCALEX (gdisp, info->x);
info->src_y = UNSCALEY (gdisp, info->y); info->src_y = UNSCALEY (gdisp, info->y);
info->src_bpp = gimp_image_projection_bytes (gdisp->gimage); info->src_bpp = gimp_image_projection_bytes (gdisp->gimage);
info->dest = gximage_get_data (); info->dest = gximage_get_data ();
info->dest_bpp = gximage_get_bpp (); info->dest_bpp = gximage_get_bpp ();
info->dest_bpl = gximage_get_bpl (); info->dest_bpl = gximage_get_bpl ();
info->dest_width = info->w * info->dest_bpp; info->dest_width = info->w * info->dest_bpp;
info->byte_order = gximage_get_byte_order (); info->byte_order = gximage_get_byte_order ();
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; info->alpha = NULL;
switch (gimp_image_projection_type (gdisp->gimage)) switch (gimp_image_projection_type (gdisp->gimage))
{ {
case RGBA_GIMAGE: case RGBA_GIMAGE:
case GRAYA_GIMAGE: case GRAYA_GIMAGE:
case INDEXEDA_GIMAGE: case INDEXEDA_GIMAGE:
info->alpha = render_image_init_alpha (gimp_image_projection_opacity (gdisp->gimage)); info->alpha =
render_image_init_alpha (gimp_image_projection_opacity (gdisp->gimage));
break; break;
default: default:
/* nothing special needs doing */ /* nothing special needs doing */
@ -760,11 +772,12 @@ render_image_init_info (RenderInfo *info,
} }
static guint* static guint*
render_image_init_alpha (int mult) render_image_init_alpha (gint mult)
{ {
static guint *alpha_mult = NULL; static guint *alpha_mult = NULL;
static int alpha_val = -1; static gint alpha_val = -1;
int i;
gint i;
if (alpha_val != mult) if (alpha_val != mult)
{ {
@ -780,14 +793,15 @@ render_image_init_alpha (int mult)
} }
static guchar* static guchar*
render_image_accelerate_scaling (int width, render_image_accelerate_scaling (gint width,
int start, gint start,
float scalex) gfloat scalex)
{ {
static guchar *scale = NULL; static guchar *scale = NULL;
float error;
float step; gfloat error;
int i; gfloat step;
gint i;
if (!scale) if (!scale)
scale = g_new (guchar, GXIMAGE_WIDTH + 1); scale = g_new (guchar, GXIMAGE_WIDTH + 1);
@ -806,20 +820,20 @@ render_image_accelerate_scaling (int width,
return scale; return scale;
} }
static guchar* static guchar *
render_image_tile_fault (RenderInfo *info) render_image_tile_fault (RenderInfo *info)
{ {
Tile *tile; Tile *tile;
guchar *data; guchar *data;
guchar *dest; guchar *dest;
guchar *scale; guchar *scale;
int width; gint width;
int tilex; gint tilex;
int tiley; gint tiley;
int srctilex, srctiley; gint srctilex, srctiley;
int step; gint step;
int bpp = info->src_bpp; gint bpp = info->src_bpp;
int x, b; gint x, b;
tilex = info->src_x / TILE_WIDTH; tilex = info->src_x / TILE_WIDTH;
tiley = info->src_y / TILE_HEIGHT; tiley = info->src_y / TILE_HEIGHT;
@ -834,9 +848,9 @@ render_image_tile_fault (RenderInfo *info)
info->src_x % TILE_WIDTH, info->src_x % TILE_WIDTH,
info->src_y % TILE_HEIGHT); info->src_y % TILE_HEIGHT);
scale = info->scale; scale = info->scale;
dest = tile_buf; dest = tile_buf;
x = info->src_x; x = info->src_x;
width = info->w; width = info->w;
while (width--) while (width--)
@ -868,5 +882,6 @@ render_image_tile_fault (RenderInfo *info)
} }
tile_release (tile, FALSE); tile_release (tile, FALSE);
return tile_buf; return tile_buf;
} }

View File

@ -22,35 +22,42 @@
/* Transparency representation */ /* Transparency representation */
#define LIGHT_CHECKS 0 typedef enum
#define GRAY_CHECKS 1 {
#define DARK_CHECKS 2 LIGHT_CHECKS = 0,
#define WHITE_ONLY 3 GRAY_CHECKS = 1,
#define GRAY_ONLY 4 DARK_CHECKS = 2,
#define BLACK_ONLY 5 WHITE_ONLY = 3,
GRAY_ONLY = 4,
BLACK_ONLY = 5
} GimpCheckType;
typedef enum
{
SMALL_CHECKS = 0,
MEDIUM_CHECKS = 1,
LARGE_CHECKS = 2
} GimpCheckSize;
#define SMALL_CHECKS 0
#define MEDIUM_CHECKS 1
#define LARGE_CHECKS 2
/* Functions */ /* Functions */
void render_setup (gint check_type, void render_setup (GimpCheckType check_type,
gint check_size); GimpCheckSize check_size);
void render_free (void); void render_free (void);
void render_image (GDisplay *gdisp, void render_image (GDisplay *gdisp,
gint x, gint x,
gint y, gint y,
gint w, gint w,
gint h); gint h);
/* /*
* Extern variables * Extern variables
*/ */
extern guchar *check_buf; extern guchar *render_check_buf;
extern guchar *empty_buf; extern guchar *render_empty_buf;
extern guchar *temp_buf; extern guchar *render_temp_buf;
extern guchar *blend_dark_check; extern guchar *render_blend_dark_check;
extern guchar *blend_light_check; extern guchar *render_blend_light_check;
#endif /* __IMAGE_RENDER_H__ */ #endif /* __IMAGE_RENDER_H__ */

View File

@ -775,13 +775,13 @@ render_preview (TempBuf *preview_buf,
if (has_alpha) if (has_alpha)
{ {
buf = check_buf; buf = render_check_buf;
alpha = ((color) ? ALPHA_PIX : alpha = ((color) ? ALPHA_PIX :
((channel != -1) ? (preview_buf->bytes - 1) : ((channel != -1) ? (preview_buf->bytes - 1) :
ALPHA_G_PIX)); ALPHA_G_PIX));
} }
else else
buf = empty_buf; buf = render_empty_buf;
x1 = CLAMP (preview_buf->x, 0, width); x1 = CLAMP (preview_buf->x, 0, width);
y1 = CLAMP (preview_buf->y, 0, height); y1 = CLAMP (preview_buf->y, 0, height);
@ -815,7 +815,7 @@ render_preview (TempBuf *preview_buf,
/* Handle the leading transparency */ /* Handle the leading transparency */
for (j = 0; j < x1; j++) for (j = 0; j < x1; j++)
for (b = 0; b < image_bytes; b++) for (b = 0; b < image_bytes; b++)
temp_buf[j * image_bytes + b] = cb[j * 3 + b]; render_temp_buf[j * image_bytes + b] = cb[j * 3 + b];
/* The stuff in the middle */ /* The stuff in the middle */
s = src; s = src;
@ -829,28 +829,28 @@ render_preview (TempBuf *preview_buf,
if ((j + offset) & 0x4) if ((j + offset) & 0x4)
{ {
temp_buf[j * 3 + 0] = render_temp_buf[j * 3 + 0] =
blend_dark_check [(a | s[RED_PIX])]; render_blend_dark_check [(a | s[RED_PIX])];
temp_buf[j * 3 + 1] = render_temp_buf[j * 3 + 1] =
blend_dark_check [(a | s[GREEN_PIX])]; render_blend_dark_check [(a | s[GREEN_PIX])];
temp_buf[j * 3 + 2] = render_temp_buf[j * 3 + 2] =
blend_dark_check [(a | s[BLUE_PIX])]; render_blend_dark_check [(a | s[BLUE_PIX])];
} }
else else
{ {
temp_buf[j * 3 + 0] = render_temp_buf[j * 3 + 0] =
blend_light_check [(a | s[RED_PIX])]; render_blend_light_check [(a | s[RED_PIX])];
temp_buf[j * 3 + 1] = render_temp_buf[j * 3 + 1] =
blend_light_check [(a | s[GREEN_PIX])]; render_blend_light_check [(a | s[GREEN_PIX])];
temp_buf[j * 3 + 2] = render_temp_buf[j * 3 + 2] =
blend_light_check [(a | s[BLUE_PIX])]; render_blend_light_check [(a | s[BLUE_PIX])];
} }
} }
else else
{ {
temp_buf[j * 3 + 0] = s[RED_PIX]; render_temp_buf[j * 3 + 0] = s[RED_PIX];
temp_buf[j * 3 + 1] = s[GREEN_PIX]; render_temp_buf[j * 3 + 1] = s[GREEN_PIX];
temp_buf[j * 3 + 2] = s[BLUE_PIX]; render_temp_buf[j * 3 + 2] = s[BLUE_PIX];
} }
} }
else else
@ -863,43 +863,43 @@ render_preview (TempBuf *preview_buf,
{ {
if (color_buf) if (color_buf)
{ {
temp_buf[j * 3 + 0] = render_temp_buf[j * 3 + 0] =
blend_dark_check [(a | s[GRAY_PIX])]; render_blend_dark_check [(a | s[GRAY_PIX])];
temp_buf[j * 3 + 1] = render_temp_buf[j * 3 + 1] =
blend_dark_check [(a | s[GRAY_PIX])]; render_blend_dark_check [(a | s[GRAY_PIX])];
temp_buf[j * 3 + 2] = render_temp_buf[j * 3 + 2] =
blend_dark_check [(a | s[GRAY_PIX])]; render_blend_dark_check [(a | s[GRAY_PIX])];
} }
else else
temp_buf[j] = render_temp_buf[j] =
blend_dark_check [(a | s[GRAY_PIX + channel])]; render_blend_dark_check [(a | s[GRAY_PIX + channel])];
} }
else else
{ {
if (color_buf) if (color_buf)
{ {
temp_buf[j * 3 + 0] = render_temp_buf[j * 3 + 0] =
blend_light_check [(a | s[GRAY_PIX])]; render_blend_light_check [(a | s[GRAY_PIX])];
temp_buf[j * 3 + 1] = render_temp_buf[j * 3 + 1] =
blend_light_check [(a | s[GRAY_PIX])]; render_blend_light_check [(a | s[GRAY_PIX])];
temp_buf[j * 3 + 2] = render_temp_buf[j * 3 + 2] =
blend_light_check [(a | s[GRAY_PIX])]; render_blend_light_check [(a | s[GRAY_PIX])];
} }
else else
temp_buf[j] = render_temp_buf[j] =
blend_light_check [(a | s[GRAY_PIX + channel])]; render_blend_light_check [(a | s[GRAY_PIX + channel])];
} }
} }
else else
{ {
if (color_buf) if (color_buf)
{ {
temp_buf[j * 3 + 0] = s[GRAY_PIX]; render_temp_buf[j * 3 + 0] = s[GRAY_PIX];
temp_buf[j * 3 + 1] = s[GRAY_PIX]; render_temp_buf[j * 3 + 1] = s[GRAY_PIX];
temp_buf[j * 3 + 2] = s[GRAY_PIX]; render_temp_buf[j * 3 + 2] = s[GRAY_PIX];
} }
else else
temp_buf[j] = s[GRAY_PIX + channel]; render_temp_buf[j] = s[GRAY_PIX + channel];
} }
} }
@ -909,7 +909,7 @@ render_preview (TempBuf *preview_buf,
/* Handle the trailing transparency */ /* Handle the trailing transparency */
for (j = x2; j < width; j++) for (j = x2; j < width; j++)
for (b = 0; b < image_bytes; b++) for (b = 0; b < image_bytes; b++)
temp_buf[j * image_bytes + b] = cb[j * 3 + b]; render_temp_buf[j * image_bytes + b] = cb[j * 3 + b];
src += rowstride; src += rowstride;
} }
@ -917,11 +917,11 @@ render_preview (TempBuf *preview_buf,
{ {
for (j = 0; j < width; j++) for (j = 0; j < width; j++)
for (b = 0; b < image_bytes; b++) for (b = 0; b < image_bytes; b++)
temp_buf[j * image_bytes + b] = cb[j * 3 + b]; render_temp_buf[j * image_bytes + b] = cb[j * 3 + b];
} }
gtk_preview_draw_row (GTK_PREVIEW (preview_widget), gtk_preview_draw_row (GTK_PREVIEW (preview_widget),
temp_buf, 0, i, width); render_temp_buf, 0, i, width);
} }
} }

View File

@ -606,7 +606,7 @@ ipal_draw (GimpColormapDialog* ipal)
for (l = j * cellsize; l < xn * cellsize; l++) for (l = j * cellsize; l < xn * cellsize; l++)
for (b = 0; b < 3; b++) for (b = 0; b < 3; b++)
row[l * 3 + b] = ((((i * cellsize + k) & 0x4) ? (l) : (l + 0x4)) & 0x4) ? row[l * 3 + b] = ((((i * cellsize + k) & 0x4) ? (l) : (l + 0x4)) & 0x4) ?
blend_light_check[0] : blend_dark_check[0]; render_blend_light_check[0] : render_blend_dark_check[0];
gtk_preview_draw_row (ipal->palette, row, 0, gtk_preview_draw_row (ipal->palette, row, 0,
i * cellsize + k, cellsize * xn); i * cellsize + k, cellsize * xn);
@ -709,7 +709,8 @@ ipal_clear (GimpColormapDialog* ipal)
for (j = 0; j < width; j++) for (j = 0; j < width; j++)
{ {
row[j * 3 + 0] = row[j * 3 + 1] = row[j * 3 + 2] = row[j * 3 + 0] = row[j * 3 + 1] = row[j * 3 + 2] =
((j + offset) & 0x4) ? blend_light_check[0] : blend_dark_check[0]; ((j + offset) & 0x4) ?
render_blend_light_check[0] : render_blend_dark_check[0];
} }
for (j = 0; j < 4 && i+j < height; j++) for (j = 0; j < 4 && i+j < height; j++)