Skip to content

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

C

Fix dummy ink pixel (Tone =255) ink texture crash

Abel You2bf1681b0f76
diff --git a/toonz/sources/common/trop/tropcm.cpp b/toonz/sources/common/trop/tropcm.cpp
index 9348ff840..0dc8fdce0 100644
--- a/toonz/sources/common/trop/tropcm.cpp
+++ b/toonz/sources/common/trop/tropcm.cpp
@@ -367,7 +367,8 @@ TRasterP putSingleInkInRasterGR8(TRasterCM32P &rasIn, int inkId) {
if (rasOut) pixOut = rasOut->pixels(y);
while (pixIn < endPix) {
- if (pixIn->getInk() == inkId) {
+ if (pixIn->getTone() != TPixelCM32::getMaxTone() &&
+ pixIn->getInk() == inkId) {
assert(TPixelCM32::getMaxTone() == 0xff);
if (!rasOut) {
rasOut = TRasterGR8P(rasIn->getLx(), rasIn->getLy());
@@ -399,7 +400,8 @@ TRasterP putSingleInkInRasterRGBM(TRasterCM32P &rasIn, int inkId) {
if (rasOut) pixOut = rasOut->pixels(y);
while (pixIn < endPix) {
- if (pixIn->getInk() == inkId) {
+ if (pixIn->getTone() != TPixelCM32::getMaxTone() &&
+ pixIn->getInk() == inkId) {
assert(TPixelCM32::getMaxTone() == 0xff);
if (!rasOut) {
rasOut = TRaster32P(rasIn->getLx(), rasIn->getLy());
diff --git a/toonz/sources/toonzlib/imagestyles.cpp b/toonz/sources/toonzlib/imagestyles.cpp
index 61f576655..ff4f0e4e9 100644
--- a/toonz/sources/toonzlib/imagestyles.cpp
+++ b/toonz/sources/toonzlib/imagestyles.cpp
@@ -967,7 +967,9 @@ bool TTextureStyle::doCompute(const Params &params) const {
if (m_params.m_type == TTextureParams::AUTOMATIC) {
TRect bBox;
TRop::computeBBox(r, bBox);
-
+
+ // Just in case of empty raster
+ if (bBox.isEmpty()) bBox = TRect(0,0,1,1);
r = r->extract(bBox);
p += r->getCenter() - computeCentroid(r);
}