mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-19 15:40:31 +00:00
Add "Put Alpha" ink (to draw with the exact opacity value as Alpha)
This commit is contained in:
parent
9259dd49d1
commit
2919bbc972
@ -26,6 +26,7 @@
|
||||
enum InkType {
|
||||
kDefaultInk,
|
||||
kOpaqueInk,
|
||||
kPutAlphaInk,
|
||||
kMergeInk,
|
||||
kShadingInk,
|
||||
kReplaceInk,
|
||||
|
@ -116,6 +116,45 @@ static void ink_hline8_opaque(int x1, int y, int x2, ToolLoop* loop)
|
||||
/* memset(((uint8_t**)data->dst_image->line)[y]+x1, data->color, x2-x1+1); */
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Putalpha Ink
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void ink_hline32_putalpha(int x1, int y, int x2, ToolLoop* loop)
|
||||
{
|
||||
int c = loop->getPrimaryColor();
|
||||
int opacity = loop->getOpacity();
|
||||
|
||||
DEFINE_INK_PROCESSING_DST
|
||||
(RgbTraits,
|
||||
*dst_address = _rgba(_rgba_getr(c),
|
||||
_rgba_getg(c),
|
||||
_rgba_getb(c),
|
||||
opacity)
|
||||
);
|
||||
}
|
||||
|
||||
static void ink_hline16_putalpha(int x1, int y, int x2, ToolLoop* loop)
|
||||
{
|
||||
int c = loop->getPrimaryColor();
|
||||
int opacity = loop->getOpacity();
|
||||
|
||||
DEFINE_INK_PROCESSING_DST
|
||||
(GrayscaleTraits,
|
||||
*dst_address = _graya(_graya_getv(c),
|
||||
opacity)
|
||||
);
|
||||
}
|
||||
|
||||
static void ink_hline8_putalpha(int x1, int y, int x2, ToolLoop* loop)
|
||||
{
|
||||
int c = loop->getPrimaryColor();
|
||||
|
||||
DEFINE_INK_PROCESSING_DST
|
||||
(IndexedTraits,
|
||||
*dst_address = c );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Transparent Ink
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -484,6 +523,7 @@ static void ink_hline8_shading(int x1, int y, int x2, ToolLoop* loop)
|
||||
|
||||
enum {
|
||||
INK_OPAQUE,
|
||||
INK_PUTALPHA,
|
||||
INK_TRANSPARENT,
|
||||
INK_BLUR,
|
||||
INK_REPLACE,
|
||||
@ -500,6 +540,7 @@ static AlgoHLine ink_processing[][3] =
|
||||
(AlgoHLine)ink_hline8_##name }
|
||||
|
||||
DEF_INK(opaque),
|
||||
DEF_INK(putalpha),
|
||||
DEF_INK(transparent),
|
||||
DEF_INK(blur),
|
||||
DEF_INK(replace),
|
||||
|
@ -32,7 +32,7 @@
|
||||
class PaintInk : public Ink
|
||||
{
|
||||
public:
|
||||
enum Type { Normal, WithFg, WithBg };
|
||||
enum Type { Merge, WithFg, WithBg, Opaque, PutAlpha };
|
||||
|
||||
private:
|
||||
AlgoHLine m_proc;
|
||||
@ -47,7 +47,7 @@ public:
|
||||
{
|
||||
switch (m_type) {
|
||||
|
||||
case Normal:
|
||||
case Merge:
|
||||
// Do nothing, use the default colors
|
||||
break;
|
||||
|
||||
@ -64,9 +64,21 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
m_proc = loop->getOpacity() == 255 ?
|
||||
ink_processing[INK_OPAQUE][MID(0, loop->getSprite()->getPixelFormat(), 2)]:
|
||||
ink_processing[INK_TRANSPARENT][MID(0, loop->getSprite()->getPixelFormat(), 2)];
|
||||
int depth = MID(0, loop->getSprite()->getPixelFormat(), 2);
|
||||
|
||||
switch (m_type) {
|
||||
case Opaque:
|
||||
m_proc = ink_processing[INK_OPAQUE][depth];
|
||||
break;
|
||||
case PutAlpha:
|
||||
m_proc = ink_processing[INK_PUTALPHA][depth];
|
||||
break;
|
||||
default:
|
||||
m_proc = (loop->getOpacity() == 255 ?
|
||||
ink_processing[INK_OPAQUE][depth]:
|
||||
ink_processing[INK_TRANSPARENT][depth]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void inkHline(int x1, int y, int x2, ToolLoop* loop)
|
||||
|
@ -51,6 +51,8 @@ const char* WellKnownInks::Selection = "selection";
|
||||
const char* WellKnownInks::Paint = "paint";
|
||||
const char* WellKnownInks::PaintFg = "paint_fg";
|
||||
const char* WellKnownInks::PaintBg = "paint_bg";
|
||||
const char* WellKnownInks::PaintOpaque = "paint_opaque";
|
||||
const char* WellKnownInks::PaintPutAlpha = "paint_put_alpha";
|
||||
const char* WellKnownInks::Shading = "shading";
|
||||
const char* WellKnownInks::Eraser = "eraser";
|
||||
const char* WellKnownInks::ReplaceFgWithBg = "replace_fg_with_bg";
|
||||
@ -69,9 +71,11 @@ ToolBox::ToolBox()
|
||||
PRINTF("Toolbox module: installing\n");
|
||||
|
||||
m_inks[WellKnownInks::Selection] = new SelectionInk();
|
||||
m_inks[WellKnownInks::Paint] = new PaintInk(PaintInk::Normal);
|
||||
m_inks[WellKnownInks::Paint] = new PaintInk(PaintInk::Merge);
|
||||
m_inks[WellKnownInks::PaintFg] = new PaintInk(PaintInk::WithFg);
|
||||
m_inks[WellKnownInks::PaintBg] = new PaintInk(PaintInk::WithBg);
|
||||
m_inks[WellKnownInks::PaintOpaque] = new PaintInk(PaintInk::Opaque);
|
||||
m_inks[WellKnownInks::PaintPutAlpha] = new PaintInk(PaintInk::PutAlpha);
|
||||
m_inks[WellKnownInks::Shading] = new ShadingInk();
|
||||
m_inks[WellKnownInks::Eraser] = new EraserInk(EraserInk::Eraser);
|
||||
m_inks[WellKnownInks::ReplaceFgWithBg] = new EraserInk(EraserInk::ReplaceFgWithBg);
|
||||
|
@ -38,6 +38,8 @@ namespace WellKnownInks {
|
||||
extern const char* Paint;
|
||||
extern const char* PaintFg;
|
||||
extern const char* PaintBg;
|
||||
extern const char* PaintOpaque;
|
||||
extern const char* PaintPutAlpha;
|
||||
extern const char* Shading;
|
||||
extern const char* Eraser;
|
||||
extern const char* ReplaceFgWithBg;
|
||||
|
@ -248,6 +248,7 @@ public:
|
||||
// The same order as in InkType
|
||||
addItem("Default");
|
||||
addItem("Opaque");
|
||||
addItem("Put Alpha");
|
||||
addItem("Merge");
|
||||
addItem("Shading");
|
||||
addItem("Replace");
|
||||
|
@ -276,7 +276,10 @@ private:
|
||||
const char* id = WellKnownInks::Paint;
|
||||
switch (inkType) {
|
||||
case kOpaqueInk:
|
||||
id = WellKnownInks::Paint;
|
||||
id = WellKnownInks::PaintOpaque;
|
||||
break;
|
||||
case kPutAlphaInk:
|
||||
id = WellKnownInks::PaintPutAlpha;
|
||||
break;
|
||||
case kMergeInk:
|
||||
id = WellKnownInks::Paint;
|
||||
@ -303,6 +306,7 @@ private:
|
||||
id = WellKnownInks::Jumble;
|
||||
break;
|
||||
}
|
||||
|
||||
return App::instance()->getToolBox()->getInkById(id);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user