Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

fix crash due to gap refer pixel ink painted in stroke fill process

Abel Youf904430a3d9b
diff --git a/toonz/sources/common/trop/quickput.cpp b/toonz/sources/common/trop/quickput.cpp
index 589de725e..ae465c07f 100644
--- a/toonz/sources/common/trop/quickput.cpp
+++ b/toonz/sources/common/trop/quickput.cpp
@@ -4208,12 +4208,12 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up,
(yI <= up->getLy() - 1));
TPixelCM32 *upPix = upBasePix + (yI * upWrap + xI);
int t = upPix->getTone();
- int p = upPix->getPaint();
+ int p = upPix->getPaint() < paints.size() ? upPix->getPaint() : -1;
if (t == 0xff && p == 0)
continue;
else {
- int i = upPix->getInk();
+ int i = upPix->getInk() < inks.size() ? upPix->getInk() : -1;
TPixel32 colorUp;
if (s.m_inksOnly) switch (t) {
case 0:
@@ -4457,8 +4457,8 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up,
int count = std::max({palette->getStyleCount(), TPixelCM32::getMaxInk(),
TPixelCM32::getMaxPaint()});
- std::vector<TPixel32> paints(count+1, TPixel32::Red);
- std::vector<TPixel32> inks(count+1, TPixel32::Red);
+ std::vector<TPixel32> paints(count + 1, TPixel32::Red);
+ std::vector<TPixel32> inks(count + 1, TPixel32::Red);
if (globalColorScale != TPixel::Black)
for (int i = 0; i < palette->getStyleCount(); i++)
paints[i] = inks[i] = applyColorScaleCMapped(
@@ -4467,7 +4467,7 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up,
for (int i = 0; i < palette->getStyleCount(); i++)
paints[i] = inks[i] =
::premultiply(palette->getStyle(i)->getAverageColor());
-
+
dn->lock();
up->lock();
TPixelCM32 *upBasePix = up->pixels();
diff --git a/toonz/sources/toonzlib/fillutil.cpp b/toonz/sources/toonzlib/fillutil.cpp
index efaeff541..6b9a5bfd3 100644
--- a/toonz/sources/toonzlib/fillutil.cpp
+++ b/toonz/sources/toonzlib/fillutil.cpp
@@ -79,7 +79,9 @@ void fillOutsideOfStroke(const TRasterCM32P &r, TStroke *stroke, int color) {
params.m_prevailing = false;
for (int i = 0; i < length; i++) {
TPoint p = convert(stroke->getPointAtLength(i));
- if (p == oldP || !bbox.contains(p)) continue;
+ if (p == oldP || !bbox.contains(p) ||
+ r->pixels(p.y)[p.x].getPaint() == color)
+ continue;
params.m_p = p;
fill(r, params);
oldP = p;
@@ -190,8 +192,8 @@ bool AreaFiller::rectFill(const TRect &rect, int color, bool onlyUnfilled,
m_ras->lock();
TRect r = m_bounds * rect;
- int dx = r.x1 - r.x0;
- int dy = (r.y1 - r.y0) * m_wrap;
+ int dx = r.x1 - r.x0;
+ int dy = (r.y1 - r.y0) * m_wrap;
if (dx < 2 || dy < 2) // rect degenere(area contenuta nulla), skippo.
return false;
// Se il rettangolo non contiene il bordo del raster e se tutti i pixels
@@ -366,6 +368,8 @@ void AreaFiller::strokeFill(const TRect &rect, TStroke *stroke, int color,
// std::vector<std::pair<TPoint, int>> seeds;
// computeSeeds(m_ras, stroke, seeds);
fillOutsideOfStroke(ras, stroke, TPixelCM32::getMaxPaint() - 1);
+ // Some pixels might be painted to in fillRow(),
+ // with PAINT Bounds off and refer/gap on
TVectorImage app;
app.addStroke(stroke);
@@ -397,6 +401,8 @@ const void AreaFiller::processPixel(
/*--- Process refer/auto-paint Lines ---*/
else {
// paint refer lines
+ if (!invert && pix.getInk() == TPixelCM32::getMaxInk() - 1) // !!!!
+ pix.setInk(TPixelCM32::getMaxInk());
if (pix.getInk() == TPixelCM32::getMaxInk() && !DEF_REGION_WITH_PAINT)
pix.setInk(color);
// paint auto-paint lines
@@ -422,7 +428,7 @@ const void AreaFiller::processPixel(
}
/*--- Restore Area should not be filled */
else
- pix.setPaint(bak.getPaint());
+ pix.setPaint(bak.getPaint()), pix.setInk(bak.getInk());
}
//=============================================================================