mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-15 21:40:34 +00:00
Remove blend modes from ImageLayers.
This commit is contained in:
parent
551efd4313
commit
7ace9a2099
@ -121,7 +121,8 @@ Layer Chunk (0x2004)
|
||||
WORD Layer child level (see NOTE.1)
|
||||
WORD Default layer width in pixels (ignored)
|
||||
WORD Default layer height in pixels (ignored)
|
||||
WORD Blend mode (always 0 for layer set)
|
||||
WORD DEPRECATED This field is not used anymore.
|
||||
Blend mode (always 0 for layer set)
|
||||
BLEND_MODE_NORMAL = 0
|
||||
BLEND_MODE_DISSOLVE = 1
|
||||
BLEND_MODE_MULTIPLY = 2
|
||||
|
@ -60,10 +60,8 @@ bool LayerPropertiesCommand::onEnabled(Context* context)
|
||||
|
||||
void LayerPropertiesCommand::onExecute(Context* context)
|
||||
{
|
||||
JWidget label_bm, view_bm, list_bm;
|
||||
CurrentSpriteWriter sprite(context);
|
||||
Layer* layer = sprite->getCurrentLayer();
|
||||
bool with_blend_modes = (layer->is_image() && sprite->getImgType() != IMAGE_INDEXED);
|
||||
|
||||
FramePtr window(new Frame(false, "Layer Properties"));
|
||||
Widget* box1 = jbox_new(JI_VERTICAL);
|
||||
@ -77,46 +75,12 @@ void LayerPropertiesCommand::onExecute(Context* context)
|
||||
button_ok->Click.connect(Bind<void>(&Frame::closeWindow, window.get(), button_ok));
|
||||
button_cancel->Click.connect(Bind<void>(&Frame::closeWindow, window.get(), button_cancel));
|
||||
|
||||
if (with_blend_modes) {
|
||||
label_bm = new Label("Blend mode:");
|
||||
view_bm = jview_new();
|
||||
list_bm = jlistbox_new();
|
||||
|
||||
jwidget_add_child(list_bm, jlistitem_new("Normal"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Dissolve"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Multiply"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Screen"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Overlay"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Hard Light"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Dodge"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Burn"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Darken"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Lighten"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Addition"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Subtract"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Difference"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Hue"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Saturation"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Color"));
|
||||
jwidget_add_child(list_bm, jlistitem_new("Luminosity"));
|
||||
|
||||
jlistbox_select_index(list_bm, static_cast<LayerImage*>(layer)->get_blend_mode());
|
||||
|
||||
jview_attach(view_bm, list_bm);
|
||||
jwidget_set_min_size(view_bm, 128*jguiscale(), 64*jguiscale());
|
||||
jwidget_expansive(view_bm, true);
|
||||
}
|
||||
|
||||
jwidget_set_min_size(entry_name, 128, 0);
|
||||
jwidget_expansive(entry_name, true);
|
||||
|
||||
jwidget_add_child(box2, label_name);
|
||||
jwidget_add_child(box2, entry_name);
|
||||
jwidget_add_child(box1, box2);
|
||||
if (with_blend_modes) {
|
||||
jwidget_add_child(box1, label_bm);
|
||||
jwidget_add_child(box1, view_bm);
|
||||
}
|
||||
jwidget_add_child(box3, button_ok);
|
||||
jwidget_add_child(box3, button_cancel);
|
||||
jwidget_add_child(box1, box3);
|
||||
@ -130,9 +94,6 @@ void LayerPropertiesCommand::onExecute(Context* context)
|
||||
if (window->get_killer() == button_ok) {
|
||||
layer->setName(entry_name->getText());
|
||||
|
||||
if (with_blend_modes)
|
||||
static_cast<LayerImage*>(layer)->set_blend_mode(jlistbox_get_selected_index(list_bm));
|
||||
|
||||
update_screen_for_sprite(sprite);
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ void MergeDownLayerCommand::onExecute(Context* context)
|
||||
src_cel->x-x1,
|
||||
src_cel->y-y1,
|
||||
src_cel->opacity,
|
||||
static_cast<LayerImage*>(src_layer)->get_blend_mode());
|
||||
static_cast<LayerImage*>(src_layer)->getBlendMode());
|
||||
|
||||
if (sprite->getUndo()->isEnabled()) {
|
||||
sprite->getUndo()->undo_int(dst_cel, &dst_cel->x);
|
||||
|
@ -641,14 +641,13 @@ static Layer *ase_file_read_layer_chunk(FILE *f, Sprite *sprite, Layer **previou
|
||||
int flags;
|
||||
int layer_type;
|
||||
int child_level;
|
||||
int blend_mode;
|
||||
|
||||
flags = fgetw(f);
|
||||
layer_type = fgetw(f);
|
||||
child_level = fgetw(f);
|
||||
fgetw(f); /* default_width */
|
||||
fgetw(f); /* default_height */
|
||||
blend_mode = fgetw(f);
|
||||
fgetw(f); // default width
|
||||
fgetw(f); // default height
|
||||
fgetw(f); // blend mode
|
||||
|
||||
ase_file_read_padding(f, 4);
|
||||
name = ase_file_read_string(f);
|
||||
@ -656,7 +655,6 @@ static Layer *ase_file_read_layer_chunk(FILE *f, Sprite *sprite, Layer **previou
|
||||
/* image layer */
|
||||
if (layer_type == 0) {
|
||||
layer = new LayerImage(sprite);
|
||||
static_cast<LayerImage*>(layer)->set_blend_mode(blend_mode);
|
||||
}
|
||||
/* layer set */
|
||||
else if (layer_type == 1) {
|
||||
@ -704,10 +702,10 @@ static void ase_file_write_layer_chunk(FILE *f, Layer *layer)
|
||||
}
|
||||
fputw(child_level, f);
|
||||
|
||||
/* width, height and blend mode */
|
||||
/* default width & height, and blend mode */
|
||||
fputw(0, f);
|
||||
fputw(0, f);
|
||||
fputw(layer->is_image() ? static_cast<LayerImage*>(layer)->get_blend_mode(): 0, f);
|
||||
fputw(layer->is_image() ? static_cast<LayerImage*>(layer)->getBlendMode(): 0, f);
|
||||
|
||||
/* padding */
|
||||
ase_file_write_padding(f, 4);
|
||||
|
@ -14,12 +14,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
***********************************************************************
|
||||
*
|
||||
* Various blender's algorithms were "stolen" from The GIMP with
|
||||
* Copyright (C) 1995 of Spencer Kimball and Peter Mattis
|
||||
* See the file "gimp/app/paint-funcs/paint-funcs-generic.h".
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@ -27,50 +21,15 @@
|
||||
#include "raster/blend.h"
|
||||
#include "raster/image.h"
|
||||
|
||||
#define T_VAR register int t;
|
||||
#define NT_VAR
|
||||
|
||||
BLEND_COLOR _rgba_blenders[] =
|
||||
{
|
||||
_rgba_blend_normal,
|
||||
_rgba_blend_normal, /* _rgba_blend_dissolve, */
|
||||
_rgba_blend_multiply,
|
||||
_rgba_blend_screen,
|
||||
_rgba_blend_overlay,
|
||||
_rgba_blend_normal, /* _rgba_blend_hard_light, */
|
||||
_rgba_blend_normal, /* _rgba_blend_dodge, */
|
||||
_rgba_blend_normal, /* _rgba_blend_burn, */
|
||||
_rgba_blend_darken,
|
||||
_rgba_blend_lighten,
|
||||
_rgba_blend_addition,
|
||||
_rgba_blend_subtract,
|
||||
_rgba_blend_difference,
|
||||
_rgba_blend_hue,
|
||||
_rgba_blend_saturation,
|
||||
_rgba_blend_color,
|
||||
_rgba_blend_luminosity,
|
||||
_rgba_blend_copy,
|
||||
};
|
||||
|
||||
BLEND_COLOR _graya_blenders[] =
|
||||
{
|
||||
_graya_blend_normal,
|
||||
_graya_blend_normal, /* _graya_blend_dissolve, */
|
||||
_graya_blend_normal, /* _graya_blend_multiply, */
|
||||
_graya_blend_normal, /* _graya_blend_screen, */
|
||||
_graya_blend_normal, /* _graya_blend_overlay, */
|
||||
_graya_blend_normal, /* _graya_blend_hard_light, */
|
||||
_graya_blend_normal, /* _graya_blend_dodge, */
|
||||
_graya_blend_normal, /* _graya_blend_burn, */
|
||||
_graya_blend_normal, /* _graya_blend_darken, */
|
||||
_graya_blend_normal, /* _graya_blend_lighten, */
|
||||
_graya_blend_normal, /* _graya_blend_addition, */
|
||||
_graya_blend_normal, /* _graya_blend_subtract, */
|
||||
_graya_blend_normal, /* _graya_blend_difference, */
|
||||
_graya_blend_normal, /* _graya_blend_hue, */
|
||||
_graya_blend_normal, /* _graya_blend_saturation, */
|
||||
_graya_blend_normal, /* _graya_blend_color, */
|
||||
_graya_blend_normal, /* _graya_blend_luminosity */
|
||||
_graya_blend_copy,
|
||||
};
|
||||
|
||||
@ -78,222 +37,52 @@ BLEND_COLOR _graya_blenders[] =
|
||||
/* RGB blenders */
|
||||
/**********************************************************************/
|
||||
|
||||
#define BLEND_BEGIN(mode) \
|
||||
int _rgba_blend_##mode (int back, int front, int opacity) \
|
||||
{ \
|
||||
T_VAR \
|
||||
\
|
||||
if ((back & 0xff000000) == 0) { \
|
||||
return \
|
||||
(front & 0xffffff) | \
|
||||
(INT_MULT(_rgba_geta(front), opacity, t) << _rgba_a_shift); \
|
||||
} \
|
||||
else if ((front & 0xff000000) == 0) { \
|
||||
return back; \
|
||||
} \
|
||||
else { \
|
||||
int B_r, B_g, B_b, B_a; \
|
||||
int F_r, F_g, F_b, F_a; \
|
||||
int D_r, D_g, D_b, D_a; \
|
||||
\
|
||||
B_r = _rgba_getr(back); \
|
||||
B_g = _rgba_getg(back); \
|
||||
B_b = _rgba_getb(back); \
|
||||
B_a = _rgba_geta(back); \
|
||||
\
|
||||
F_r = _rgba_getr(front); \
|
||||
F_g = _rgba_getg(front); \
|
||||
F_b = _rgba_getb(front); \
|
||||
F_a = _rgba_geta(front); \
|
||||
int _rgba_blend_normal(int back, int front, int opacity)
|
||||
{
|
||||
register int t;
|
||||
|
||||
if ((back & 0xff000000) == 0) {
|
||||
return
|
||||
(front & 0xffffff) |
|
||||
(INT_MULT(_rgba_geta(front), opacity, t) << _rgba_a_shift);
|
||||
}
|
||||
else if ((front & 0xff000000) == 0) {
|
||||
return back;
|
||||
}
|
||||
else {
|
||||
int B_r, B_g, B_b, B_a;
|
||||
int F_r, F_g, F_b, F_a;
|
||||
int D_r, D_g, D_b, D_a;
|
||||
|
||||
B_r = _rgba_getr(back);
|
||||
B_g = _rgba_getg(back);
|
||||
B_b = _rgba_getb(back);
|
||||
B_a = _rgba_geta(back);
|
||||
|
||||
F_r = _rgba_getr(front);
|
||||
F_g = _rgba_getg(front);
|
||||
F_b = _rgba_getb(front);
|
||||
F_a = _rgba_geta(front);
|
||||
F_a = INT_MULT(F_a, opacity, t);
|
||||
|
||||
#define BLEND_END() \
|
||||
return _rgba(D_r, D_g, D_b, D_a); \
|
||||
} \
|
||||
D_a = B_a + F_a - INT_MULT(B_a, F_a, t);
|
||||
D_r = B_r + (F_r-B_r) * F_a / D_a;
|
||||
D_g = B_g + (F_g-B_g) * F_a / D_a;
|
||||
D_b = B_b + (F_b-B_b) * F_a / D_a;
|
||||
|
||||
return _rgba(D_r, D_g, D_b, D_a);
|
||||
}
|
||||
}
|
||||
|
||||
#define BLEND_OPACITY() \
|
||||
D_r = B_r + (D_r-B_r) * F_a / 255; \
|
||||
D_g = B_g + (D_g-B_g) * F_a / 255; \
|
||||
D_b = B_b + (D_b-B_b) * F_a / 255;
|
||||
|
||||
BLEND_BEGIN(normal)
|
||||
D_a = B_a + F_a - INT_MULT(B_a, F_a, t);
|
||||
D_r = B_r + (F_r-B_r) * F_a / D_a;
|
||||
D_g = B_g + (F_g-B_g) * F_a / D_a;
|
||||
D_b = B_b + (F_b-B_b) * F_a / D_a;
|
||||
BLEND_END()
|
||||
|
||||
BLEND_BEGIN(multiply)
|
||||
D_r = INT_MULT(B_r, F_r, t);
|
||||
D_g = INT_MULT(B_g, F_g, t);
|
||||
D_b = INT_MULT(B_b, F_b, t);
|
||||
D_a = B_a;
|
||||
|
||||
BLEND_OPACITY()
|
||||
BLEND_END()
|
||||
|
||||
BLEND_BEGIN(screen)
|
||||
D_r = 255 - INT_MULT((255 - B_r), (255 - F_r), t);
|
||||
D_g = 255 - INT_MULT((255 - B_g), (255 - F_g), t);
|
||||
D_b = 255 - INT_MULT((255 - B_b), (255 - F_b), t);
|
||||
D_a = B_a;
|
||||
|
||||
BLEND_OPACITY()
|
||||
BLEND_END()
|
||||
|
||||
BLEND_BEGIN(overlay)
|
||||
D_r = INT_MULT(B_r, B_r + INT_MULT (2 * F_r, 255 - B_r, t), t);
|
||||
D_g = INT_MULT(B_g, B_g + INT_MULT (2 * F_g, 255 - B_g, t), t);
|
||||
D_b = INT_MULT(B_b, B_b + INT_MULT (2 * F_b, 255 - B_b, t), t);
|
||||
D_a = B_a;
|
||||
|
||||
BLEND_OPACITY()
|
||||
BLEND_END()
|
||||
|
||||
#if 0
|
||||
BLEND_BEGIN(hard_light)
|
||||
#define HARD_LIGHT(channel) \
|
||||
if (F_##channel > 128) { \
|
||||
t = (255 - B_##channel) * (255 - ((F_##channel - 128) << 1)); \
|
||||
D_##channel = MID (0, 255 - (t >> 8), 255); \
|
||||
} \
|
||||
else { \
|
||||
t = B_##channel * (F_##channel << 1); \
|
||||
D_##channel = MID (0, t >> 8, 255); \
|
||||
}
|
||||
|
||||
HARD_LIGHT(r)
|
||||
HARD_LIGHT(g)
|
||||
HARD_LIGHT(b)
|
||||
D_a = B_a;
|
||||
|
||||
BLEND_OPACITY()
|
||||
BLEND_END()
|
||||
#endif
|
||||
|
||||
BLEND_BEGIN(darken)
|
||||
D_r = MIN(B_r, F_r);
|
||||
D_g = MIN(B_g, F_g);
|
||||
D_b = MIN(B_b, F_b);
|
||||
D_a = B_a;
|
||||
|
||||
BLEND_OPACITY()
|
||||
BLEND_END()
|
||||
|
||||
BLEND_BEGIN(lighten)
|
||||
D_r = MAX(B_r, F_r);
|
||||
D_g = MAX(B_g, F_g);
|
||||
D_b = MAX(B_b, F_b);
|
||||
D_a = B_a;
|
||||
|
||||
BLEND_OPACITY()
|
||||
BLEND_END()
|
||||
|
||||
BLEND_BEGIN(addition)
|
||||
D_r = MIN(B_r + F_r, 255);
|
||||
D_g = MIN(B_g + F_g, 255);
|
||||
D_b = MIN(B_b + F_b, 255);
|
||||
D_a = B_a;
|
||||
|
||||
BLEND_OPACITY()
|
||||
BLEND_END()
|
||||
|
||||
BLEND_BEGIN(subtract)
|
||||
D_r = MAX(B_r - F_r, 0);
|
||||
D_g = MAX(B_g - F_g, 0);
|
||||
D_b = MAX(B_b - F_b, 0);
|
||||
D_a = B_a;
|
||||
|
||||
BLEND_OPACITY()
|
||||
BLEND_END()
|
||||
|
||||
BLEND_BEGIN(difference)
|
||||
{
|
||||
NT_VAR
|
||||
t = B_r - F_r; D_r = (t < 0)? -t: t;
|
||||
t = B_g - F_g; D_g = (t < 0)? -t: t;
|
||||
t = B_b - F_b; D_b = (t < 0)? -t: t;
|
||||
}
|
||||
D_a = B_a;
|
||||
|
||||
BLEND_OPACITY()
|
||||
BLEND_END()
|
||||
|
||||
BLEND_BEGIN(hue)
|
||||
D_r = B_r;
|
||||
D_g = B_g;
|
||||
D_b = B_b;
|
||||
D_a = B_a;
|
||||
|
||||
rgb_to_hsv_int (&D_r, &D_g, &D_b);
|
||||
rgb_to_hsv_int (&F_r, &F_g, &F_b);
|
||||
|
||||
D_r = F_r;
|
||||
|
||||
hsv_to_rgb_int (&D_r, &D_g, &D_b);
|
||||
|
||||
BLEND_OPACITY()
|
||||
BLEND_END()
|
||||
|
||||
BLEND_BEGIN(saturation)
|
||||
D_r = B_r;
|
||||
D_g = B_g;
|
||||
D_b = B_b;
|
||||
D_a = B_a;
|
||||
|
||||
rgb_to_hsv_int (&D_r, &D_g, &D_b);
|
||||
rgb_to_hsv_int (&F_r, &F_g, &F_b);
|
||||
|
||||
D_g = F_g;
|
||||
|
||||
hsv_to_rgb_int (&D_r, &D_g, &D_b);
|
||||
|
||||
BLEND_OPACITY()
|
||||
BLEND_END()
|
||||
|
||||
BLEND_BEGIN(color)
|
||||
D_r = B_r;
|
||||
D_g = B_g;
|
||||
D_b = B_b;
|
||||
D_a = B_a;
|
||||
|
||||
rgb_to_hsv_int (&D_r, &D_g, &D_b);
|
||||
rgb_to_hsv_int (&F_r, &F_g, &F_b);
|
||||
|
||||
D_r = F_r;
|
||||
D_g = F_g;
|
||||
|
||||
hsv_to_rgb_int (&D_r, &D_g, &D_b);
|
||||
|
||||
BLEND_OPACITY()
|
||||
BLEND_END()
|
||||
|
||||
BLEND_BEGIN(luminosity)
|
||||
D_r = B_r;
|
||||
D_g = B_g;
|
||||
D_b = B_b;
|
||||
D_a = B_a;
|
||||
|
||||
rgb_to_hsv_int (&D_r, &D_g, &D_b);
|
||||
rgb_to_hsv_int (&F_r, &F_g, &F_b);
|
||||
|
||||
D_b = F_b;
|
||||
|
||||
hsv_to_rgb_int (&D_r, &D_g, &D_b);
|
||||
|
||||
BLEND_OPACITY()
|
||||
BLEND_END()
|
||||
|
||||
int _rgba_blend_copy(int back, int front, int opacity)
|
||||
{
|
||||
return front;
|
||||
}
|
||||
|
||||
int _rgba_blend_FORPATH(int back, int front, int opacity)
|
||||
int _rgba_blend_forpath(int back, int front, int opacity)
|
||||
{
|
||||
int F_r, F_g, F_b, F_a;
|
||||
T_VAR
|
||||
register int t;
|
||||
|
||||
F_r = _rgba_getr(front);
|
||||
F_g = _rgba_getg(front);
|
||||
@ -304,7 +93,7 @@ int _rgba_blend_FORPATH(int back, int front, int opacity)
|
||||
return _rgba(F_r, F_g, F_b, F_a);
|
||||
}
|
||||
|
||||
int _rgba_blend_MERGE(int back, int front, int opacity)
|
||||
int _rgba_blend_merge(int back, int front, int opacity)
|
||||
{
|
||||
int B_r, B_g, B_b, B_a;
|
||||
int F_r, F_g, F_b, F_a;
|
||||
@ -340,65 +129,50 @@ int _rgba_blend_MERGE(int back, int front, int opacity)
|
||||
return _rgba(D_r, D_g, D_b, D_a);
|
||||
}
|
||||
|
||||
#undef BLEND_BEGIN
|
||||
#undef BLEND_END
|
||||
#undef BLEND_OPACITY
|
||||
|
||||
/**********************************************************************/
|
||||
/* Grayscale blenders */
|
||||
/**********************************************************************/
|
||||
|
||||
#define BLEND_BEGIN(mode) \
|
||||
int _graya_blend_##mode (int back, int front, int opacity) \
|
||||
{ \
|
||||
T_VAR \
|
||||
\
|
||||
if ((back & 0xff00) == 0) { \
|
||||
return \
|
||||
(front & 0xff) | \
|
||||
(INT_MULT(_graya_geta (front), opacity, t) << _graya_a_shift); \
|
||||
} \
|
||||
else if ((front & 0xff00) == 0) { \
|
||||
return back; \
|
||||
} \
|
||||
else { \
|
||||
int B_g, B_a; \
|
||||
int F_g, F_a; \
|
||||
int D_g, D_a; \
|
||||
\
|
||||
B_g = _graya_getv(back); \
|
||||
B_a = _graya_geta(back); \
|
||||
\
|
||||
F_g = _graya_getv(front); \
|
||||
F_a = _graya_geta(front); \
|
||||
int _graya_blend_normal(int back, int front, int opacity)
|
||||
{
|
||||
register int t;
|
||||
|
||||
if ((back & 0xff00) == 0) {
|
||||
return
|
||||
(front & 0xff) |
|
||||
(INT_MULT(_graya_geta (front), opacity, t) << _graya_a_shift);
|
||||
}
|
||||
else if ((front & 0xff00) == 0) {
|
||||
return back;
|
||||
}
|
||||
else {
|
||||
int B_g, B_a;
|
||||
int F_g, F_a;
|
||||
int D_g, D_a;
|
||||
|
||||
B_g = _graya_getv(back);
|
||||
B_a = _graya_geta(back);
|
||||
|
||||
F_g = _graya_getv(front);
|
||||
F_a = _graya_geta(front);
|
||||
F_a = INT_MULT(F_a, opacity, t);
|
||||
|
||||
#define BLEND_END() \
|
||||
return _graya(D_g, D_a); \
|
||||
} \
|
||||
D_a = B_a + F_a - INT_MULT(B_a, F_a, t);
|
||||
D_g = B_g + (F_g-B_g) * F_a / D_a;
|
||||
|
||||
return _graya(D_g, D_a);
|
||||
}
|
||||
}
|
||||
|
||||
#define BLEND_OPACITY() \
|
||||
D_g = B_g + (D_g-B_g) * F_a / 255;
|
||||
|
||||
BLEND_BEGIN(normal)
|
||||
D_a = B_a + F_a - INT_MULT(B_a, F_a, t);
|
||||
D_g = B_g + (F_g-B_g) * F_a / D_a;
|
||||
BLEND_END()
|
||||
|
||||
int _graya_blend_copy(int back, int front, int opacity)
|
||||
{
|
||||
return front;
|
||||
}
|
||||
|
||||
/* BLEND_BEGIN(FORPATH) */
|
||||
/* D_a = B_a + F_a - INT_MULT(B_a, F_a, t); */
|
||||
/* D_g = B_g + (F_g-B_g) * F_a / D_a; */
|
||||
/* BLEND_END() */
|
||||
int _graya_blend_FORPATH(int back, int front, int opacity)
|
||||
int _graya_blend_forpath(int back, int front, int opacity)
|
||||
{
|
||||
int F_k, F_a;
|
||||
T_VAR
|
||||
register int t;
|
||||
|
||||
F_k = _graya_getv(front);
|
||||
F_a = _graya_geta(front);
|
||||
@ -407,7 +181,7 @@ int _graya_blend_FORPATH(int back, int front, int opacity)
|
||||
return _graya(F_k, F_a);
|
||||
}
|
||||
|
||||
int _graya_blend_MERGE(int back, int front, int opacity)
|
||||
int _graya_blend_merge(int back, int front, int opacity)
|
||||
{
|
||||
int B_k, B_a;
|
||||
int F_k, F_a;
|
||||
|
@ -24,22 +24,6 @@
|
||||
|
||||
enum {
|
||||
BLEND_MODE_NORMAL,
|
||||
BLEND_MODE_DISSOLVE,
|
||||
BLEND_MODE_MULTIPLY,
|
||||
BLEND_MODE_SCREEN,
|
||||
BLEND_MODE_OVERLAY,
|
||||
BLEND_MODE_HARD_LIGHT,
|
||||
BLEND_MODE_DODGE,
|
||||
BLEND_MODE_BURN,
|
||||
BLEND_MODE_DARKEN,
|
||||
BLEND_MODE_LIGHTEN,
|
||||
BLEND_MODE_ADDITION,
|
||||
BLEND_MODE_SUBTRACT,
|
||||
BLEND_MODE_DIFFERENCE,
|
||||
BLEND_MODE_HUE,
|
||||
BLEND_MODE_SATURATION,
|
||||
BLEND_MODE_COLOR,
|
||||
BLEND_MODE_LUMINOSITY,
|
||||
BLEND_MODE_COPY,
|
||||
BLEND_MODE_MAX,
|
||||
};
|
||||
@ -50,30 +34,14 @@ extern BLEND_COLOR _rgba_blenders[];
|
||||
extern BLEND_COLOR _graya_blenders[];
|
||||
|
||||
int _rgba_blend_normal(int back, int front, int opacity);
|
||||
int _rgba_blend_dissolve(int back, int front, int opacity);
|
||||
int _rgba_blend_multiply(int back, int front, int opacity);
|
||||
int _rgba_blend_screen(int back, int front, int opacity);
|
||||
int _rgba_blend_overlay(int back, int front, int opacity);
|
||||
int _rgba_blend_hard_light(int back, int front, int opacity);
|
||||
int _rgba_blend_dodge(int back, int front, int opacity);
|
||||
int _rgba_blend_burn(int back, int front, int opacity);
|
||||
int _rgba_blend_darken(int back, int front, int opacity);
|
||||
int _rgba_blend_lighten(int back, int front, int opacity);
|
||||
int _rgba_blend_addition(int back, int front, int opacity);
|
||||
int _rgba_blend_subtract(int back, int front, int opacity);
|
||||
int _rgba_blend_difference(int back, int front, int opacity);
|
||||
int _rgba_blend_hue(int back, int front, int opacity);
|
||||
int _rgba_blend_saturation(int back, int front, int opacity);
|
||||
int _rgba_blend_color(int back, int front, int opacity);
|
||||
int _rgba_blend_luminosity(int back, int front, int opacity);
|
||||
int _rgba_blend_copy(int back, int front, int opacity);
|
||||
int _rgba_blend_FORPATH(int back, int front, int opacity);
|
||||
int _rgba_blend_MERGE(int back, int front, int opacity);
|
||||
int _rgba_blend_forpath(int back, int front, int opacity);
|
||||
int _rgba_blend_merge(int back, int front, int opacity);
|
||||
|
||||
int _graya_blend_normal(int back, int front, int opacity);
|
||||
int _graya_blend_copy(int back, int front, int opacity);
|
||||
int _graya_blend_FORPATH(int back, int front, int opacity);
|
||||
int _graya_blend_MERGE(int back, int front, int opacity);
|
||||
int _graya_blend_forpath(int back, int front, int opacity);
|
||||
int _graya_blend_merge(int back, int front, int opacity);
|
||||
|
||||
void rgb_to_hsv_int(int *red, int *green, int *blue);
|
||||
void hsv_to_rgb_int(int *hue, int *saturation, int *value);
|
||||
|
@ -112,14 +112,11 @@ Layer* Layer::get_next() const
|
||||
LayerImage::LayerImage(Sprite* sprite)
|
||||
: Layer(GFXOBJ_LAYER_IMAGE, sprite)
|
||||
{
|
||||
m_blend_mode = BLEND_MODE_NORMAL;
|
||||
}
|
||||
|
||||
LayerImage::LayerImage(const LayerImage* src_layer, Sprite* dst_sprite)
|
||||
: Layer(src_layer, dst_sprite)
|
||||
{
|
||||
set_blend_mode(src_layer->get_blend_mode());
|
||||
|
||||
try {
|
||||
// copy cels
|
||||
CelConstIterator it = src_layer->getCelBegin();
|
||||
@ -190,11 +187,6 @@ void LayerImage::destroy_all_cels()
|
||||
m_cels.clear();
|
||||
}
|
||||
|
||||
void LayerImage::set_blend_mode(int blend_mode)
|
||||
{
|
||||
m_blend_mode = blend_mode;
|
||||
}
|
||||
|
||||
void LayerImage::getCels(CelList& cels)
|
||||
{
|
||||
CelIterator it = getCelBegin();
|
||||
@ -458,7 +450,7 @@ void layer_render(const Layer* layer, Image* image, int x, int y, int frame)
|
||||
cel->x + x,
|
||||
cel->y + y,
|
||||
MID (0, cel->opacity, 255),
|
||||
static_cast<const LayerImage*>(layer)->get_blend_mode());
|
||||
static_cast<const LayerImage*>(layer)->getBlendMode());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <string>
|
||||
#include "raster/gfxobj.h"
|
||||
#include "raster/blend.h"
|
||||
|
||||
class Cel;
|
||||
class Image;
|
||||
@ -95,8 +96,7 @@ public:
|
||||
|
||||
int getMemSize() const;
|
||||
|
||||
int get_blend_mode() const { return m_blend_mode; }
|
||||
void set_blend_mode(int blend_mode);
|
||||
int getBlendMode() const { return BLEND_MODE_NORMAL; }
|
||||
|
||||
void addCel(Cel *cel);
|
||||
void removeCel(Cel *cel);
|
||||
@ -118,7 +118,6 @@ public:
|
||||
private:
|
||||
void destroy_all_cels();
|
||||
|
||||
int m_blend_mode; // It indicates how this layer is merged in the final render.
|
||||
CelList m_cels; // List of all cels inside this layer used by frames.
|
||||
};
|
||||
|
||||
|
@ -1026,7 +1026,6 @@ Sprite* Sprite::createWithLayer(int imgtype, int width, int height, int ncolors)
|
||||
|
||||
/* configure the first transparent layer */
|
||||
layer->setName("Layer 1");
|
||||
layer->set_blend_mode(BLEND_MODE_NORMAL);
|
||||
|
||||
/* add image in the layer stock */
|
||||
int index = sprite->getStock()->addImage(image);
|
||||
|
@ -2224,17 +2224,13 @@ static Layer* read_raw_layer(ase_uint8* raw_data)
|
||||
switch (layer_type) {
|
||||
|
||||
case GFXOBJ_LAYER_IMAGE: {
|
||||
int c, blend_mode, cels;
|
||||
int c, cels;
|
||||
|
||||
read_raw_uint8(blend_mode); /* blend mode */
|
||||
read_raw_uint16(cels); /* cels */
|
||||
|
||||
/* create layer */
|
||||
layer = new LayerImage(sprite);
|
||||
|
||||
/* set blend mode */
|
||||
static_cast<LayerImage*>(layer)->set_blend_mode(blend_mode);
|
||||
|
||||
/* read cels */
|
||||
for (c=0; c<cels; c++) {
|
||||
Cel* cel;
|
||||
@ -2311,9 +2307,6 @@ static ase_uint8* write_raw_layer(ase_uint8* raw_data, Layer* layer)
|
||||
switch (layer->getType()) {
|
||||
|
||||
case GFXOBJ_LAYER_IMAGE: {
|
||||
// blend mode
|
||||
write_raw_uint8(static_cast<LayerImage*>(layer)->get_blend_mode());
|
||||
|
||||
// cels
|
||||
write_raw_uint16(static_cast<LayerImage*>(layer)->getCelsCount());
|
||||
|
||||
|
@ -392,7 +392,7 @@ static void ink_hline32_jumble(int x1, int y, int x2, IToolLoop* loop)
|
||||
(RgbTraits,
|
||||
{
|
||||
JUMBLE_XY_IN_UV();
|
||||
*dst_address = _rgba_blend_MERGE(*src_address, color, opacity);
|
||||
*dst_address = _rgba_blend_merge(*src_address, color, opacity);
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -408,7 +408,7 @@ static void ink_hline16_jumble(int x1, int y, int x2, IToolLoop* loop)
|
||||
(GrayscaleTraits,
|
||||
{
|
||||
JUMBLE_XY_IN_UV();
|
||||
*dst_address = _graya_blend_MERGE(*src_address, color, opacity);
|
||||
*dst_address = _graya_blend_merge(*src_address, color, opacity);
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -429,7 +429,7 @@ static void ink_hline8_jumble(int x1, int y, int x2, IToolLoop* loop)
|
||||
JUMBLE_XY_IN_UV();
|
||||
|
||||
tc = color != 0 ? pal->getEntry(color): 0;
|
||||
c = _rgba_blend_MERGE(*src_address != 0 ? pal->getEntry(*src_address): 0,
|
||||
c = _rgba_blend_merge(*src_address != 0 ? pal->getEntry(*src_address): 0,
|
||||
tc, opacity);
|
||||
|
||||
if (_rgba_geta(c) >= 128)
|
||||
|
@ -304,9 +304,6 @@ Layer* Undoable::newLayer()
|
||||
// new layer
|
||||
LayerImage* layer = new LayerImage(m_sprite);
|
||||
|
||||
// configure layer name and blend mode
|
||||
layer->set_blend_mode(BLEND_MODE_NORMAL);
|
||||
|
||||
// add the layer in the sprite set
|
||||
if (isEnabled())
|
||||
m_sprite->getUndo()->undo_add_layer(m_sprite->getFolder(), layer);
|
||||
@ -438,7 +435,7 @@ void Undoable::backgroundFromLayer(LayerImage* layer, int bgcolor)
|
||||
cel->x,
|
||||
cel->y,
|
||||
MID(0, cel->opacity, 255),
|
||||
layer->get_blend_mode());
|
||||
layer->getBlendMode());
|
||||
|
||||
// now we have to copy the new image (bg_image) to the cel...
|
||||
setCelPosition(cel, 0, 0);
|
||||
|
@ -594,7 +594,7 @@ void RenderEngine::renderLayer(const Sprite *sprite,
|
||||
(cel->x << zoom) - source_x,
|
||||
(cel->y << zoom) - source_y,
|
||||
output_opacity,
|
||||
static_cast<const LayerImage*>(layer)->get_blend_mode(), zoom);
|
||||
static_cast<const LayerImage*>(layer)->getBlendMode(), zoom);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user