Okay. Raster, trash.xcf should work now. Also fixed Divide

mode. It seems I missed the alpha level cases. I'll need to
check how the other modes perform when alpha levels are
involved.


SVN revision: 3883
This commit is contained in:
Christian Kreibich 2000-11-14 06:46:15 +00:00
parent f6a04f9218
commit 5c5d0842e5
2 changed files with 41 additions and 11 deletions

View File

@ -1446,72 +1446,86 @@ flatten_image(void)
switch (l->mode)
{
case MULTIPLY_MODE:
D(("MULTIPLY\n"));
combine_pixels_mult(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
break;
case DIVIDE_MODE:
D(("DIVIDE\n"));
combine_pixels_div(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
break;
case SCREEN_MODE:
D(("SCREEN\n"));
combine_pixels_screen(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
break;
case OVERLAY_MODE:
D(("OVERLAY\n"));
combine_pixels_overlay(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
break;
case DIFFERENCE_MODE:
D(("DIFF\n"));
combine_pixels_diff(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
break;
case ADDITION_MODE:
D(("ADD\n"));
combine_pixels_add(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
break;
case SUBTRACT_MODE:
D(("SUB\n"));
combine_pixels_sub(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
break;
case DARKEN_ONLY_MODE:
D(("DARKEN\n"));
combine_pixels_darken(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
break;
case LIGHTEN_ONLY_MODE:
D(("LIGHTEN\n"));
combine_pixels_lighten(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
break;
case HUE_MODE:
D(("HUE\n"));
combine_pixels_hue(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
break;
case SATURATION_MODE:
D(("SATURATION\n"));
combine_pixels_sat(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
break;
case VALUE_MODE:
D(("VALUE\n"));
combine_pixels_val(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
break;
case COLOR_MODE:
D(("COLOR\n"));
combine_pixels_col(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
break;
case DISSOLVE_MODE:
D(("DISSOLVE\n"));
combine_pixels_diss(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);
@ -1522,8 +1536,10 @@ flatten_image(void)
case REPLACE_MODE:
case ERASE_MODE:
case ANTI_ERASE_MODE:
D(("EEEEEK -- this mode shouldn't be here\n"));
case NORMAL_MODE:
D(("NORMAL\n"));
combine_pixels_normal(l->data, l->width, l->height,
image->data, image->width, image->height,
l->offset_x, l->offset_y);

View File

@ -17,6 +17,15 @@
#include "image.h"
#include "color_values.h"
#ifdef XCF_DBG
#define D(s) \
{ \
printf s; \
}
#else
#define D(s)
#endif
#define RS R_VAL(src + s_idx)
#define GS G_VAL(src + s_idx)
#define BS B_VAL(src + s_idx)
@ -28,8 +37,8 @@
#define EPS 0.00001
#define PI 3.141592654
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a < b) ? a : b)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define INT_MULT(a,b,t) ((t) = (a) * (b) + 0x80, ((((t) >> 8) + (t)) >> 8))
#define LINEAR(x,y,w) ((w*y + x)*4)
@ -489,6 +498,7 @@ combine_pixels_mult (DATA8* src, int src_w, int src_h, DATA8* dest, int dest_w,
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;
int tmp;
clip(&src_tl_x, &src_tl_y, &src_br_x, &src_br_y, &dest_x, &dest_y, dest_w, dest_h);
@ -497,13 +507,15 @@ combine_pixels_mult (DATA8* src, int src_w, int src_h, DATA8* dest, int dest_w,
{
d_idx = LINEAR((dest_x + x - src_tl_x), (dest_y + y - src_tl_y), dest_w);
s_idx = LINEAR(x, y, src_w);
RD = (RD * RS) >> 8;
GD = (GD * GS) >> 8;
BD = (BD * BS) >> 8;
AD = MIN(AD, AS);
RS = INT_MULT(RS, RD, tmp);
GS = INT_MULT(GS, GD, tmp);
BS = INT_MULT(BS, BD, tmp);
AS = MIN(AS, AD);
}
combine_pixels_normal(src, src_w, src_h, dest, dest_w, dest_h, dest_x, dest_y);
}
@ -522,12 +534,14 @@ combine_pixels_div (DATA8* src, int src_w, int src_h, DATA8* dest, int dest_w, i
d_idx = LINEAR((dest_x + x - src_tl_x), (dest_y + y - src_tl_y), dest_w);
s_idx = LINEAR(x, y, src_w);
RD = MIN(255, ((float)RD / (RS + 1)) * 256);
GD = MIN(255, ((float)GD / (GS + 1)) * 256);
BD = MIN(255, ((float)BD / (BS + 1)) * 256);
RS = MIN(255, ((float)RD / (RS + 1)) * 256);
GS = MIN(255, ((float)GD / (GS + 1)) * 256);
BS = MIN(255, ((float)BD / (BS + 1)) * 256);
AD = MIN(AD, AS);
AS = MIN(AD, AS);
}
combine_pixels_normal(src, src_w, src_h, dest, dest_w, dest_h, dest_x, dest_y);
}