mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 04:19:12 +00:00
Fix bug losing original image colors from custom brushes (fix #3375)
This commit is contained in:
parent
51132a8e84
commit
44bb1c4e48
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -437,9 +437,9 @@ void AppBrushes::save(const std::string& filename) const
|
||||
}
|
||||
|
||||
if (slot.brush()->type() == kImageBrushType &&
|
||||
slot.brush()->image()) {
|
||||
slot.brush()->originalImage()) {
|
||||
TiXmlElement elem("image");
|
||||
save_xml_image(&elem, slot.brush()->image());
|
||||
save_xml_image(&elem, slot.brush()->originalImage());
|
||||
brushElem.InsertEndChild(elem);
|
||||
|
||||
if (slot.brush()->maskBitmap()) {
|
||||
|
@ -454,7 +454,9 @@ os::SurfaceRef BrushPopup::createSurfaceForBrush(const BrushRef& origBrush)
|
||||
brush.reset(new Brush(*brush));
|
||||
brush->setSize(10);
|
||||
}
|
||||
image = brush->image();
|
||||
// Show the original image in the popup (without the image colors
|
||||
// modified if there were some modification).
|
||||
image = brush->originalImage();
|
||||
}
|
||||
|
||||
os::SurfaceRef surface = os::instance()->makeRgbaSurface(
|
||||
|
@ -2026,6 +2026,11 @@ void ContextBar::setActiveBrushBySlot(tools::Tool* tool, int slot)
|
||||
|
||||
if (brush.brush()) {
|
||||
if (brush.brush()->type() == doc::kImageBrushType) {
|
||||
// Reset the colors of the image when we select the brush from
|
||||
// the slot.
|
||||
if (brush.hasFlag(BrushSlot::Flags::ImageColor))
|
||||
brush.brush()->resetImageColors();
|
||||
|
||||
setActiveBrush(brush.brush());
|
||||
}
|
||||
else {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (C) 2019-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -281,6 +281,12 @@ void Brush::setImageColor(ImageColor imageColor, color_t color)
|
||||
}
|
||||
}
|
||||
|
||||
void Brush::resetImageColors()
|
||||
{
|
||||
if (m_backupImage)
|
||||
m_image.reset(Image::createCopy(m_backupImage.get()));
|
||||
}
|
||||
|
||||
void Brush::setCenter(const gfx::Point& center)
|
||||
{
|
||||
m_center = center;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -52,7 +52,12 @@ namespace doc {
|
||||
void setAngle(int angle);
|
||||
void setImage(const Image* image,
|
||||
const Image* maskBitmap);
|
||||
|
||||
// Special functions to change the colors of the image or restore
|
||||
// the colors to the original image used to create the brush.
|
||||
void setImageColor(ImageColor imageColor, color_t color);
|
||||
void resetImageColors();
|
||||
|
||||
void setPattern(BrushPattern pattern) {
|
||||
m_pattern = pattern;
|
||||
}
|
||||
@ -64,6 +69,15 @@ namespace doc {
|
||||
}
|
||||
void setCenter(const gfx::Point& center);
|
||||
|
||||
// Returns the original image used to create the brush before
|
||||
// calling any setImageColor()
|
||||
Image* originalImage() const {
|
||||
if (m_backupImage)
|
||||
return m_backupImage.get();
|
||||
else
|
||||
return m_image.get();
|
||||
}
|
||||
|
||||
private:
|
||||
void clean();
|
||||
void regenerate();
|
||||
|
Loading…
x
Reference in New Issue
Block a user