mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-27 06:35:16 +00:00
Revert select_layer_boundaries behavior
select_layer_boundaries was affected by a change made to Mask::fromImage where a hardcoded threshold was changed from 128 to 0. To make select_layer_boundaries behave as before, I've added a new parameter to Mask::fromImage to set the threshold and then use the same hardcoded value it was using (128)
This commit is contained in:
parent
55042f89ce
commit
75da9c6c51
@ -37,7 +37,7 @@ void select_layer_boundaries(Layer* layer,
|
||||
const Cel* cel = layer->cel(frame);
|
||||
if (cel) {
|
||||
const Image* image = cel->image();
|
||||
newMask.fromImage(image, cel->bounds().origin());
|
||||
newMask.fromImage(image, cel->bounds().origin(), 128); // TODO configurable alpha threshold
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -128,7 +128,7 @@ void Mask::copyFrom(const Mask* sourceMask)
|
||||
}
|
||||
}
|
||||
|
||||
void Mask::fromImage(const Image* image, const gfx::Point& maskOrigin)
|
||||
void Mask::fromImage(const Image* image, const gfx::Point& maskOrigin, uint8_t alphaThreshold)
|
||||
{
|
||||
if (image) {
|
||||
replace(image->bounds().setOrigin(maskOrigin));
|
||||
@ -149,7 +149,7 @@ void Mask::fromImage(const Image* image, const gfx::Point& maskOrigin)
|
||||
for (; maskIt != maskEnd; ++maskIt, ++rgbIt) {
|
||||
ASSERT(rgbIt != rgbEnd);
|
||||
color_t c = *rgbIt;
|
||||
*maskIt = (rgba_geta(c) > 0);
|
||||
*maskIt = (rgba_geta(c) > alphaThreshold);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -163,7 +163,7 @@ void Mask::fromImage(const Image* image, const gfx::Point& maskOrigin)
|
||||
for (; maskIt != maskEnd; ++maskIt, ++grayIt) {
|
||||
ASSERT(grayIt != grayEnd);
|
||||
color_t c = *grayIt;
|
||||
*maskIt = (graya_geta(c) > 0);
|
||||
*maskIt = (graya_geta(c) > alphaThreshold);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ namespace doc {
|
||||
|
||||
// Copies the data from the given mask.
|
||||
void copyFrom(const Mask* sourceMask);
|
||||
void fromImage(const Image* image, const gfx::Point& maskOrigin);
|
||||
void fromImage(const Image* image, const gfx::Point& maskOrigin, uint8_t alphaThreshold = 0);
|
||||
|
||||
// Replace the whole mask with the given region.
|
||||
void replace(const gfx::Rect& bounds);
|
||||
|
Loading…
x
Reference in New Issue
Block a user