Commit 5cc38d44 authored by Manish Singh's avatar Manish Singh
Browse files

divide paint mode stuff

-Yosh
parent 46d02508
Mon Jun 8 20:58:09 PDT 1998 Manish Singh <yosh@gimp.org>
* app/blend.c
* app/brushes.c
* app/brush_select.c
* app/bucket_fill.c
* app/layer_cmds.c
* app/layers_dialog.c
* app/paint_funcs.[ch]: applied a variation on
gimp-scier-980315-0 (implements divide (dodge) layer mode)
Mon Jun 8 22:09:07 1998 Owen Taylor <otaylor@gtk.org>
* app/airbrush.c: Simple pressure sensitivity.
......
......@@ -1705,7 +1705,7 @@ ProcArg blend_args[] =
},
{ PDB_INT32,
"paint_mode",
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14) }"
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
},
{ PDB_INT32,
"gradient_type",
......
......@@ -72,7 +72,8 @@ static MenuItem option_items[] =
{ "Normal", 0, 0, paint_mode_menu_callback, (gpointer) NORMAL_MODE, NULL, NULL },
{ "Dissolve", 0, 0, paint_mode_menu_callback, (gpointer) DISSOLVE_MODE, NULL, NULL },
{ "Behind", 0, 0, paint_mode_menu_callback, (gpointer) BEHIND_MODE, NULL, NULL },
{ "Multiply", 0, 0, paint_mode_menu_callback, (gpointer) MULTIPLY_MODE, NULL, NULL },
{ "Multiply (Burn)", 0, 0, paint_mode_menu_callback, (gpointer) MULTIPLY_MODE, NULL, NULL },
{ "Divide (Dodge)", 0, 0, paint_mode_menu_callback, (gpointer) DIVIDE_MODE, NULL, NULL },
{ "Screen", 0, 0, paint_mode_menu_callback, (gpointer) SCREEN_MODE, NULL, NULL },
{ "Overlay", 0, 0, paint_mode_menu_callback, (gpointer) OVERLAY_MODE, NULL, NULL },
{ "Difference", 0, 0, paint_mode_menu_callback, (gpointer) DIFFERENCE_MODE, NULL, NULL },
......
......@@ -817,7 +817,7 @@ ProcArg brushes_get_paint_mode_out_args[] =
{
{ PDB_INT32,
"paint_mode",
"the paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14) }"
"the paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
}
};
......@@ -866,7 +866,7 @@ ProcArg brushes_set_paint_mode_args[] =
{
{ PDB_INT32,
"paint_mode",
"the paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14) }"
"the paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
}
};
......
......@@ -709,7 +709,7 @@ ProcArg bucket_fill_args[] =
},
{ PDB_INT32,
"paint_mode",
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14) }"
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
},
{ PDB_FLOAT,
"opacity",
......
......@@ -1705,7 +1705,7 @@ ProcArg blend_args[] =
},
{ PDB_INT32,
"paint_mode",
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14) }"
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
},
{ PDB_INT32,
"gradient_type",
......
......@@ -72,7 +72,8 @@ static MenuItem option_items[] =
{ "Normal", 0, 0, paint_mode_menu_callback, (gpointer) NORMAL_MODE, NULL, NULL },
{ "Dissolve", 0, 0, paint_mode_menu_callback, (gpointer) DISSOLVE_MODE, NULL, NULL },
{ "Behind", 0, 0, paint_mode_menu_callback, (gpointer) BEHIND_MODE, NULL, NULL },
{ "Multiply", 0, 0, paint_mode_menu_callback, (gpointer) MULTIPLY_MODE, NULL, NULL },
{ "Multiply (Burn)", 0, 0, paint_mode_menu_callback, (gpointer) MULTIPLY_MODE, NULL, NULL },
{ "Divide (Dodge)", 0, 0, paint_mode_menu_callback, (gpointer) DIVIDE_MODE, NULL, NULL },
{ "Screen", 0, 0, paint_mode_menu_callback, (gpointer) SCREEN_MODE, NULL, NULL },
{ "Overlay", 0, 0, paint_mode_menu_callback, (gpointer) OVERLAY_MODE, NULL, NULL },
{ "Difference", 0, 0, paint_mode_menu_callback, (gpointer) DIFFERENCE_MODE, NULL, NULL },
......
......@@ -253,7 +253,8 @@ static MenuItem option_items[] =
{
{ "Normal", 0, 0, paint_mode_menu_callback, (gpointer) NORMAL_MODE, NULL, NULL },
{ "Dissolve", 0, 0, paint_mode_menu_callback, (gpointer) DISSOLVE_MODE, NULL, NULL },
{ "Multiply", 0, 0, paint_mode_menu_callback, (gpointer) MULTIPLY_MODE, NULL, NULL },
{ "Multiply (Burn)", 0, 0, paint_mode_menu_callback, (gpointer) MULTIPLY_MODE, NULL, NULL },
{ "Divide (Dodge)", 0, 0, paint_mode_menu_callback, (gpointer) DIVIDE_MODE, NULL, NULL },
{ "Screen", 0, 0, paint_mode_menu_callback, (gpointer) SCREEN_MODE, NULL, NULL },
{ "Overlay", 0, 0, paint_mode_menu_callback, (gpointer) OVERLAY_MODE, NULL, NULL },
{ "Difference", 0, 0, paint_mode_menu_callback, (gpointer) DIFFERENCE_MODE, NULL, NULL },
......
......@@ -1712,7 +1712,7 @@ ProcArg layer_get_mode_out_args[] =
{
{ PDB_INT32,
"mode",
"the layer combination mode: { NORMAL (0), DISSOLVE (1), MULTIPLY (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14) }"
"the layer combination mode: { NORMAL (0), DISSOLVE (1), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
}
};
......
......@@ -253,7 +253,8 @@ static MenuItem option_items[] =
{
{ "Normal", 0, 0, paint_mode_menu_callback, (gpointer) NORMAL_MODE, NULL, NULL },
{ "Dissolve", 0, 0, paint_mode_menu_callback, (gpointer) DISSOLVE_MODE, NULL, NULL },
{ "Multiply", 0, 0, paint_mode_menu_callback, (gpointer) MULTIPLY_MODE, NULL, NULL },
{ "Multiply (Burn)", 0, 0, paint_mode_menu_callback, (gpointer) MULTIPLY_MODE, NULL, NULL },
{ "Divide (Dodge)", 0, 0, paint_mode_menu_callback, (gpointer) DIVIDE_MODE, NULL, NULL },
{ "Screen", 0, 0, paint_mode_menu_callback, (gpointer) SCREEN_MODE, NULL, NULL },
{ "Overlay", 0, 0, paint_mode_menu_callback, (gpointer) OVERLAY_MODE, NULL, NULL },
{ "Difference", 0, 0, paint_mode_menu_callback, (gpointer) DIFFERENCE_MODE, NULL, NULL },
......
......@@ -53,7 +53,7 @@ LayerMode layer_modes[] =
{ 1, "Normal" },
{ 1, "Dissolve" },
{ 1, "Behind" },
{ 0, "Multiply" },
{ 0, "Multiply (Burn)" },
{ 0, "Screen" },
{ 0, "Overlay" },
{ 0, "Difference" },
......@@ -65,6 +65,7 @@ LayerMode layer_modes[] =
{ 0, "Saturation" },
{ 0, "Color" },
{ 0, "Value" },
{ 0, "Divide (Dodge)" },
{ 1, "Erase" },
{ 1, "Replace" }
};
......@@ -651,6 +652,39 @@ multiply_pixels (unsigned char *src1,
}
void
divide_pixels (unsigned char *src1,
unsigned char *src2,
unsigned char *dest,
int length,
int b1,
int b2,
int ha1,
int ha2)
{
int alpha, b, result;
alpha = (ha1 || ha2) ? MAXIMUM (b1, b2) - 1 : b1;
while (length --)
{
for (b = 0; b < alpha; b++) {
result = ((src1[b] * 256) / (1+src2[b]));
dest[b] = (result > 255) ? 255 : result;
}
if (ha1 && ha2)
dest[alpha] = MIN (src1[alpha], src2[alpha]);
else if (ha2)
dest[alpha] = src2[alpha];
src1 += b1;
src2 += b2;
dest += b2;
}
}
void
screen_pixels (unsigned char *src1,
unsigned char *src2,
......@@ -4292,6 +4326,10 @@ apply_layer_mode (unsigned char *src1,
multiply_pixels (src1, src2, *dest, length, b1, b2, ha1, ha2);
break;
case DIVIDE_MODE:
divide_pixels (src1, src2, *dest, length, b1, b2, ha1, ha2);
break;
case SCREEN_MODE:
screen_pixels (src1, src2, *dest, length, b1, b2, ha1, ha2);
break;
......
......@@ -60,6 +60,9 @@ void color_only_pixels (unsigned char *, unsigned char *,
void multiply_pixels (unsigned char *, unsigned char *,
unsigned char *, int, int, int, int, int);
void divide_pixels (unsigned char *, unsigned char *,
unsigned char *, int, int, int, int, int);
void screen_pixels (unsigned char *, unsigned char *,
unsigned char *, int, int, int, int, int);
......@@ -438,8 +441,9 @@ void hls_to_rgb (int *, int *, int *);
#define SATURATION_MODE 12
#define COLOR_MODE 13
#define VALUE_MODE 14
#define ERASE_MODE 15
#define REPLACE_MODE 16
#define DIVIDE_MODE 15
#define ERASE_MODE 16
#define REPLACE_MODE 17
/* Applying layer modes... */
......
......@@ -53,7 +53,7 @@ LayerMode layer_modes[] =
{ 1, "Normal" },
{ 1, "Dissolve" },
{ 1, "Behind" },
{ 0, "Multiply" },
{ 0, "Multiply (Burn)" },
{ 0, "Screen" },
{ 0, "Overlay" },
{ 0, "Difference" },
......@@ -65,6 +65,7 @@ LayerMode layer_modes[] =
{ 0, "Saturation" },
{ 0, "Color" },
{ 0, "Value" },
{ 0, "Divide (Dodge)" },
{ 1, "Erase" },
{ 1, "Replace" }
};
......@@ -651,6 +652,39 @@ multiply_pixels (unsigned char *src1,
}
void
divide_pixels (unsigned char *src1,
unsigned char *src2,
unsigned char *dest,
int length,
int b1,
int b2,
int ha1,
int ha2)
{
int alpha, b, result;
alpha = (ha1 || ha2) ? MAXIMUM (b1, b2) - 1 : b1;
while (length --)
{
for (b = 0; b < alpha; b++) {
result = ((src1[b] * 256) / (1+src2[b]));
dest[b] = (result > 255) ? 255 : result;
}
if (ha1 && ha2)
dest[alpha] = MIN (src1[alpha], src2[alpha]);
else if (ha2)
dest[alpha] = src2[alpha];
src1 += b1;
src2 += b2;
dest += b2;
}
}
void
screen_pixels (unsigned char *src1,
unsigned char *src2,
......@@ -4292,6 +4326,10 @@ apply_layer_mode (unsigned char *src1,
multiply_pixels (src1, src2, *dest, length, b1, b2, ha1, ha2);
break;
case DIVIDE_MODE:
divide_pixels (src1, src2, *dest, length, b1, b2, ha1, ha2);
break;
case SCREEN_MODE:
screen_pixels (src1, src2, *dest, length, b1, b2, ha1, ha2);
break;
......
......@@ -60,6 +60,9 @@ void color_only_pixels (unsigned char *, unsigned char *,
void multiply_pixels (unsigned char *, unsigned char *,
unsigned char *, int, int, int, int, int);
void divide_pixels (unsigned char *, unsigned char *,
unsigned char *, int, int, int, int, int);
void screen_pixels (unsigned char *, unsigned char *,
unsigned char *, int, int, int, int, int);
......@@ -438,8 +441,9 @@ void hls_to_rgb (int *, int *, int *);
#define SATURATION_MODE 12
#define COLOR_MODE 13
#define VALUE_MODE 14
#define ERASE_MODE 15
#define REPLACE_MODE 16
#define DIVIDE_MODE 15
#define ERASE_MODE 16
#define REPLACE_MODE 17
/* Applying layer modes... */
......
......@@ -1705,7 +1705,7 @@ ProcArg blend_args[] =
},
{ PDB_INT32,
"paint_mode",
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14) }"
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
},
{ PDB_INT32,
"gradient_type",
......
......@@ -709,7 +709,7 @@ ProcArg bucket_fill_args[] =
},
{ PDB_INT32,
"paint_mode",
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14) }"
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
},
{ PDB_FLOAT,
"opacity",
......
......@@ -1705,7 +1705,7 @@ ProcArg blend_args[] =
},
{ PDB_INT32,
"paint_mode",
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14) }"
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
},
{ PDB_INT32,
"gradient_type",
......
......@@ -709,7 +709,7 @@ ProcArg bucket_fill_args[] =
},
{ PDB_INT32,
"paint_mode",
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14) }"
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
},
{ PDB_FLOAT,
"opacity",
......
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