OpenToonz - An open-source full-featured 2D animation creation software
C
feat: allow user to customize Ink and Paint Check color
andeon981859d063ec
diff --git a/toonz/sources/common/trop/quickput.cpp b/toonz/sources/common/trop/quickput.cppindex ae465c07f..ee56a644a 100644--- a/toonz/sources/common/trop/quickput.cpp+++ b/toonz/sources/common/trop/quickput.cpp@@ -10,6 +10,8 @@#include "tcolorstyles.h"#endif+#include <algorithm> // for std::max, std::min+/*#ifndef __sgi#include <algorithm>@@ -75,60 +77,59 @@ inline TPixel32 applyColorScaleCMapped(const TPixel32 &color,void doQuickPutFilter(const TRaster32P &dn, const TRaster32P &up,const TAffine &aff) {- // se aff e' degenere la controimmagine di up e' un segmento (o un punto)+ // if aff is degenerate, the inverse image of up is a segment (or a point)if ((aff.a11 * aff.a22 - aff.a12 * aff.a21) == 0) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // maschera del filtro bilineare+ // bilinear filter maskconst int MASKN = (1 << PADN) - 1;- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));TRectD boundingBoxD = TRectD(convert(dn->getSize())) *(aff * TRectD(0, 0, up->getLx() - 2, up->getLy() - 2));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- TAffine invAff = inv(aff); // inversa di aff+ TAffine invAff = inv(aff); // inverse of aff- // nel disegnare la y-esima scanline di dn, il passaggio al pixel successivo- // comporta l'incremento (deltaXD, deltaYD) delle coordinate del pixel- // corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, deltaYD) of the corresponding up pixel+ // coordinatesdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- // deltaXD "TLonghizzato" (round)+ // "long-ized" deltaXD (round)int deltaXL = tround(deltaXD * (1 << PADN));- // deltaYD "TLonghizzato" (round)+ // "long-ized" deltaYD (round)int deltaYL = tround(deltaYD * (1 << PADN));- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) && (deltaYL == 0)) return;- // naturale predecessore di up->getLx() - 1+ // natural predecessor of up->getLx() - 1int lxPred = (up->getLx() - 2) * (1 << PADN);- // naturale predecessore di up->getLy() - 1+ // natural predecessor of up->getLy() - 1int lyPred = (up->getLy() - 2) * (1 << PADN);int dnWrap = dn->getWrap();@@ -138,156 +139,152 @@ void doQuickPutFilter(const TRaster32P &dn, const TRaster32P &up,TPixel32 *dnRow = dn->pixels(yMin);TPixel32 *upBasePix = up->pixels();- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int y = yMin; y <= yMax; y++, dnRow += dnWrap) {- // (1) equazione k-parametrica della y-esima- // scanline di boundingBoxD:- // (xMin, y) + k*(1, 0), k = 0, ..., (xMax - xMin)+ // (1) parametric k-equation of the y-th scanline of boundingBoxD:+ // (xMin, y) + k*(1, 0), k = 0, ..., (xMax - xMin)- // (2) equazione k-parametrica dell'immagine mediante- // invAff di (1):- // invAff*(xMin, y) + k*(deltaXD, deltaYD),- // k = kMin, ..., kMax- // con 0 <= kMin <= kMax <= (xMax - xMin)+ // (2) parametric k-equation of the image via invAff of (1):+ // invAff*(xMin, y) + k*(deltaXD, deltaYD),+ // k = kMin, ..., kMax with 0 <= kMin <= kMax <= (xMax - xMin)- // calcola kMin, kMax per la scanline corrente intersecando la (2)- // con i lati di up+ // compute kMin, kMax for the current scanline by intersecting (2)+ // with the sides of up- // il segmento [a, b] di up e' la controimmagine mediante aff- // della porzione di scanline [ (xMin, y), (xMax, y) ] di dn+ // the segment [a, b] of up is the inverse image via aff of the portion+ // of scanline [ (xMin, y), (xMax, y) ] of dn- // TPointD b = invAff*TPointD(xMax, y);+ // TPointD b = invAff*TPointD(xMax, y);TPointD a = invAff * TPointD(xMin, y);- // (xL0, yL0) sono le coordinate di a in versione "TLonghizzata"- // 0 <= xL0 + k*deltaXL- // <= (up->getLx() - 2)*(1<<PADN), 0- // <= kMinX- // <= kMin- // <= k- // <= kMax- // <= kMaxX- // <= (xMax - xMin)- //- // 0 <= yL0 + k*deltaYL- // <= (up->getLy() - 2)*(1<<PADN), 0- // <= kMinY- // <= kMin- // <= k- // <= kMax- // <= kMaxY- // <= (yMax - yMin)- int xL0 = tround(a.x * (1 << PADN)); // xL0 inizializzato- int yL0 = tround(a.y * (1 << PADN)); // yL0 inizializzato-- // calcola kMinX, kMaxX, kMinY, kMaxY- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = yMax - yMin; // clipping su dn-- // 0 <= xL0 + k*deltaXL <= (up->getLx() - 2)*(1<<PADN)- // <=>- // 0 <= xL0 + k*deltaXL <= lxPred+ // (xL0, yL0) are the coordinates of a in "long-ized" version+ // 0 <= xL0 + k*deltaXL+ // <= (up->getLx() - 2)*(1<<PADN),+ // 0 <= kMinX+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxX+ // <= (xMax - xMin)//+ // 0 <= yL0 + k*deltaYL+ // <= (up->getLy() - 2)*(1<<PADN),+ // 0 <= kMinY+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxY+ // <= (xMax - xMin)++ int xL0 = tround(a.x * (1 << PADN)); // initialize xL0+ int yL0 = tround(a.y * (1 << PADN)); // initialize yL0++ // compute kMinX, kMaxX, kMinY, kMaxY+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dn++ // 0 <= xL0 + k*deltaXL <= (up->getLx() - 2)*(1<<PADN)+ // <=>+ // 0 <= xL0 + k*deltaXL <= lxPred//- // 0 <= yL0 + k*deltaYL <= (up->getLy() - 2)*(1<<PADN)- // <=>- // 0 <= yL0 + k*deltaYL <= lyPred+ // 0 <= yL0 + k*deltaYL <= (up->getLy() - 2)*(1<<PADN)+ // <=>+ // 0 <= yL0 + k*deltaYL <= lyPred- // calcola kMinX, kMaxX+ // compute kMinX, kMaxXif (deltaXL == 0) {- // [a, b] verticale esterno ad up contratto+ // [a, b] vertical outside contracted upif ((xL0 < 0) || (lxPred < xL0)) continue;- // altrimenti usa solo- // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))+ // otherwise only use+ // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))} else if (deltaXL > 0) {- if (lxPred < xL0) // [a, b] esterno ad up+(bordo destro)+ if (lxPred < xL0) // [a, b] outside up+(right edge)continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- if (xL0 < 0) // [a, b] esterno ad up contratto+ if (xL0 < 0) // [a, b] outside contracted upcontinue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinY, kMaxY+ // compute kMinY, kMaxYif (deltaYL == 0) {- // [a, b] orizzontale esterno ad up contratto+ // [a, b] horizontal outside contracted upif ((yL0 < 0) || (lyPred < yL0)) continue;- // altrimenti usa solo- // kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))+ // otherwise only use+ // kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))} else if (deltaYL > 0) {- if (lyPred < yL0) // [a, b] esterno ad up contratto+ if (lyPred < yL0) // [a, b] outside contracted upcontinue;- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- if (yL0 < 0) // [a, b] esterno ad up contratto+ if (yL0 < 0) // [a, b] outside contracted upcontinue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMin, kMax effettuando anche il clipping su dn+ // compute kMin, kMax also performing clipping on dnint kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});TPixel32 *dnPix = dnRow + xMin + kMin;TPixel32 *dnEndPix = dnRow + xMin + kMax + 1;- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata"- // del pixel corrente di up- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yL- // scorre i pixel sulla y-esima scanline di boundingBoxD+ // iterate over pixels on the y-th scanline of boundingBoxDfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN))- // e' approssimato con (xI, yI)- int xI = xL >> PADN; // troncato- int yI = yL >> PADN; // troncato+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN))+ // is approximated with (xI, yI)+ int xI = xL >> PADN; // truncated+ int yI = yL >> PADN; // truncatedassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));- // (xI, yI)+ // (xI, yI)TPixel32 *upPix00 = upBasePix + (yI * upWrap + xI);- // (xI + 1, yI)+ // (xI + 1, yI)TPixel32 *upPix10 = upPix00 + 1;- // (xI, yI + 1)+ // (xI, yI + 1)TPixel32 *upPix01 = upPix00 + upWrap;- // (xI + 1, yI + 1)+ // (xI + 1, yI + 1)TPixel32 *upPix11 = upPix00 + upWrap + 1;- // filtro bilineare 4 pixels: calcolo dei pesi+ // bilinear filter 4 pixels: weight calculationint xWeight1 = (xL & MASKN);int xWeight0 = (1 << PADN) - xWeight1;int yWeight1 = (yL & MASKN);int yWeight0 = (1 << PADN) - yWeight1;- // filtro bilineare 4 pixels: media pesata sui singoli canali+ // bilinear filter 4 pixels: weighted average on each channelint rColDownTmp =(xWeight0 * (upPix00->r) + xWeight1 * ((upPix10)->r)) >> PADN;@@ -340,15 +337,15 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRaster32P &up,const TAffine &aff, const TPixel32 &colorScale,bool doPremultiply, bool whiteTransp, bool firstColumn,bool doRasterDarkenBlendedView) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((aff.a11 * aff.a22 - aff.a12 * aff.a21) == 0) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));@@ -356,45 +353,44 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRaster32P &up,TRectD(convert(dn->getBounds())) *(aff * TRectD(-0.5, -0.5, up->getLx() - 0.5, up->getLy() - 0.5));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- // inversa di aff+ // inverse of affTAffine invAff = inv(aff);- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, deltaYD) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, deltaYD) of the corresponding up pixel+ // coordinatesdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- // deltaXD "TLonghizzato" (round)+ // "long-ized" deltaXD (round)int deltaXL = tround(deltaXD * (1 << PADN));- // deltaYD "TLonghizzato" (round)+ // "long-ized" deltaYD (round)int deltaYL = tround(deltaYD * (1 << PADN));- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) && (deltaYL == 0)) return;- // TINT32 predecessore di up->getLx()+ // predecessor of up->getLx()int lxPred = up->getLx() * (1 << PADN) - 1;- // TINT32 predecessore di up->getLy()+ // predecessor of up->getLy()int lyPred = up->getLy() * (1 << PADN) - 1;int dnWrap = dn->getWrap();@@ -405,139 +401,139 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRaster32P &up,TPixel32 *dnRow = dn->pixels(yMin);TPixel32 *upBasePix = up->pixels();- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int y = yMin; y <= yMax; y++, dnRow += dnWrap) {- // (1) equazione k-parametrica della y-esima scanline di boundingBoxD:+ // (1) parametric k-equation of the y-th scanline of boundingBoxD:// (xMin, y) + k*(1, 0), k = 0, ..., (xMax - xMin)- // (2) equazione k-parametrica dell'immagine mediante invAff di (1):+ // (2) parametric k-equation of the image via invAff of (1):// invAff*(xMin, y) + k*(deltaXD, deltaYD),- // k = kMin, ..., kMax con 0 <= kMin <= kMax <= (xMax - xMin)+ // k = kMin, ..., kMax with 0 <= kMin <= kMax <= (xMax - xMin)- // calcola kMin, kMax per la scanline corrente- // intersecando la (2) con i lati di up+ // compute kMin, kMax for the current scanline by intersecting (2)+ // with the sides of up- // il segmento [a, b] di up e' la controimmagine mediante aff della- // porzione di scanline [ (xMin, y), (xMax, y) ] di dn+ // the segment [a, b] of up is the inverse image via aff of the portion+ // of scanline [ (xMin, y), (xMax, y) ] of dn- // TPointD b = invAff*TPointD(xMax, y);+ // TPointD b = invAff*TPointD(xMax, y);TPointD a = invAff * TPointD(xMin, y);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)//- // 0 <= kMinX- // <= kMin- // <= k- // <= kMax- // <= kMaxX- // <= (xMax - xMin)+ // 0 <= kMinX+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxX+ // <= (xMax - xMin)//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)- // 0 <= kMinY- // <= kMin- // <= k- // <= kMax- // <= kMaxY- // <= (xMax - xMin)+ // 0 <= kMinY+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxY+ // <= (xMax - xMin)- // xL0 inizializzato per il round+ // xL0 initialized for roundingint xL0 = tround((a.x + 0.5) * (1 << PADN));- // yL0 inizializzato per il round+ // yL0 initialized for roundingint yL0 = tround((a.y + 0.5) * (1 << PADN));- // calcola kMinX, kMaxX, kMinY, kMaxY- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn+ // compute kMinX, kMaxX, kMinY, kMaxY+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dn- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)- // <=>- // 0 <= xL0 + k*deltaXL- // <= lxPred+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)+ // <=>+ // 0 <= xL0 + k*deltaXL+ // <= lxPred//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)- // <=>- // 0 <= yL0 + k*deltaYL- // <= lyPred+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)+ // <=>+ // 0 <= yL0 + k*deltaYL+ // <= lyPred- // calcola kMinX, kMaxX+ // compute kMinX, kMaxXif (deltaXL == 0) {- // [a, b] verticale esterno ad up+(bordo destro/basso)+ // [a, b] vertical outside up+(right/bottom edge)if ((xL0 < 0) || (lxPred < xL0)) continue;- // altrimenti usa solo- // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))+ // otherwise only use+ // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))} else if (deltaXL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinY, kMaxY+ // compute kMinY, kMaxYif (deltaYL == 0) {- // [a, b] orizzontale esterno ad up+(bordo destro/basso)+ // [a, b] horizontal outside up+(right/bottom edge)if ((yL0 < 0) || (lyPred < yL0)) continue;- // altrimenti usa solo+ // otherwise only use// kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))} else if (deltaYL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMin, kMax effettuando anche il clippind su dn+ // compute kMin, kMax also performing clipping on dnint kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});TPixel32 *dnPix = dnRow + xMin + kMin;TPixel32 *dnEndPix = dnRow + xMin + kMax + 1;- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata" del pixel corrente di up- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yL- // scorre i pixel sulla y-esima scanline di boundingBoxD+ // iterate over pixels on the y-th scanline of boundingBoxDfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // round- int yI = yL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN))+ // is approximated with (xI, yI)+ int xI = xL >> PADN; // round+ int yI = yL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -573,15 +569,15 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRaster32P &up,void doQuickPutNoFilter(const TRaster32P &dn, const TRaster64P &up,const TAffine &aff, bool doPremultiply,bool firstColumn) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((aff.a11 * aff.a22 - aff.a12 * aff.a21) == 0) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));@@ -589,45 +585,44 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRaster64P &up,TRectD(convert(dn->getBounds())) *(aff * TRectD(-0.5, -0.5, up->getLx() - 0.5, up->getLy() - 0.5));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- // inversa di aff+ // inverse of affTAffine invAff = inv(aff);- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, deltaYD) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, deltaYD) of the corresponding up pixel+ // coordinatesdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- // deltaXD "TLonghizzato" (round)+ // "long-ized" deltaXD (round)int deltaXL = tround(deltaXD * (1 << PADN));- // deltaYD "TLonghizzato" (round)+ // "long-ized" deltaYD (round)int deltaYL = tround(deltaYD * (1 << PADN));- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) && (deltaYL == 0)) return;- // TINT32 predecessore di up->getLx()+ // predecessor of up->getLx()int lxPred = up->getLx() * (1 << PADN) - 1;- // TINT32 predecessore di up->getLy()+ // predecessor of up->getLy()int lyPred = up->getLy() * (1 << PADN) - 1;int dnWrap = dn->getWrap();@@ -638,139 +633,139 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRaster64P &up,TPixel32 *dnRow = dn->pixels(yMin);TPixel64 *upBasePix = up->pixels();- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int y = yMin; y <= yMax; y++, dnRow += dnWrap) {- // (1) equazione k-parametrica della y-esima scanline di boundingBoxD:+ // (1) parametric k-equation of the y-th scanline of boundingBoxD:// (xMin, y) + k*(1, 0), k = 0, ..., (xMax - xMin)- // (2) equazione k-parametrica dell'immagine mediante invAff di (1):+ // (2) parametric k-equation of the image via invAff of (1):// invAff*(xMin, y) + k*(deltaXD, deltaYD),- // k = kMin, ..., kMax con 0 <= kMin <= kMax <= (xMax - xMin)+ // k = kMin, ..., kMax with 0 <= kMin <= kMax <= (xMax - xMin)- // calcola kMin, kMax per la scanline corrente- // intersecando la (2) con i lati di up+ // compute kMin, kMax for the current scanline by intersecting (2)+ // with the sides of up- // il segmento [a, b] di up e' la controimmagine mediante aff della- // porzione di scanline [ (xMin, y), (xMax, y) ] di dn+ // the segment [a, b] of up is the inverse image via aff of the portion+ // of scanline [ (xMin, y), (xMax, y) ] of dn- // TPointD b = invAff*TPointD(xMax, y);+ // TPointD b = invAff*TPointD(xMax, y);TPointD a = invAff * TPointD(xMin, y);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)//- // 0 <= kMinX- // <= kMin- // <= k- // <= kMax- // <= kMaxX- // <= (xMax - xMin)+ // 0 <= kMinX+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxX+ // <= (xMax - xMin)//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)- // 0 <= kMinY- // <= kMin- // <= k- // <= kMax- // <= kMaxY- // <= (xMax - xMin)+ // 0 <= kMinY+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxY+ // <= (xMax - xMin)- // xL0 inizializzato per il round+ // xL0 initialized for roundingint xL0 = tround((a.x + 0.5) * (1 << PADN));- // yL0 inizializzato per il round+ // yL0 initialized for roundingint yL0 = tround((a.y + 0.5) * (1 << PADN));- // calcola kMinX, kMaxX, kMinY, kMaxY- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn+ // compute kMinX, kMaxX, kMinY, kMaxY+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dn- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)- // <=>- // 0 <= xL0 + k*deltaXL- // <= lxPred+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)+ // <=>+ // 0 <= xL0 + k*deltaXL+ // <= lxPred//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)- // <=>- // 0 <= yL0 + k*deltaYL- // <= lyPred+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)+ // <=>+ // 0 <= yL0 + k*deltaYL+ // <= lyPred- // calcola kMinX, kMaxX+ // compute kMinX, kMaxXif (deltaXL == 0) {- // [a, b] verticale esterno ad up+(bordo destro/basso)+ // [a, b] vertical outside up+(right/bottom edge)if ((xL0 < 0) || (lxPred < xL0)) continue;- // altrimenti usa solo- // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))+ // otherwise only use+ // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))} else if (deltaXL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinY, kMaxY+ // compute kMinY, kMaxYif (deltaYL == 0) {- // [a, b] orizzontale esterno ad up+(bordo destro/basso)+ // [a, b] horizontal outside up+(right/bottom edge)if ((yL0 < 0) || (lyPred < yL0)) continue;- // altrimenti usa solo+ // otherwise only use// kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))} else if (deltaYL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMin, kMax effettuando anche il clippind su dn+ // compute kMin, kMax also performing clipping on dnint kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});TPixel32 *dnPix = dnRow + xMin + kMin;TPixel32 *dnEndPix = dnRow + xMin + kMax + 1;- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata" del pixel corrente di up- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yL- // scorre i pixel sulla y-esima scanline di boundingBoxD+ // iterate over pixels on the y-th scanline of boundingBoxDfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // round- int yI = yL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN))+ // is approximated with (xI, yI)+ int xI = xL >> PADN; // round+ int yI = yL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -810,11 +805,8 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRasterGR8P &up,return;int yMin = std::max(tfloor(boundingBoxD.y0), 0);-int yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);-int xMin = std::max(tfloor(boundingBoxD.x0), 0);-int xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);TAffine invAff = inv(aff);@@ -823,13 +815,11 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRasterGR8P &up,double deltaYD = invAff.a21;int deltaXL = tround(deltaXD * (1 << PADN));-int deltaYL = tround(deltaYD * (1 << PADN));if ((deltaXL == 0) && (deltaYL == 0)) return;int lxPred = up->getLx() * (1 << PADN) - 1;-int lyPred = up->getLy() * (1 << PADN) - 1;int dnWrap = dn->getWrap();@@ -844,78 +834,77 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRasterGR8P &up,TPointD a = invAff * TPointD(xMin, y);int xL0 = tround((a.x + 0.5) * (1 << PADN));-int yL0 = tround((a.y + 0.5) * (1 << PADN));- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dnif (deltaXL == 0) {if ((xL0 < 0) || (lxPred < xL0)) continue;} else if (deltaXL > 0) {if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinY, kMaxY+ // compute kMinY, kMaxYif (deltaYL == 0) {- // [a, b] orizzontale esterno ad up+(bordo destro/basso)+ // [a, b] horizontal outside up+(right/bottom edge)if ((yL0 < 0) || (lyPred < yL0)) continue;- // altrimenti usa solo+ // otherwise only use// kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))} else if (deltaYL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMin, kMax effettuando anche il clippind su dn+ // compute kMin, kMax also performing clipping on dnint kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});TPixel32 *dnPix = dnRow + xMin + kMin;TPixel32 *dnEndPix = dnRow + xMin + kMax + 1;- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata" del pixel corrente di up- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yL- // scorre i pixel sulla y-esima scanline di boundingBoxD+ // iterate over pixels on the y-th scanline of boundingBoxDfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // round- int yI = yL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN))+ // is approximated with (xI, yI)+ int xI = xL >> PADN; // round+ int yI = yL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -949,15 +938,15 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRasterGR8P &up,void doQuickPutNoFilter(const TRaster64P &dn, const TRaster64P &up,const TAffine &aff, bool doPremultiply,bool firstColumn) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((aff.a11 * aff.a22 - aff.a12 * aff.a21) == 0) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));@@ -965,45 +954,44 @@ void doQuickPutNoFilter(const TRaster64P &dn, const TRaster64P &up,TRectD(convert(dn->getBounds())) *(aff * TRectD(-0.5, -0.5, up->getLx() - 0.5, up->getLy() - 0.5));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- // inversa di aff+ // inverse of affTAffine invAff = inv(aff);- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, deltaYD) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, deltaYD) of the corresponding up pixel+ // coordinatesdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- // deltaXD "TLonghizzato" (round)+ // "long-ized" deltaXD (round)int deltaXL = tround(deltaXD * (1 << PADN));- // deltaYD "TLonghizzato" (round)+ // "long-ized" deltaYD (round)int deltaYL = tround(deltaYD * (1 << PADN));- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) && (deltaYL == 0)) return;- // TINT32 predecessore di up->getLx()+ // predecessor of up->getLx()int lxPred = up->getLx() * (1 << PADN) - 1;- // TINT32 predecessore di up->getLy()+ // predecessor of up->getLy()int lyPred = up->getLy() * (1 << PADN) - 1;int dnWrap = dn->getWrap();@@ -1014,139 +1002,139 @@ void doQuickPutNoFilter(const TRaster64P &dn, const TRaster64P &up,TPixel64 *dnRow = dn->pixels(yMin);TPixel64 *upBasePix = up->pixels();- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int y = yMin; y <= yMax; y++, dnRow += dnWrap) {- // (1) equazione k-parametrica della y-esima scanline di boundingBoxD:+ // (1) parametric k-equation of the y-th scanline of boundingBoxD:// (xMin, y) + k*(1, 0), k = 0, ..., (xMax - xMin)- // (2) equazione k-parametrica dell'immagine mediante invAff di (1):+ // (2) parametric k-equation of the image via invAff of (1):// invAff*(xMin, y) + k*(deltaXD, deltaYD),- // k = kMin, ..., kMax con 0 <= kMin <= kMax <= (xMax - xMin)+ // k = kMin, ..., kMax with 0 <= kMin <= kMax <= (xMax - xMin)- // calcola kMin, kMax per la scanline corrente- // intersecando la (2) con i lati di up+ // compute kMin, kMax for the current scanline by intersecting (2)+ // with the sides of up- // il segmento [a, b] di up e' la controimmagine mediante aff della- // porzione di scanline [ (xMin, y), (xMax, y) ] di dn+ // the segment [a, b] of up is the inverse image via aff of the portion+ // of scanline [ (xMin, y), (xMax, y) ] of dn- // TPointD b = invAff*TPointD(xMax, y);+ // TPointD b = invAff*TPointD(xMax, y);TPointD a = invAff * TPointD(xMin, y);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)//- // 0 <= kMinX- // <= kMin- // <= k- // <= kMax- // <= kMaxX- // <= (xMax - xMin)+ // 0 <= kMinX+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxX+ // <= (xMax - xMin)//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)- // 0 <= kMinY- // <= kMin- // <= k- // <= kMax- // <= kMaxY- // <= (xMax - xMin)+ // 0 <= kMinY+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxY+ // <= (xMax - xMin)- // xL0 inizializzato per il round+ // xL0 initialized for roundingint xL0 = tround((a.x + 0.5) * (1 << PADN));- // yL0 inizializzato per il round+ // yL0 initialized for roundingint yL0 = tround((a.y + 0.5) * (1 << PADN));- // calcola kMinX, kMaxX, kMinY, kMaxY- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn+ // compute kMinX, kMaxX, kMinY, kMaxY+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dn- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)- // <=>- // 0 <= xL0 + k*deltaXL- // <= lxPred+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)+ // <=>+ // 0 <= xL0 + k*deltaXL+ // <= lxPred//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)- // <=>- // 0 <= yL0 + k*deltaYL- // <= lyPred+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)+ // <=>+ // 0 <= yL0 + k*deltaYL+ // <= lyPred- // calcola kMinX, kMaxX+ // compute kMinX, kMaxXif (deltaXL == 0) {- // [a, b] verticale esterno ad up+(bordo destro/basso)+ // [a, b] vertical outside up+(right/bottom edge)if ((xL0 < 0) || (lxPred < xL0)) continue;- // altrimenti usa solo- // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))+ // otherwise only use+ // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))} else if (deltaXL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinY, kMaxY+ // compute kMinY, kMaxYif (deltaYL == 0) {- // [a, b] orizzontale esterno ad up+(bordo destro/basso)+ // [a, b] horizontal outside up+(right/bottom edge)if ((yL0 < 0) || (lyPred < yL0)) continue;- // altrimenti usa solo+ // otherwise only use// kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))} else if (deltaYL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMin, kMax effettuando anche il clippind su dn+ // compute kMin, kMax also performing clipping on dnint kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});TPixel64 *dnPix = dnRow + xMin + kMin;TPixel64 *dnEndPix = dnRow + xMin + kMax + 1;- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata" del pixel corrente di up- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yL- // scorre i pixel sulla y-esima scanline di boundingBoxD+ // iterate over pixels on the y-th scanline of boundingBoxDfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // round- int yI = yL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN))+ // is approximated with (xI, yI)+ int xI = xL >> PADN; // round+ int yI = yL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -1173,15 +1161,15 @@ void doQuickPutNoFilter(const TRaster64P &dn, const TRaster64P &up,void doQuickPutNoFilter(const TRaster64P &dn, const TRasterFP &up,const TAffine &aff, bool doPremultiply,bool firstColumn) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((aff.a11 * aff.a22 - aff.a12 * aff.a21) == 0) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));@@ -1189,45 +1177,44 @@ void doQuickPutNoFilter(const TRaster64P &dn, const TRasterFP &up,TRectD(convert(dn->getBounds())) *(aff * TRectD(-0.5, -0.5, up->getLx() - 0.5, up->getLy() - 0.5));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- // inversa di aff+ // inverse of affTAffine invAff = inv(aff);- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, deltaYD) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, deltaYD) of the corresponding up pixel+ // coordinatesdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- // deltaXD "TLonghizzato" (round)+ // "long-ized" deltaXD (round)int deltaXL = tround(deltaXD * (1 << PADN));- // deltaYD "TLonghizzato" (round)+ // "long-ized" deltaYD (round)int deltaYL = tround(deltaYD * (1 << PADN));- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) && (deltaYL == 0)) return;- // TINT32 predecessore di up->getLx()+ // predecessor of up->getLx()int lxPred = up->getLx() * (1 << PADN) - 1;- // TINT32 predecessore di up->getLy()+ // predecessor of up->getLy()int lyPred = up->getLy() * (1 << PADN) - 1;int dnWrap = dn->getWrap();@@ -1238,139 +1225,139 @@ void doQuickPutNoFilter(const TRaster64P &dn, const TRasterFP &up,TPixel64 *dnRow = dn->pixels(yMin);TPixelF *upBasePix = up->pixels();- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int y = yMin; y <= yMax; y++, dnRow += dnWrap) {- // (1) equazione k-parametrica della y-esima scanline di boundingBoxD:+ // (1) parametric k-equation of the y-th scanline of boundingBoxD:// (xMin, y) + k*(1, 0), k = 0, ..., (xMax - xMin)- // (2) equazione k-parametrica dell'immagine mediante invAff di (1):+ // (2) parametric k-equation of the image via invAff of (1):// invAff*(xMin, y) + k*(deltaXD, deltaYD),- // k = kMin, ..., kMax con 0 <= kMin <= kMax <= (xMax - xMin)+ // k = kMin, ..., kMax with 0 <= kMin <= kMax <= (xMax - xMin)- // calcola kMin, kMax per la scanline corrente- // intersecando la (2) con i lati di up+ // compute kMin, kMax for the current scanline by intersecting (2)+ // with the sides of up- // il segmento [a, b] di up e' la controimmagine mediante aff della- // porzione di scanline [ (xMin, y), (xMax, y) ] di dn+ // the segment [a, b] of up is the inverse image via aff of the portion+ // of scanline [ (xMin, y), (xMax, y) ] of dn- // TPointD b = invAff*TPointD(xMax, y);+ // TPointD b = invAff*TPointD(xMax, y);TPointD a = invAff * TPointD(xMin, y);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)//- // 0 <= kMinX- // <= kMin- // <= k- // <= kMax- // <= kMaxX- // <= (xMax - xMin)+ // 0 <= kMinX+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxX+ // <= (xMax - xMin)//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)- // 0 <= kMinY- // <= kMin- // <= k- // <= kMax- // <= kMaxY- // <= (xMax - xMin)+ // 0 <= kMinY+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxY+ // <= (xMax - xMin)- // xL0 inizializzato per il round+ // xL0 initialized for roundingint xL0 = tround((a.x + 0.5) * (1 << PADN));- // yL0 inizializzato per il round+ // yL0 initialized for roundingint yL0 = tround((a.y + 0.5) * (1 << PADN));- // calcola kMinX, kMaxX, kMinY, kMaxY- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn+ // compute kMinX, kMaxX, kMinY, kMaxY+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dn- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)- // <=>- // 0 <= xL0 + k*deltaXL- // <= lxPred+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)+ // <=>+ // 0 <= xL0 + k*deltaXL+ // <= lxPred//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)- // <=>- // 0 <= yL0 + k*deltaYL- // <= lyPred+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)+ // <=>+ // 0 <= yL0 + k*deltaYL+ // <= lyPred- // calcola kMinX, kMaxX+ // compute kMinX, kMaxXif (deltaXL == 0) {- // [a, b] verticale esterno ad up+(bordo destro/basso)+ // [a, b] vertical outside up+(right/bottom edge)if ((xL0 < 0) || (lxPred < xL0)) continue;- // altrimenti usa solo- // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))+ // otherwise only use+ // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))} else if (deltaXL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinY, kMaxY+ // compute kMinY, kMaxYif (deltaYL == 0) {- // [a, b] orizzontale esterno ad up+(bordo destro/basso)+ // [a, b] horizontal outside up+(right/bottom edge)if ((yL0 < 0) || (lyPred < yL0)) continue;- // altrimenti usa solo+ // otherwise only use// kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))} else if (deltaYL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMin, kMax effettuando anche il clippind su dn+ // compute kMin, kMax also performing clipping on dnint kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});TPixel64 *dnPix = dnRow + xMin + kMin;TPixel64 *dnEndPix = dnRow + xMin + kMax + 1;- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata" del pixel corrente di up- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yL- // scorre i pixel sulla y-esima scanline di boundingBoxD+ // iterate over pixels on the y-th scanline of boundingBoxDfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // round- int yI = yL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN))+ // is approximated with (xI, yI)+ int xI = xL >> PADN; // round+ int yI = yL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -1398,15 +1385,15 @@ void doQuickPutNoFilter(const TRaster64P &dn, const TRasterFP &up,void doQuickPutNoFilter(const TRasterFP &dn, const TRasterFP &up,const TAffine &aff, bool doPremultiply,bool firstColumn) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((aff.a11 * aff.a22 - aff.a12 * aff.a21) == 0) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));@@ -1414,45 +1401,44 @@ void doQuickPutNoFilter(const TRasterFP &dn, const TRasterFP &up,TRectD(convert(dn->getBounds())) *(aff * TRectD(-0.5, -0.5, up->getLx() - 0.5, up->getLy() - 0.5));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- // inversa di aff+ // inverse of affTAffine invAff = inv(aff);- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, deltaYD) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, deltaYD) of the corresponding up pixel+ // coordinatesdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- // deltaXD "TLonghizzato" (round)+ // "long-ized" deltaXD (round)int deltaXL = tround(deltaXD * (1 << PADN));- // deltaYD "TLonghizzato" (round)+ // "long-ized" deltaYD (round)int deltaYL = tround(deltaYD * (1 << PADN));- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) && (deltaYL == 0)) return;- // TINT32 predecessore di up->getLx()+ // predecessor of up->getLx()int lxPred = up->getLx() * (1 << PADN) - 1;- // TINT32 predecessore di up->getLy()+ // predecessor of up->getLy()int lyPred = up->getLy() * (1 << PADN) - 1;int dnWrap = dn->getWrap();@@ -1463,139 +1449,139 @@ void doQuickPutNoFilter(const TRasterFP &dn, const TRasterFP &up,TPixelF *dnRow = dn->pixels(yMin);TPixelF *upBasePix = up->pixels();- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int y = yMin; y <= yMax; y++, dnRow += dnWrap) {- // (1) equazione k-parametrica della y-esima scanline di boundingBoxD:+ // (1) parametric k-equation of the y-th scanline of boundingBoxD:// (xMin, y) + k*(1, 0), k = 0, ..., (xMax - xMin)- // (2) equazione k-parametrica dell'immagine mediante invAff di (1):+ // (2) parametric k-equation of the image via invAff of (1):// invAff*(xMin, y) + k*(deltaXD, deltaYD),- // k = kMin, ..., kMax con 0 <= kMin <= kMax <= (xMax - xMin)+ // k = kMin, ..., kMax with 0 <= kMin <= kMax <= (xMax - xMin)- // calcola kMin, kMax per la scanline corrente- // intersecando la (2) con i lati di up+ // compute kMin, kMax for the current scanline by intersecting (2)+ // with the sides of up- // il segmento [a, b] di up e' la controimmagine mediante aff della- // porzione di scanline [ (xMin, y), (xMax, y) ] di dn+ // the segment [a, b] of up is the inverse image via aff of the portion+ // of scanline [ (xMin, y), (xMax, y) ] of dn- // TPointD b = invAff*TPointD(xMax, y);+ // TPointD b = invAff*TPointD(xMax, y);TPointD a = invAff * TPointD(xMin, y);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)//- // 0 <= kMinX- // <= kMin- // <= k- // <= kMax- // <= kMaxX- // <= (xMax - xMin)+ // 0 <= kMinX+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxX+ // <= (xMax - xMin)//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)- // 0 <= kMinY- // <= kMin- // <= k- // <= kMax- // <= kMaxY- // <= (xMax - xMin)+ // 0 <= kMinY+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxY+ // <= (xMax - xMin)- // xL0 inizializzato per il round+ // xL0 initialized for roundingint xL0 = tround((a.x + 0.5) * (1 << PADN));- // yL0 inizializzato per il round+ // yL0 initialized for roundingint yL0 = tround((a.y + 0.5) * (1 << PADN));- // calcola kMinX, kMaxX, kMinY, kMaxY- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn+ // compute kMinX, kMaxX, kMinY, kMaxY+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dn- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)- // <=>- // 0 <= xL0 + k*deltaXL- // <= lxPred+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)+ // <=>+ // 0 <= xL0 + k*deltaXL+ // <= lxPred//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)- // <=>- // 0 <= yL0 + k*deltaYL- // <= lyPred+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)+ // <=>+ // 0 <= yL0 + k*deltaYL+ // <= lyPred- // calcola kMinX, kMaxX+ // compute kMinX, kMaxXif (deltaXL == 0) {- // [a, b] verticale esterno ad up+(bordo destro/basso)+ // [a, b] vertical outside up+(right/bottom edge)if ((xL0 < 0) || (lxPred < xL0)) continue;- // altrimenti usa solo- // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))+ // otherwise only use+ // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))} else if (deltaXL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinY, kMaxY+ // compute kMinY, kMaxYif (deltaYL == 0) {- // [a, b] orizzontale esterno ad up+(bordo destro/basso)+ // [a, b] horizontal outside up+(right/bottom edge)if ((yL0 < 0) || (lyPred < yL0)) continue;- // altrimenti usa solo+ // otherwise only use// kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))} else if (deltaYL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMin, kMax effettuando anche il clippind su dn+ // compute kMin, kMax also performing clipping on dnint kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});TPixelF *dnPix = dnRow + xMin + kMin;TPixelF *dnEndPix = dnRow + xMin + kMax + 1;- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata" del pixel corrente di up- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yL- // scorre i pixel sulla y-esima scanline di boundingBoxD+ // iterate over pixels on the y-th scanline of boundingBoxDfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // round- int yI = yL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN))+ // is approximated with (xI, yI)+ int xI = xL >> PADN; // round+ int yI = yL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -1622,15 +1608,15 @@ void doQuickPutNoFilter(const TRasterFP &dn, const TRasterFP &up,void doQuickPutNoFilter(const TRaster64P &dn, const TRaster32P &up,const TAffine &aff, bool doPremultiply,bool firstColumn) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((aff.a11 * aff.a22 - aff.a12 * aff.a21) == 0) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));@@ -1638,45 +1624,44 @@ void doQuickPutNoFilter(const TRaster64P &dn, const TRaster32P &up,TRectD(convert(dn->getBounds())) *(aff * TRectD(-0.5, -0.5, up->getLx() - 0.5, up->getLy() - 0.5));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- // inversa di aff+ // inverse of affTAffine invAff = inv(aff);- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, deltaYD) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, deltaYD) of the corresponding up pixel+ // coordinatesdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- // deltaXD "TLonghizzato" (round)+ // "long-ized" deltaXD (round)int deltaXL = tround(deltaXD * (1 << PADN));- // deltaYD "TLonghizzato" (round)+ // "long-ized" deltaYD (round)int deltaYL = tround(deltaYD * (1 << PADN));- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) && (deltaYL == 0)) return;- // TINT32 predecessore di up->getLx()+ // predecessor of up->getLx()int lxPred = up->getLx() * (1 << PADN) - 1;- // TINT32 predecessore di up->getLy()+ // predecessor of up->getLy()int lyPred = up->getLy() * (1 << PADN) - 1;int dnWrap = dn->getWrap();@@ -1687,139 +1672,139 @@ void doQuickPutNoFilter(const TRaster64P &dn, const TRaster32P &up,TPixel64 *dnRow = dn->pixels(yMin);TPixel32 *upBasePix = up->pixels();- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int y = yMin; y <= yMax; y++, dnRow += dnWrap) {- // (1) equazione k-parametrica della y-esima scanline di boundingBoxD:+ // (1) parametric k-equation of the y-th scanline of boundingBoxD:// (xMin, y) + k*(1, 0), k = 0, ..., (xMax - xMin)- // (2) equazione k-parametrica dell'immagine mediante invAff di (1):+ // (2) parametric k-equation of the image via invAff of (1):// invAff*(xMin, y) + k*(deltaXD, deltaYD),- // k = kMin, ..., kMax con 0 <= kMin <= kMax <= (xMax - xMin)+ // k = kMin, ..., kMax with 0 <= kMin <= kMax <= (xMax - xMin)- // calcola kMin, kMax per la scanline corrente- // intersecando la (2) con i lati di up+ // compute kMin, kMax for the current scanline by intersecting (2)+ // with the sides of up- // il segmento [a, b] di up e' la controimmagine mediante aff della- // porzione di scanline [ (xMin, y), (xMax, y) ] di dn+ // the segment [a, b] of up is the inverse image via aff of the portion+ // of scanline [ (xMin, y), (xMax, y) ] of dn- // TPointD b = invAff*TPointD(xMax, y);+ // TPointD b = invAff*TPointD(xMax, y);TPointD a = invAff * TPointD(xMin, y);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)//- // 0 <= kMinX- // <= kMin- // <= k- // <= kMax- // <= kMaxX- // <= (xMax - xMin)+ // 0 <= kMinX+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxX+ // <= (xMax - xMin)//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)- // 0 <= kMinY- // <= kMin- // <= k- // <= kMax- // <= kMaxY- // <= (xMax - xMin)+ // 0 <= kMinY+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxY+ // <= (xMax - xMin)- // xL0 inizializzato per il round+ // xL0 initialized for roundingint xL0 = tround((a.x + 0.5) * (1 << PADN));- // yL0 inizializzato per il round+ // yL0 initialized for roundingint yL0 = tround((a.y + 0.5) * (1 << PADN));- // calcola kMinX, kMaxX, kMinY, kMaxY- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn+ // compute kMinX, kMaxX, kMinY, kMaxY+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dn- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)- // <=>- // 0 <= xL0 + k*deltaXL- // <= lxPred+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)+ // <=>+ // 0 <= xL0 + k*deltaXL+ // <= lxPred//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)- // <=>- // 0 <= yL0 + k*deltaYL- // <= lyPred+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)+ // <=>+ // 0 <= yL0 + k*deltaYL+ // <= lyPred- // calcola kMinX, kMaxX+ // compute kMinX, kMaxXif (deltaXL == 0) {- // [a, b] verticale esterno ad up+(bordo destro/basso)+ // [a, b] vertical outside up+(right/bottom edge)if ((xL0 < 0) || (lxPred < xL0)) continue;- // altrimenti usa solo- // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))+ // otherwise only use+ // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))} else if (deltaXL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinY, kMaxY+ // compute kMinY, kMaxYif (deltaYL == 0) {- // [a, b] orizzontale esterno ad up+(bordo destro/basso)+ // [a, b] horizontal outside up+(right/bottom edge)if ((yL0 < 0) || (lyPred < yL0)) continue;- // altrimenti usa solo+ // otherwise only use// kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))} else if (deltaYL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMin, kMax effettuando anche il clippind su dn+ // compute kMin, kMax also performing clipping on dnint kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});TPixel64 *dnPix = dnRow + xMin + kMin;TPixel64 *dnEndPix = dnRow + xMin + kMax + 1;- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata" del pixel corrente di up- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yL- // scorre i pixel sulla y-esima scanline di boundingBoxD+ // iterate over pixels on the y-th scanline of boundingBoxDfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // round- int yI = yL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN))+ // is approximated with (xI, yI)+ int xI = xL >> PADN; // round+ int yI = yL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -1846,171 +1831,161 @@ void doQuickPutNoFilter(const TRaster64P &dn, const TRaster32P &up,void doQuickPutFilter(const TRaster32P &dn, const TRaster32P &up, double sx,double sy, double tx, double ty) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((sx == 0) || (sy == 0)) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // maschera del filtro bilineare+ // bilinear filter maskconst int MASKN = (1 << PADN) - 1;+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)TAffine aff(sx, 0, tx, 0, sy, ty);TRectD boundingBoxD = TRectD(convert(dn->getSize())) *(aff * TRectD(0, 0, up->getLx() - 2, up->getLy() - 2));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- // inversa di aff+ // inverse of affTAffine invAff = inv(aff);- // nello scorrere le scanline di boundingBoxD, il passaggio alla scanline- // successiva comporta l'incremento (0, deltaYD) delle coordinate dei- // pixels corrispondenti di up+ // when iterating over scanlines of boundingBoxD, moving to the next scanline+ // implies incrementing (0, deltaYD) of the coordinates of the corresponding+ // up pixels- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, 0) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, 0) of the coordinates of the corresponding+ // up pixeldouble deltaXD = invAff.a11;double deltaYD = invAff.a22;- // deltaXD "TLonghizzato" (round)+ // "long-ized" deltaXD (round)int deltaXL = tround(deltaXD * (1 << PADN));- // deltaYD "TLonghizzato" (round)+ // "long-ized" deltaYD (round)int deltaYL = tround(deltaYD * (1 << PADN));- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) || (deltaYL == 0)) return;- // (1) equazione (kX, kY)-parametrica di boundingBoxD:- // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),- // kX = 0, ..., (xMax - xMin),- // kY = 0, ..., (yMax - yMin)+ // (1) parametric (kX, kY)-equation of boundingBoxD:+ // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),+ // kX = 0, ..., (xMax - xMin),+ // kY = 0, ..., (yMax - yMin)- // (2) equazione (kX, kY)-parametrica dell'immagine- // mediante invAff di (1):- // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),- // kX = kMinX, ..., kMaxX- // con 0 <= kMinX <= kMaxX <= (xMax - xMin)+ // (2) parametric (kX, kY)-equation of the image via invAff of (1):+ // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),+ // kX = kMinX, ..., kMaxX+ // with 0 <= kMinX <= kMaxX <= (xMax - xMin)//- // kY = kMinY, ..., kMaxY- // con 0 <= kMinY <= kMaxY <= (yMax - yMin)+ // kY = kMinY, ..., kMaxY+ // with 0 <= kMinY <= kMaxY <= (yMax - yMin)- // calcola kMinX, kMaxX, kMinY, kMaxY intersecando la (2) con i lati di up+ // compute kMinX, kMaxX, kMinY, kMaxY by intersecting (2) with the sides of up- // il segmento [a, b] di up (con gli estremi eventualmente invertiti) e'- // la controimmagine- // mediante aff della porzione di scanline [ (xMin, yMin), (xMax, yMin) ]- // di dn+ // the segment [a, b] of up (with possibly reversed ends) is the inverse+ // image via aff of the portion of scanline [ (xMin, yMin), (xMax, yMin) ] of+ // dn- // TPointD b = invAff*TPointD(xMax, yMin);+ // TPointD b = invAff*TPointD(xMax, yMin);TPointD a = invAff * TPointD(xMin, yMin);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round) in- // versione "TLonghizzata"- //- // 0 <= xL0 + kX*deltaXL- // <= (up->getLx() - 2)*(1<<PADN),- // 0 <= kMinX <= kX- // <= kMaxX <= (xMax - xMin)- //- // 0 <= yL0 + kY*deltaYL- // <= (up->getLy() - 2)*(1<<PADN),- // 0 <= kMinY <= kY- // <= kMaxY <= (yMax - yMin)- int xL0 = tround(a.x * (1 << PADN)); // xL0 inizializzato- int yL0 = tround(a.y * (1 << PADN)); // yL0 inizializzato-- // calcola kMinY, kMaxY, kMinX, kMaxX intersecando la (2) con i lati- // di up- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = yMax - yMin; // clipping su dn-- // TINT32 predecessore di (up->getLx() - 1)+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + kX*deltaXL <= (up->getLx() - 2)*(1<<PADN),+ // 0 <= kMinX <= kX <= kMaxX <= (xMax - xMin)+ // 0 <= yL0 + kY*deltaYL <= (up->getLy() - 2)*(1<<PADN),+ // 0 <= kMinY <= kY <= kMaxY <= (yMax - yMin)++ int xL0 = tround(a.x * (1 << PADN)); // initialize xL0+ int yL0 = tround(a.y * (1 << PADN)); // initialize yL0++ // compute kMinY, kMaxY, kMinX, kMaxX by intersecting (2) with the sides of up+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = yMax - yMin; // clipping on dn++ // predecessor of (up->getLx() - 1)int lxPred = (up->getLx() - 2) * (1 << PADN);- // TINT32 predecessore di (up->getLy() - 1)+ // predecessor of (up->getLy() - 1)int lyPred = (up->getLy() - 2) * (1 << PADN);- // 0 <= xL0 + k*deltaXL- // <= (up->getLx() - 2)*(1<<PADN)- // <=>- // 0 <= xL0 + k*deltaXL <= lxPred- //- // 0 <= yL0 + k*deltaYL- // <= (up->getLy() - 2)*(1<<PADN)- // <=>- // 0 <= yL0 + k*deltaYL <= lyPred-- // calcola kMinY, kMaxY intersecando la (2) con- // i lati (y = yMin) e (y = yMax) di up- if (deltaYL > 0) // (deltaYL != 0)+ // 0 <= xL0 + k*deltaXL <= (up->getLx() - 2)*(1<<PADN)+ // <=>+ // 0 <= xL0 + k*deltaXL <= lxPred++ // 0 <= yL0 + k*deltaYL <= (up->getLy() - 2)*(1<<PADN)+ // <=>+ // 0 <= yL0 + k*deltaYL <= lyPred++ // compute kMinY, kMaxY by intersecting (2) with the sides+ // (y = yMin) and (y = yMax) of up+ if (deltaYL > 0) // (deltaYL != 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(yL0 <= lyPred);- kMaxY = (lyPred - yL0) / deltaYL; // floor++ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(0 <= yL0);- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMinY, kMaxY effettuando anche il clippind su dn+ // compute kMinY, kMaxY also performing clipping on dnkMinY = std::max(kMinY, (int)0);kMaxY = std::min(kMaxY, yMax - yMin);- // calcola kMinX, kMaxX intersecando la (2) con- // i lati (x = xMin) e (x = xMax) di up- if (deltaXL > 0) // (deltaXL != 0)+ // compute kMinX, kMaxX by intersecting (2) with the sides+ // (x = xMin) and (x = xMax) of up+ if (deltaXL > 0) // (deltaXL != 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(xL0 <= lxPred);- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(0 <= xL0);- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinX, kMaxX effettuando anche il clippind su dn+ // compute kMinX, kMaxX also performing clipping on dnkMinX = std::max(kMinX, (int)0);kMaxX = std::min(kMaxX, xMax - xMin);@@ -2022,55 +1997,55 @@ void doQuickPutFilter(const TRaster32P &dn, const TRaster32P &up, double sx,TPixel32 *upBasePix = up->pixels();TPixel32 *dnRow = dn->pixels(yMin + kMinY);- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata" del pixel corrente di up+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel- // inizializza yL+ // initialize yLint yL = yL0 + (kMinY - 1) * deltaYL;- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int kY = kMinY; kY <= kMaxY; kY++, dnRow += dnWrap) {- // inizializza xL+ // initialize xLint xL = xL0 + (kMinX - 1) * deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e' approssimato- // con (xI, yI)- int yI = yL >> PADN; // troncato+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int yI = yL >> PADN; // truncated- // filtro bilineare 4 pixels: calcolo degli y-pesi+ // bilinear filter 4 pixels: calculation of y-weightsint yWeight1 = (yL & MASKN);int yWeight0 = (1 << PADN) - yWeight1;TPixel32 *dnPix = dnRow + xMin + kMinX;TPixel32 *dnEndPix = dnRow + xMin + kMaxX + 1;- // scorre i pixel sulla (yMin + kY)-esima scanline di dn+ // iterate over pixels on the (yMin + kY)-th scanline of dnfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // troncato+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int xI = xL >> PADN; // truncatedassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));- // (xI, yI)+ // (xI, yI)TPixel32 *upPix00 = upBasePix + (yI * upWrap + xI);- // (xI + 1, yI)+ // (xI + 1, yI)TPixel32 *upPix10 = upPix00 + 1;- // (xI, yI + 1)+ // (xI, yI + 1)TPixel32 *upPix01 = upPix00 + upWrap;- // (xI + 1, yI + 1)+ // (xI + 1, yI + 1)TPixel32 *upPix11 = upPix00 + upWrap + 1;- // filtro bilineare 4 pixels: calcolo degli x-pesi+ // bilinear filter 4 pixels: calculation of x-weightsint xWeight1 = (xL & MASKN);int xWeight0 = (1 << PADN) - xWeight1;- // filtro bilineare 4 pixels: media pesata sui singoli canali+ // bilinear filter 4 pixels: weighted average on each channelint rColDownTmp =(xWeight0 * (upPix00->r) + xWeight1 * ((upPix10)->r)) >> PADN;@@ -2122,172 +2097,170 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRaster32P &up, double sx,const TPixel32 &colorScale, bool doPremultiply,bool whiteTransp, bool firstColumn,bool doRasterDarkenBlendedView) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((sx == 0) || (sy == 0)) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)TAffine aff(sx, 0, tx, 0, sy, ty);TRectD boundingBoxD =TRectD(convert(dn->getBounds())) *(aff * TRectD(-0.5, -0.5, up->getLx() - 0.5, up->getLy() - 0.5));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- TAffine invAff = inv(aff); // inversa di aff+ TAffine invAff = inv(aff); // inverse of aff- // nello scorrere le scanline di boundingBoxD, il passaggio alla scanline- // successiva comporta l'incremento (0, deltaYD) delle coordinate dei- // pixels corrispondenti di up+ // when iterating over scanlines of boundingBoxD, moving to the next scanline+ // implies incrementing (0, deltaYD) of the coordinates of the corresponding+ // up pixels- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, 0) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, 0) of the coordinates of the corresponding+ // up pixeldouble deltaXD = invAff.a11;double deltaYD = invAff.a22;- // deltaXD "TLonghizzato" (round)+ // "long-ized" deltaXD (round)int deltaXL = tround(deltaXD * (1 << PADN));- // deltaYD "TLonghizzato" (round)+ // "long-ized" deltaYD (round)int deltaYL = tround(deltaYD * (1 << PADN));- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) || (deltaYL == 0)) return;- // (1) equazione (kX, kY)-parametrica di boundingBoxD:- // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),- // kX = 0, ..., (xMax - xMin),- // kY = 0, ..., (yMax - yMin)+ // (1) parametric (kX, kY)-equation of boundingBoxD:+ // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),+ // kX = 0, ..., (xMax - xMin),+ // kY = 0, ..., (yMax - yMin)- // (2) equazione (kX, kY)-parametrica dell'immagine- // mediante invAff di (1):- // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),- // kX = kMinX, ..., kMaxX- // con 0 <= kMinX <= kMaxX <= (xMax - xMin)+ // (2) parametric (kX, kY)-equation of the image via invAff of (1):+ // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),+ // kX = kMinX, ..., kMaxX+ // with 0 <= kMinX <= kMaxX <= (xMax - xMin)//- // kY = kMinY, ..., kMaxY- // con 0 <= kMinY <= kMaxY <= (yMax - yMin)+ // kY = kMinY, ..., kMaxY+ // with 0 <= kMinY <= kMaxY <= (yMax - yMin)- // calcola kMinX, kMaxX, kMinY, kMaxY intersecando la (2) con i lati di up+ // compute kMinX, kMaxX, kMinY, kMaxY by intersecting (2) with the sides of up- // il segmento [a, b] di up e' la controimmagine mediante aff della- // porzione di scanline [ (xMin, yMin), (xMax, yMin) ] di dn+ // the segment [a, b] of up is the inverse image via aff of the portion+ // of scanline [ (xMin, yMin), (xMax, yMin) ] of dn- // TPointD b = invAff*TPointD(xMax, yMin);+ // TPointD b = invAff*TPointD(xMax, yMin);TPointD a = invAff * TPointD(xMin, yMin);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + kX*deltaXL- // < up->getLx()*(1<<PADN),+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + kX*deltaXL+ // < up->getLx()*(1<<PADN),//- // 0 <= kMinX- // <= kX- // <= kMaxX- // <= (xMax - xMin)+ // 0 <= kMinX+ // <= kX+ // <= kMaxX+ // <= (xMax - xMin)- // 0 <= yL0 + kY*deltaYL- // < up->getLy()*(1<<PADN),+ // 0 <= yL0 + kY*deltaYL+ // < up->getLy()*(1<<PADN),//- // 0 <= kMinY- // <= kY- // <= kMaxY- // <= (yMax - yMin)+ // 0 <= kMinY+ // <= kY+ // <= kMaxY+ // <= (yMax - yMin)- // xL0 inizializzato per il round+ // xL0 initialized for roundingint xL0 = tround((a.x + 0.5) * (1 << PADN));- // yL0 inizializzato per il round+ // yL0 initialized for roundingint yL0 = tround((a.y + 0.5) * (1 << PADN));- // calcola kMinY, kMaxY, kMinX, kMaxX intersecando la (2) con i lati di up- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = yMax - yMin; // clipping su dn+ // compute kMinY, kMaxY, kMinX, kMaxX by intersecting (2) with the sides of up+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = yMax - yMin; // clipping on dn- // TINT32 predecessore di up->getLx()+ // predecessor of up->getLx()int lxPred = up->getLx() * (1 << PADN) - 1;- // TINT32 predecessore di up->getLy()+ // predecessor of up->getLy()int lyPred = up->getLy() * (1 << PADN) - 1;- // 0 <= xL0 + k*deltaXL < up->getLx()*(1<<PADN)+ // 0 <= xL0 + k*deltaXL < up->getLx()*(1<<PADN)// <=>- // 0 <= xL0 + k*deltaXL <= lxPred+ // 0 <= xL0 + k*deltaXL <= lxPred- // 0 <= yL0 + k*deltaYL < up->getLy()*(1<<PADN)+ // 0 <= yL0 + k*deltaYL < up->getLy()*(1<<PADN)// <=>- // 0 <= yL0 + k*deltaYL <= lyPred+ // 0 <= yL0 + k*deltaYL <= lyPred- // calcola kMinY, kMaxY intersecando la (2) con i lati- // (y = yMin) e (y = yMax) di up- if (deltaYL > 0) // (deltaYL != 0)+ // compute kMinY, kMaxY by intersecting (2) with the sides+ // (y = yMin) and (y = yMax) of up+ if (deltaYL > 0) // (deltaYL != 0){- // [a, b] interno ad up+(bordo destro/basso)+ // [a, b] inside up+(right/bottom edge)assert(yL0 <= lyPred);- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] interno ad up+(bordo destro/basso)+ // [a, b] inside up+(right/bottom edge)assert(0 <= yL0);- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMinY, kMaxY effettuando anche il clippind su dn+ // compute kMinY, kMaxY also performing clipping on dnkMinY = std::max(kMinY, (int)0);kMaxY = std::min(kMaxY, yMax - yMin);- // calcola kMinX, kMaxX intersecando la (2) con i lati- // (x = xMin) e (x = xMax) di up- if (deltaXL > 0) // (deltaXL != 0)+ // compute kMinX, kMaxX by intersecting (2) with the sides+ // (x = xMin) and (x = xMax) of up+ if (deltaXL > 0) // (deltaXL != 0){- // [a, b] interno ad up+(bordo destro/basso)+ // [a, b] inside up+(right/bottom edge)assert(xL0 <= lxPred);- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] interno ad up+(bordo destro/basso)+ // [a, b] inside up+(right/bottom edge)assert(0 <= xL0);- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinX, kMaxX effettuando anche il clippind su dn+ // compute kMinX, kMaxX also performing clipping on dnkMinX = std::max(kMinX, (int)0);kMaxX = std::min(kMaxX, xMax - xMin);@@ -2299,31 +2272,31 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRaster32P &up, double sx,TPixel32 *upBasePix = up->pixels();TPixel32 *dnRow = dn->pixels(yMin + kMinY);- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata" del pixel corrente di up+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel- // inizializza yL+ // initialize yLint yL = yL0 + (kMinY - 1) * deltaYL;- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int kY = kMinY; kY <= kMaxY; kY++, dnRow += dnWrap) {- // inizializza xL+ // initialize xLint xL = xL0 + (kMinX - 1) * deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e' approssimato- // con (xI, yI)- int yI = yL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int yI = yL >> PADN; // roundTPixel32 *dnPix = dnRow + xMin + kMinX;TPixel32 *dnEndPix = dnRow + xMin + kMaxX + 1;- // scorre i pixel sulla (yMin + kY)-esima scanline di dn+ // iterate over pixels on the (yMin + kY)-th scanline of dnfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int xI = xL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -2376,7 +2349,7 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRasterGR8P &up, double sx,int xMin = std::max(tfloor(boundingBoxD.x0), 0);int xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- TAffine invAff = inv(aff); // inversa di aff+ TAffine invAff = inv(aff); // inverse of affdouble deltaXD = invAff.a11;double deltaYD = invAff.a22;@@ -2387,46 +2360,46 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRasterGR8P &up, double sx,int xL0 = tround((a.x + 0.5) * (1 << PADN));int yL0 = tround((a.y + 0.5) * (1 << PADN));- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = yMax - yMin; // clipping su dn+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = yMax - yMin; // clipping on dnint lxPred = up->getLx() * (1 << PADN) - 1;int lyPred = up->getLy() * (1 << PADN) - 1;- if (deltaYL > 0) // (deltaYL != 0)+ if (deltaYL > 0) // (deltaYL != 0){assert(yL0 <= lyPred);- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){assert(0 <= yL0);- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}kMinY = std::max(kMinY, (int)0);kMaxY = std::min(kMaxY, yMax - yMin);- if (deltaXL > 0) // (deltaXL != 0)+ if (deltaXL > 0) // (deltaXL != 0){assert(xL0 <= lxPred);- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){assert(0 <= xL0);- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}kMinX = std::max(kMinX, (int)0);@@ -2443,21 +2416,21 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRasterGR8P &up, double sx,int yL = yL0 + (kMinY - 1) * deltaYL;for (int kY = kMinY; kY <= kMaxY; kY++, dnRow += dnWrap) {- // inizializza xL+ // initialize xLint xL = xL0 + (kMinX - 1) * deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e' approssimato- // con (xI, yI)- int yI = yL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int yI = yL >> PADN; // roundTPixel32 *dnPix = dnRow + xMin + kMinX;TPixel32 *dnEndPix = dnRow + xMin + kMaxX + 1;- // scorre i pixel sulla (yMin + kY)-esima scanline di dn+ // iterate over pixels on the (yMin + kY)-th scanline of dnfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;- int xI = xL >> PADN; // round+ int xI = xL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -2492,60 +2465,59 @@ elsevoid doQuickResampleFilter(const TRaster32P &dn, const TRaster32P &up,const TAffine &aff) {- // se aff e' degenere la controimmagine di up e' un segmento (o un punto)+ // if aff is degenerate, the inverse image of up is a segment (or a point)if ((aff.a11 * aff.a22 - aff.a12 * aff.a21) == 0) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // maschera del filtro bilineare+ // bilinear filter maskconst int MASKN = (1 << PADN) - 1;assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)TRectD boundingBoxD = TRectD(convert(dn->getSize())) *(aff * TRectD(0, 0, up->getLx() - 2, up->getLy() - 2));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- TAffine invAff = inv(aff); // inversa di aff+ TAffine invAff = inv(aff); // inverse of aff- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, deltaYD) delle coordinate- // del pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, deltaYD) of the corresponding up pixel+ // coordinatesdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- // deltaXD "TLonghizzato" (round)+ // "long-ized" deltaXD (round)int deltaXL = tround(deltaXD * (1 << PADN));- // deltaYD "TLonghizzato" (round)+ // "long-ized" deltaYD (round)int deltaYL = tround(deltaYD * (1 << PADN));- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) && (deltaYL == 0)) return;- // naturale predecessore di up->getLx() - 1+ // natural predecessor of up->getLx() - 1int lxPred = (up->getLx() - 2) * (1 << PADN);- // naturale predecessore di up->getLy() - 1+ // natural predecessor of up->getLy() - 1int lyPred = (up->getLy() - 2) * (1 << PADN);int dnWrap = dn->getWrap();@@ -2556,155 +2528,155 @@ void doQuickResampleFilter(const TRaster32P &dn, const TRaster32P &up,TPixel32 *dnRow = dn->pixels(yMin);TPixel32 *upBasePix = up->pixels();- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int y = yMin; y <= yMax; y++, dnRow += dnWrap) {- // (1) equazione k-parametrica della y-esima scanline di boundingBoxD:- // (xMin, y) + k*(1, 0), k = 0, ..., (xMax - xMin)+ // (1) parametric k-equation of the y-th scanline of boundingBoxD:+ // (xMin, y) + k*(1, 0), k = 0, ..., (xMax - xMin)//- // (2) equazione k-parametrica dell'immagine mediante invAff di (1):- // invAff*(xMin, y) + k*(deltaXD, deltaYD),- // k = kMin, ..., kMax- // con 0 <= kMin <= kMax <= (xMax - xMin)+ // (2) parametric k-equation of the image via invAff of (1):+ // invAff*(xMin, y) + k*(deltaXD, deltaYD),+ // k = kMin, ..., kMax+ // with 0 <= kMin <= kMax <= (xMax - xMin)- // calcola kMin, kMax per la scanline corrente intersecando- // la (2) con i lati di up+ // compute kMin, kMax for the current scanline by intersecting (2)+ // with the sides of up- // il segmento [a, b] di up e' la controimmagine mediante aff della- // porzione di scanline [ (xMin, y), (xMax, y) ] di dn+ // the segment [a, b] of up is the inverse image via aff of the portion+ // of scanline [ (xMin, y), (xMax, y) ] of dn- // TPointD b = invAff*TPointD(xMax, y);+ // TPointD b = invAff*TPointD(xMax, y);TPointD a = invAff * TPointD(xMin, y);- // (xL0, yL0) sono le coordinate di a in versione "TLonghizzata"- // 0 <= xL0 + k*deltaXL- // <= (up->getLx() - 2)*(1<<PADN),- // 0 <= kMinX- // <= kMin- // <= k- // <= kMax- // <= kMaxX- // <= (xMax - xMin)-- // 0 <= yL0 + k*deltaYL- // <= (up->getLy() - 2)*(1<<PADN),- // 0 <= kMinY- // <= kMin- // <= k- // <= kMax- // <= kMaxY- // <= (xMax - xMin)-- // xL0 inizializzato+ // (xL0, yL0) are the coordinates of a in "long-ized" version+ // 0 <= xL0 + k*deltaXL+ // <= (up->getLx() - 2)*(1<<PADN),+ // 0 <= kMinX+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxX+ // <= (xMax - xMin)++ // 0 <= yL0 + k*deltaYL+ // <= (up->getLy() - 2)*(1<<PADN),+ // 0 <= kMinY+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxY+ // <= (xMax - xMin)++ // xL0 initializedint xL0 = tround(a.x * (1 << PADN));- // yL0 inizializzato+ // yL0 initializedint yL0 = tround(a.y * (1 << PADN));- // calcola kMinX, kMaxX, kMinY, kMaxY- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn+ // compute kMinX, kMaxX, kMinY, kMaxY+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dn- // 0 <= xL0 + k*deltaXL <= (up->getLx() - 2)*(1<<PADN)+ // 0 <= xL0 + k*deltaXL <= (up->getLx() - 2)*(1<<PADN)// <=>- // 0 <= xL0 + k*deltaXL <= lxPred+ // 0 <= xL0 + k*deltaXL <= lxPred- // 0 <= yL0 + k*deltaYL <= (up->getLy() - 2)*(1<<PADN)+ // 0 <= yL0 + k*deltaYL <= (up->getLy() - 2)*(1<<PADN)// <=>- // 0 <= yL0 + k*deltaYL <= lyPred+ // 0 <= yL0 + k*deltaYL <= lyPred- // calcola kMinX, kMaxX+ // compute kMinX, kMaxXif (deltaXL == 0) {- // [a, b] verticale esterno ad up contratto+ // [a, b] vertical outside contracted upif ((xL0 < 0) || (lxPred < xL0)) continue;- // altrimenti usa solo- // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))+ // otherwise only use+ // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))} else if (deltaXL > 0) {- // [a, b] esterno ad up+(bordo destro)+ // [a, b] outside up+(right edge)if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] esterno ad up contratto+ // [a, b] outside contracted upif (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinY, kMaxY+ // compute kMinY, kMaxYif (deltaYL == 0) {- // [a, b] orizzontale esterno ad up contratto+ // [a, b] horizontal outside contracted upif ((yL0 < 0) || (lyPred < yL0)) continue;- // altrimenti usa solo- // kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))+ // otherwise only use+ // kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))} else if (deltaYL > 0) {- // [a, b] esterno ad up contratto+ // [a, b] outside contracted upif (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] esterno ad up contratto+ // [a, b] outside contracted upif (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMin, kMax effettuando anche il clippind su dn+ // compute kMin, kMax also performing clipping on dnint kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});TPixel32 *dnPix = dnRow + xMin + kMin;TPixel32 *dnEndPix = dnRow + xMin + kMax + 1;- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "longhizzata" del pixel corrente di up- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yL- // scorre i pixel sulla y-esima scanline di boundingBoxD+ // iterate over pixels on the y-th scanline of boundingBoxDfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // troncato- int yI = yL >> PADN; // troncato+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int xI = xL >> PADN; // truncated+ int yI = yL >> PADN; // truncatedassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));- // (xI, yI)+ // (xI, yI)TPixel32 *upPix00 = upBasePix + (yI * upWrap + xI);- // (xI + 1, yI)+ // (xI + 1, yI)TPixel32 *upPix10 = upPix00 + 1;- // (xI, yI + 1)+ // (xI, yI + 1)TPixel32 *upPix01 = upPix00 + upWrap;- // (xI + 1, yI + 1)+ // (xI + 1, yI + 1)TPixel32 *upPix11 = upPix00 + upWrap + 1;- // filtro bilineare 4 pixels: calcolo dei pesi+ // bilinear filter 4 pixels: weight calculationint xWeight1 = (xL & MASKN);int xWeight0 = (1 << PADN) - xWeight1;int yWeight1 = (yL & MASKN);int yWeight0 = (1 << PADN) - yWeight1;- // filtro bilineare 4 pixels: media pesata sui singoli canali+ // bilinear filter 4 pixels: weighted average on each channelint rColDownTmp =(xWeight0 * (upPix00->r) + xWeight1 * ((upPix10)->r)) >> PADN;@@ -2763,7 +2735,7 @@ void doQuickResampleFilter(const TRaster32P &dn, const TRasterGR8P &up,TRectD boundingBoxD = TRectD(convert(dn->getSize())) *(aff * TRectD(0, 0, up->getLx() - 2, up->getLy() - 2));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;@@ -2772,7 +2744,7 @@ void doQuickResampleFilter(const TRaster32P &dn, const TRasterGR8P &up,int xMin = std::max(tfloor(boundingBoxD.x0), 0);int xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- TAffine invAff = inv(aff); // inversa di aff+ TAffine invAff = inv(aff); // inverse of affdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;@@ -2795,24 +2767,24 @@ void doQuickResampleFilter(const TRaster32P &dn, const TRasterGR8P &up,TPointD a = invAff * TPointD(xMin, y);int xL0 = tround(a.x * (1 << PADN));int yL0 = tround(a.y * (1 << PADN));- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dnif (deltaXL == 0) {if ((xL0 < 0) || (lxPred < xL0)) continue;} else if (deltaXL > 0) {if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}} else {if (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}@@ -2821,17 +2793,17 @@ void doQuickResampleFilter(const TRaster32P &dn, const TRasterGR8P &up,} else if (deltaYL > 0) {if (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}@@ -2841,38 +2813,38 @@ void doQuickResampleFilter(const TRaster32P &dn, const TRasterGR8P &up,TPixel32 *dnPix = dnRow + xMin + kMin;TPixel32 *dnEndPix = dnRow + xMin + kMax + 1;- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yLfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- int xI = xL >> PADN; // troncato- int yI = yL >> PADN; // troncato+ int xI = xL >> PADN; // truncated+ int yI = yL >> PADN; // truncatedassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));- // (xI, yI)+ // (xI, yI)TPixelGR8 *upPix00 = upBasePix + (yI * upWrap + xI);- // (xI + 1, yI)+ // (xI + 1, yI)TPixelGR8 *upPix10 = upPix00 + 1;- // (xI, yI + 1)+ // (xI, yI + 1)TPixelGR8 *upPix01 = upPix00 + upWrap;- // (xI + 1, yI + 1)+ // (xI + 1, yI + 1)TPixelGR8 *upPix11 = upPix00 + upWrap + 1;- // filtro bilineare 4 pixels: calcolo dei pesi+ // bilinear filter 4 pixels: weight calculationint xWeight1 = (xL & MASKN);int xWeight0 = (1 << PADN) - xWeight1;int yWeight1 = (yL & MASKN);int yWeight0 = (1 << PADN) - yWeight1;- // filtro bilineare 4 pixels: media pesata sui singoli canali+ // bilinear filter 4 pixels: weighted average on each channelint colDownTmp =(xWeight0 * (upPix00->value) + xWeight1 * ((upPix10)->value)) >> PADN;@@ -2909,27 +2881,23 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRaster32P &up,if (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- int yMin = std::max(tfloor(boundingBoxD.y0), 0); // clipping y su dn+ int yMin = std::max(tfloor(boundingBoxD.y0), 0); // y clipping on dnint yMax =- std::min(tceil(boundingBoxD.y1), dn->getLy() - 1); // clipping y su dn- int xMin = std::max(tfloor(boundingBoxD.x0), 0); // clipping x su dn+ std::min(tceil(boundingBoxD.y1), dn->getLy() - 1); // y clipping on dn+ int xMin = std::max(tfloor(boundingBoxD.x0), 0); // x clipping on dnint xMax =- std::min(tceil(boundingBoxD.x1), dn->getLx() - 1); // clipping x su dn+ std::min(tceil(boundingBoxD.x1), dn->getLx() - 1); // x clipping on dn- TAffine invAff = inv(aff); // inversa di aff+ TAffine invAff = inv(aff); // inverse of affdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- int deltaXL =- tround(deltaXD * (1 << PADN)); // deltaXD "TLonghizzato" (round)- int deltaYL =- tround(deltaYD * (1 << PADN)); // deltaYD "TLonghizzato" (round)+ int deltaXL = tround(deltaXD * (1 << PADN)); // "long-ized" deltaXD (round)+ int deltaYL = tround(deltaYD * (1 << PADN)); // "long-ized" deltaYD (round)if ((deltaXL == 0) && (deltaYL == 0)) return;- int lxPred =- up->getLx() * (1 << PADN) - 1; // TINT32 predecessore di up->getLx()- int lyPred =- up->getLy() * (1 << PADN) - 1; // TINT32 predecessore di up->getLy()+ int lxPred = up->getLx() * (1 << PADN) - 1; // predecessor of up->getLx()+ int lyPred = up->getLy() * (1 << PADN) - 1; // predecessor of up->getLy()int dnWrap = dn->getWrap();int upWrap = up->getWrap();@@ -2943,48 +2911,48 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRaster32P &up,TPointD a = invAff * TPointD(xMin, y);int xL0 = tround((a.x + 0.5) * (1 << PADN));int yL0 = tround((a.y + 0.5) * (1 << PADN));- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dnif (deltaXL == 0) {if ((xL0 < 0) || (lxPred < xL0)) continue;} else if (deltaXL > 0) {if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor- if (xL0 < 0) kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil- } else // (deltaXL < 0)+ kMaxX = (lxPred - xL0) / deltaXL; // floor+ if (xL0 < 0) kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ } else // (deltaXL < 0){if (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0)- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}if (deltaYL == 0) {if ((yL0 < 0) || (lyPred < yL0)) continue;} else if (deltaYL > 0) {if (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor- if (yL0 < 0) kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil- } else // (deltaYL < 0)+ kMaxY = (lyPred - yL0) / deltaYL; // floor+ if (yL0 < 0) kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ } else // (deltaYL < 0){if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0)- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}int kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});TPixel32 *dnPix = dnRow + xMin + kMin;TPixel32 *dnEndPix = dnRow + xMin + kMax + 1;- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yLfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- int xI = xL >> PADN; // round- int yI = yL >> PADN; // round+ int xI = xL >> PADN; // round+ int yI = yL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -3026,27 +2994,23 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRaster64P &up,if (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- int yMin = std::max(tfloor(boundingBoxD.y0), 0); // clipping y su dn+ int yMin = std::max(tfloor(boundingBoxD.y0), 0); // y clipping on dnint yMax =- std::min(tceil(boundingBoxD.y1), dn->getLy() - 1); // clipping y su dn- int xMin = std::max(tfloor(boundingBoxD.x0), 0); // clipping x su dn+ std::min(tceil(boundingBoxD.y1), dn->getLy() - 1); // y clipping on dn+ int xMin = std::max(tfloor(boundingBoxD.x0), 0); // x clipping on dnint xMax =- std::min(tceil(boundingBoxD.x1), dn->getLx() - 1); // clipping x su dn+ std::min(tceil(boundingBoxD.x1), dn->getLx() - 1); // x clipping on dn- TAffine invAff = inv(aff); // inversa di aff+ TAffine invAff = inv(aff); // inverse of affdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- int deltaXL =- tround(deltaXD * (1 << PADN)); // deltaXD "TLonghizzato" (round)- int deltaYL =- tround(deltaYD * (1 << PADN)); // deltaYD "TLonghizzato" (round)+ int deltaXL = tround(deltaXD * (1 << PADN)); // "long-ized" deltaXD (round)+ int deltaYL = tround(deltaYD * (1 << PADN)); // "long-ized" deltaYD (round)if ((deltaXL == 0) && (deltaYL == 0)) return;- int lxPred =- up->getLx() * (1 << PADN) - 1; // TINT32 predecessore di up->getLx()- int lyPred =- up->getLy() * (1 << PADN) - 1; // TINT32 predecessore di up->getLy()+ int lxPred = up->getLx() * (1 << PADN) - 1; // predecessor of up->getLx()+ int lyPred = up->getLy() * (1 << PADN) - 1; // predecessor of up->getLy()int dnWrap = dn->getWrap();int upWrap = up->getWrap();@@ -3060,48 +3024,48 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRaster64P &up,TPointD a = invAff * TPointD(xMin, y);int xL0 = tround((a.x + 0.5) * (1 << PADN));int yL0 = tround((a.y + 0.5) * (1 << PADN));- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dnif (deltaXL == 0) {if ((xL0 < 0) || (lxPred < xL0)) continue;} else if (deltaXL > 0) {if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor- if (xL0 < 0) kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil- } else // (deltaXL < 0)+ kMaxX = (lxPred - xL0) / deltaXL; // floor+ if (xL0 < 0) kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ } else // (deltaXL < 0){if (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0)- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}if (deltaYL == 0) {if ((yL0 < 0) || (lyPred < yL0)) continue;} else if (deltaYL > 0) {if (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor- if (yL0 < 0) kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil- } else // (deltaYL < 0)+ kMaxY = (lyPred - yL0) / deltaYL; // floor+ if (yL0 < 0) kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ } else // (deltaYL < 0){if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0)- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}int kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});TPixel32 *dnPix = dnRow + xMin + kMin;TPixel32 *dnEndPix = dnRow + xMin + kMax + 1;- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yLfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- int xI = xL >> PADN; // round- int yI = yL >> PADN; // round+ int xI = xL >> PADN; // round+ int yI = yL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -3127,18 +3091,18 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRaster64P &up,void doQuickResampleFilter(const TRaster32P &dn, const TRaster32P &up,double sx, double sy, double tx, double ty) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((sx == 0) || (sy == 0)) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // maschera del filtro bilineare+ // bilinear filter maskconst int MASKN = (1 << PADN) - 1;- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));@@ -3147,141 +3111,138 @@ void doQuickResampleFilter(const TRaster32P &dn, const TRaster32P &up,TRectD(convert(dn->getSize())) *(aff * TRectD(0, 0, up->getLx() - /*1*/ 2, up->getLy() - /*1*/ 2));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- // inversa di aff+ // inverse of affTAffine invAff = inv(aff);- // nello scorrere le scanline di boundingBoxD, il passaggio alla scanline- // successiva comporta l'incremento (0, deltaYD) delle coordinate dei- // pixels corrispondenti di up+ // when iterating over scanlines of boundingBoxD, moving to the next scanline+ // implies incrementing (0, deltaYD) of the coordinates of the corresponding+ // up pixels- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, 0) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, 0) of the coordinates of the corresponding+ // up pixeldouble deltaXD = invAff.a11;double deltaYD = invAff.a22;- int deltaXL =- tround(deltaXD * (1 << PADN)); // deltaXD "TLonghizzato" (round)- int deltaYL =- tround(deltaYD * (1 << PADN)); // deltaYD "TLonghizzato" (round)+ int deltaXL = tround(deltaXD * (1 << PADN)); // "long-ized" deltaXD (round)+ int deltaYL = tround(deltaYD * (1 << PADN)); // "long-ized" deltaYD (round)- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e'- // un segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) || (deltaYL == 0)) return;- // (1) equazione (kX, kY)-parametrica di boundingBoxD:- // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),- // kX = 0, ..., (xMax - xMin),- // kY = 0, ..., (yMax - yMin)+ // (1) parametric (kX, kY)-equation of boundingBoxD:+ // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),+ // kX = 0, ..., (xMax - xMin),+ // kY = 0, ..., (yMax - yMin)- // (2) equazione (kX, kY)-parametrica dell'immagine mediante invAff di (1):- // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),- // kX = kMinX, ..., kMaxX- // con 0 <= kMinX <= kMaxX <= (xMax - xMin)+ // (2) parametric (kX, kY)-equation of the image via invAff of (1):+ // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),+ // kX = kMinX, ..., kMaxX+ // with 0 <= kMinX <= kMaxX <= (xMax - xMin)//- // kY = kMinY, ..., kMaxY- // con 0 <= kMinY <= kMaxY <= (yMax - yMin)+ // kY = kMinY, ..., kMaxY+ // with 0 <= kMinY <= kMaxY <= (yMax - yMin)- // calcola kMinX, kMaxX, kMinY, kMaxY intersecando la (2) con i lati di up+ // compute kMinX, kMaxX, kMinY, kMaxY by intersecting (2) with the sides of up- // il segmento [a, b] di up (con gli estremi eventualmente invertiti) e'- // la controimmagine mediante aff della porzione di scanline- // [ (xMin, yMin), (xMax, yMin) ] di dn+ // the segment [a, b] of up (with possibly reversed ends) is the inverse+ // image via aff of the portion of scanline+ // [ (xMin, yMin), (xMax, yMin) ] of dn- // TPointD b = invAff*TPointD(xMax, yMin);+ // TPointD b = invAff*TPointD(xMax, yMin);TPointD a = invAff * TPointD(xMin, yMin);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + kX*deltaXL <= (up->getLx() - 2)*(1<<PADN),- // 0 <= kMinX <= kX <= kMaxX <= (xMax - xMin)- // 0 <= yL0 + kY*deltaYL <= (up->getLy() - 2)*(1<<PADN),- // 0 <= kMinY <= kY <= kMaxY <= (yMax - yMin)+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + kX*deltaXL <= (up->getLx() - 2)*(1<<PADN),+ // 0 <= kMinX <= kX <= kMaxX <= (xMax - xMin)+ // 0 <= yL0 + kY*deltaYL <= (up->getLy() - 2)*(1<<PADN),+ // 0 <= kMinY <= kY <= kMaxY <= (yMax - yMin)- int xL0 = tround(a.x * (1 << PADN)); // xL0 inizializzato- int yL0 = tround(a.y * (1 << PADN)); // yL0 inizializzato+ int xL0 = tround(a.x * (1 << PADN)); // initialize xL0+ int yL0 = tround(a.y * (1 << PADN)); // initialize yL0- // calcola kMinY, kMaxY, kMinX, kMaxX intersecando la (2) con i lati di up- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = yMax - yMin; // clipping su dn+ // compute kMinY, kMaxY, kMinX, kMaxX by intersecting (2) with the sides of up+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = yMax - yMin; // clipping on dn- // TINT32 predecessore di (up->getLx() - 1)+ // predecessor of (up->getLx() - 1)int lxPred = (up->getLx() - /*1*/ 2) * (1 << PADN);- // TINT32 predecessore di (up->getLy() - 1)+ // predecessor of (up->getLy() - 1)int lyPred = (up->getLy() - /*1*/ 2) * (1 << PADN);- // 0 <= xL0 + k*deltaXL <= (up->getLx() - 2)*(1<<PADN)+ // 0 <= xL0 + k*deltaXL <= (up->getLx() - 2)*(1<<PADN)// <=>- // 0 <= xL0 + k*deltaXL <= lxPred+ // 0 <= xL0 + k*deltaXL <= lxPred- // 0 <= yL0 + k*deltaYL <= (up->getLy() - 2)*(1<<PADN)+ // 0 <= yL0 + k*deltaYL <= (up->getLy() - 2)*(1<<PADN)// <=>- // 0 <= yL0 + k*deltaYL <= lyPred+ // 0 <= yL0 + k*deltaYL <= lyPred- // calcola kMinY, kMaxY intersecando la (2) con i lati- // (y = yMin) e (y = yMax) di up- if (deltaYL > 0) // (deltaYL != 0)+ // compute kMinY, kMaxY by intersecting (2) with the sides+ // (y = yMin) and (y = yMax) of up+ if (deltaYL > 0) // (deltaYL != 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(yL0 <= lyPred);- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(0 <= yL0);- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMinY, kMaxY effettuando anche il clippind su dn+ // compute kMinY, kMaxY also performing clipping on dnkMinY = std::max(kMinY, (int)0);kMaxY = std::min(kMaxY, yMax - yMin);- // calcola kMinX, kMaxX intersecando la (2) con i lati- // (x = xMin) e (x = xMax) di up- if (deltaXL > 0) // (deltaXL != 0)+ // compute kMinX, kMaxX by intersecting (2) with the sides+ // (x = xMin) and (x = xMax) of up+ if (deltaXL > 0) // (deltaXL != 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(xL0 <= lxPred);- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(0 <= xL0);- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinX, kMaxX effettuando anche il clippind su dn+ // compute kMinX, kMaxX also performing clipping on dnkMinX = std::max(kMinX, (int)0);kMaxX = std::min(kMaxX, xMax - xMin);@@ -3293,53 +3254,52 @@ void doQuickResampleFilter(const TRaster32P &dn, const TRaster32P &up,TPixel32 *upBasePix = up->pixels();TPixel32 *dnRow = dn->pixels(yMin + kMinY);- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata"- // del pixel corrente di up- int yL = yL0 + (kMinY - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int yL = yL0 + (kMinY - 1) * deltaYL; // initialize yL- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int kY = kMinY; kY <= kMaxY; kY++, dnRow += dnWrap) {- int xL = xL0 + (kMinX - 1) * deltaXL; // inizializza xL+ int xL = xL0 + (kMinX - 1) * deltaXL; // initialize xLyL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e' approssimato- // con (xI, yI)- int yI = yL >> PADN; // troncato+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int yI = yL >> PADN; // truncated- // filtro bilineare 4 pixels: calcolo degli y-pesi+ // bilinear filter 4 pixels: calculation of y-weightsint yWeight1 = (yL & MASKN);int yWeight0 = (1 << PADN) - yWeight1;TPixel32 *dnPix = dnRow + xMin + kMinX;TPixel32 *dnEndPix = dnRow + xMin + kMaxX + 1;- // scorre i pixel sulla (yMin + kY)-esima scanline di dn+ // iterate over pixels on the (yMin + kY)-th scanline of dnfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // troncato+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int xI = xL >> PADN; // truncatedassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));- // (xI, yI)+ // (xI, yI)TPixel32 *upPix00 = upBasePix + (yI * upWrap + xI);- // (xI + 1, yI)+ // (xI + 1, yI)TPixel32 *upPix10 = upPix00 + 1;- // (xI, yI + 1)+ // (xI, yI + 1)TPixel32 *upPix01 = upPix00 + upWrap;- // (xI + 1, yI + 1)+ // (xI + 1, yI + 1)TPixel32 *upPix11 = upPix00 + upWrap + 1;- // filtro bilineare 4 pixels: calcolo degli x-pesi+ // bilinear filter 4 pixels: calculation of x-weightsint xWeight1 = (xL & MASKN);int xWeight0 = (1 << PADN) - xWeight1;- // filtro bilineare 4 pixels: media pesata sui singoli canali+ // bilinear filter 4 pixels: weighted average on each channelint rColDownTmp =(xWeight0 * (upPix00->r) + xWeight1 * ((upPix10)->r)) >> PADN;@@ -3386,18 +3346,18 @@ void doQuickResampleFilter(const TRaster32P &dn, const TRaster32P &up,void doQuickResampleFilter(const TRaster32P &dn, const TRasterGR8P &up,double sx, double sy, double tx, double ty) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((sx == 0) || (sy == 0)) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // maschera del filtro bilineare+ // bilinear filter maskconst int MASKN = (1 << PADN) - 1;- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));@@ -3406,141 +3366,138 @@ void doQuickResampleFilter(const TRaster32P &dn, const TRasterGR8P &up,TRectD(convert(dn->getSize())) *(aff * TRectD(0, 0, up->getLx() - /*1*/ 2, up->getLy() - /*1*/ 2));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- // inversa di aff+ // inverse of affTAffine invAff = inv(aff);- // nello scorrere le scanline di boundingBoxD, il passaggio alla scanline- // successiva comporta l'incremento (0, deltaYD) delle coordinate dei- // pixels corrispondenti di up+ // when iterating over scanlines of boundingBoxD, moving to the next scanline+ // implies incrementing (0, deltaYD) of the coordinates of the corresponding+ // up pixels- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, 0) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, 0) of the coordinates of the corresponding+ // up pixeldouble deltaXD = invAff.a11;double deltaYD = invAff.a22;- int deltaXL =- tround(deltaXD * (1 << PADN)); // deltaXD "TLonghizzato" (round)- int deltaYL =- tround(deltaYD * (1 << PADN)); // deltaYD "TLonghizzato" (round)+ int deltaXL = tround(deltaXD * (1 << PADN)); // "long-ized" deltaXD (round)+ int deltaYL = tround(deltaYD * (1 << PADN)); // "long-ized" deltaYD (round)- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e'- // un segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) || (deltaYL == 0)) return;- // (1) equazione (kX, kY)-parametrica di boundingBoxD:- // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),- // kX = 0, ..., (xMax - xMin),- // kY = 0, ..., (yMax - yMin)+ // (1) parametric (kX, kY)-equation of boundingBoxD:+ // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),+ // kX = 0, ..., (xMax - xMin),+ // kY = 0, ..., (yMax - yMin)- // (2) equazione (kX, kY)-parametrica dell'immagine mediante invAff di (1):- // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),- // kX = kMinX, ..., kMaxX- // con 0 <= kMinX <= kMaxX <= (xMax - xMin)+ // (2) parametric (kX, kY)-equation of the image via invAff of (1):+ // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),+ // kX = kMinX, ..., kMaxX+ // with 0 <= kMinX <= kMaxX <= (xMax - xMin)//- // kY = kMinY, ..., kMaxY- // con 0 <= kMinY <= kMaxY <= (yMax - yMin)+ // kY = kMinY, ..., kMaxY+ // with 0 <= kMinY <= kMaxY <= (yMax - yMin)- // calcola kMinX, kMaxX, kMinY, kMaxY intersecando la (2) con i lati di up+ // compute kMinX, kMaxX, kMinY, kMaxY by intersecting (2) with the sides of up- // il segmento [a, b] di up (con gli estremi eventualmente invertiti) e'- // la controimmagine mediante aff della porzione di scanline- // [ (xMin, yMin), (xMax, yMin) ] di dn+ // the segment [a, b] of up (with possibly reversed ends) is the inverse+ // image via aff of the portion of scanline+ // [ (xMin, yMin), (xMax, yMin) ] of dn- // TPointD b = invAff*TPointD(xMax, yMin);+ // TPointD b = invAff*TPointD(xMax, yMin);TPointD a = invAff * TPointD(xMin, yMin);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + kX*deltaXL <= (up->getLx() - 2)*(1<<PADN),- // 0 <= kMinX <= kX <= kMaxX <= (xMax - xMin)- // 0 <= yL0 + kY*deltaYL <= (up->getLy() - 2)*(1<<PADN),- // 0 <= kMinY <= kY <= kMaxY <= (yMax - yMin)+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + kX*deltaXL <= (up->getLx() - 2)*(1<<PADN),+ // 0 <= kMinX <= kX <= kMaxX <= (xMax - xMin)+ // 0 <= yL0 + kY*deltaYL <= (up->getLy() - 2)*(1<<PADN),+ // 0 <= kMinY <= kY <= kMaxY <= (yMax - yMin)- int xL0 = tround(a.x * (1 << PADN)); // xL0 inizializzato- int yL0 = tround(a.y * (1 << PADN)); // yL0 inizializzato+ int xL0 = tround(a.x * (1 << PADN)); // initialize xL0+ int yL0 = tround(a.y * (1 << PADN)); // initialize yL0- // calcola kMinY, kMaxY, kMinX, kMaxX intersecando la (2) con i lati di up- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = yMax - yMin; // clipping su dn+ // compute kMinY, kMaxY, kMinX, kMaxX by intersecting (2) with the sides of up+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = yMax - yMin; // clipping on dn- // TINT32 predecessore di (up->getLx() - 1)+ // predecessor of (up->getLx() - 1)int lxPred = (up->getLx() - /*1*/ 2) * (1 << PADN);- // TINT32 predecessore di (up->getLy() - 1)+ // predecessor of (up->getLy() - 1)int lyPred = (up->getLy() - /*1*/ 2) * (1 << PADN);- // 0 <= xL0 + k*deltaXL <= (up->getLx() - 2)*(1<<PADN)+ // 0 <= xL0 + k*deltaXL <= (up->getLx() - 2)*(1<<PADN)// <=>- // 0 <= xL0 + k*deltaXL <= lxPred+ // 0 <= xL0 + k*deltaXL <= lxPred- // 0 <= yL0 + k*deltaYL <= (up->getLy() - 2)*(1<<PADN)+ // 0 <= yL0 + k*deltaYL <= (up->getLy() - 2)*(1<<PADN)// <=>- // 0 <= yL0 + k*deltaYL <= lyPred+ // 0 <= yL0 + k*deltaYL <= lyPred- // calcola kMinY, kMaxY intersecando la (2) con i lati- // (y = yMin) e (y = yMax) di up- if (deltaYL > 0) // (deltaYL != 0)+ // compute kMinY, kMaxY by intersecting (2) with the sides+ // (y = yMin) and (y = yMax) of up+ if (deltaYL > 0) // (deltaYL != 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(yL0 <= lyPred);- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(0 <= yL0);- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMinY, kMaxY effettuando anche il clippind su dn+ // compute kMinY, kMaxY also performing clipping on dnkMinY = std::max(kMinY, (int)0);kMaxY = std::min(kMaxY, yMax - yMin);- // calcola kMinX, kMaxX intersecando la (2) con i lati- // (x = xMin) e (x = xMax) di up- if (deltaXL > 0) // (deltaXL != 0)+ // compute kMinX, kMaxX by intersecting (2) with the sides+ // (x = xMin) and (x = xMax) of up+ if (deltaXL > 0) // (deltaXL != 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(xL0 <= lxPred);- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(0 <= xL0);- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinX, kMaxX effettuando anche il clippind su dn+ // compute kMinX, kMaxX also performing clipping on dnkMinX = std::max(kMinX, (int)0);kMaxX = std::min(kMaxX, xMax - xMin);@@ -3552,53 +3509,52 @@ void doQuickResampleFilter(const TRaster32P &dn, const TRasterGR8P &up,TPixelGR8 *upBasePix = up->pixels();TPixel32 *dnRow = dn->pixels(yMin + kMinY);- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata"- // del pixel corrente di up- int yL = yL0 + (kMinY - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int yL = yL0 + (kMinY - 1) * deltaYL; // initialize yL- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int kY = kMinY; kY <= kMaxY; kY++, dnRow += dnWrap) {- int xL = xL0 + (kMinX - 1) * deltaXL; // inizializza xL+ int xL = xL0 + (kMinX - 1) * deltaXL; // initialize xLyL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e' approssimato- // con (xI, yI)- int yI = yL >> PADN; // troncato+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int yI = yL >> PADN; // truncated- // filtro bilineare 4 pixels: calcolo degli y-pesi+ // bilinear filter 4 pixels: calculation of y-weightsint yWeight1 = (yL & MASKN);int yWeight0 = (1 << PADN) - yWeight1;TPixel32 *dnPix = dnRow + xMin + kMinX;TPixel32 *dnEndPix = dnRow + xMin + kMaxX + 1;- // scorre i pixel sulla (yMin + kY)-esima scanline di dn+ // iterate over pixels on the (yMin + kY)-th scanline of dnfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // troncato+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int xI = xL >> PADN; // truncatedassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));- // (xI, yI)+ // (xI, yI)TPixelGR8 *upPix00 = upBasePix + (yI * upWrap + xI);- // (xI + 1, yI)+ // (xI + 1, yI)TPixelGR8 *upPix10 = upPix00 + 1;- // (xI, yI + 1)+ // (xI, yI + 1)TPixelGR8 *upPix01 = upPix00 + upWrap;- // (xI + 1, yI + 1)+ // (xI + 1, yI + 1)TPixelGR8 *upPix11 = upPix00 + upWrap + 1;- // filtro bilineare 4 pixels: calcolo degli x-pesi+ // bilinear filter 4 pixels: calculation of x-weightsint xWeight1 = (xL & MASKN);int xWeight0 = (1 << PADN) - xWeight1;- // filtro bilineare 4 pixels: media pesata sui singoli canali+ // bilinear filter 4 pixels: weighted average on each channelint colDownTmp =(xWeight0 * (upPix00->value) + xWeight1 * (upPix10->value)) >> PADN;@@ -3621,15 +3577,15 @@ void doQuickResampleFilter(const TRaster32P &dn, const TRasterGR8P &up,template <typename PIX>void doQuickResampleNoFilter(const TRasterPT<PIX> &dn, const TRasterPT<PIX> &up,double sx, double sy, double tx, double ty) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((sx == 0) || (sy == 0)) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));@@ -3637,136 +3593,129 @@ void doQuickResampleNoFilter(const TRasterPT<PIX> &dn, const TRasterPT<PIX> &up,TRectD boundingBoxD =TRectD(convert(dn->getBounds())) *(aff * TRectD(-0.5, -0.5, up->getLx() - 0.5, up->getLy() - 0.5));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- TAffine invAff = inv(aff); // inversa di aff+ TAffine invAff = inv(aff); // inverse of aff- // nello scorrere le scanline di boundingBoxD, il passaggio alla scanline- // successiva comporta l'incremento (0, deltaYD) delle coordinate dei- // pixels corrispondenti di up+ // when iterating over scanlines of boundingBoxD, moving to the next scanline+ // implies incrementing (0, deltaYD) of the coordinates of the corresponding+ // up pixels- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, 0) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, 0) of the coordinates of the corresponding+ // up pixeldouble deltaXD = invAff.a11;double deltaYD = invAff.a22;- int deltaXL =- tround(deltaXD * (1 << PADN)); // deltaXD "TLonghizzato" (round)- int deltaYL =- tround(deltaYD * (1 << PADN)); // deltaYD "TLonghizzato" (round)+ int deltaXL = tround(deltaXD * (1 << PADN)); // "long-ized" deltaXD (round)+ int deltaYL = tround(deltaYD * (1 << PADN)); // "long-ized" deltaYD (round)- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) || (deltaYL == 0)) return;- // (1) equazione (kX, kY)-parametrica di boundingBoxD:- // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),- // kX = 0, ..., (xMax - xMin),- // kY = 0, ..., (yMax - yMin)+ // (1) parametric (kX, kY)-equation of boundingBoxD:+ // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),+ // kX = 0, ..., (xMax - xMin),+ // kY = 0, ..., (yMax - yMin)- // (2) equazione (kX, kY)-parametrica dell'immagine mediante invAff di (1):- // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),- // kX = kMinX, ..., kMaxX- // con 0 <= kMinX <= kMaxX <= (xMax - xMin)- // kY = kMinY, ..., kMaxY- // con 0 <= kMinY <= kMaxY <= (yMax - yMin)+ // (2) parametric (kX, kY)-equation of the image via invAff of (1):+ // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),+ // kX = kMinX, ..., kMaxX+ // with 0 <= kMinX <= kMaxX <= (xMax - xMin)+ // kY = kMinY, ..., kMaxY+ // with 0 <= kMinY <= kMaxY <= (yMax - yMin)- // calcola kMinX, kMaxX, kMinY, kMaxY intersecando la (2) con i lati di up+ // compute kMinX, kMaxX, kMinY, kMaxY by intersecting (2) with the sides of up- // il segmento [a, b] di up e' la controimmagine mediante aff della- // porzione di scanline [ (xMin, yMin), (xMax, yMin) ] di dn+ // the segment [a, b] of up is the inverse image via aff of the portion+ // of scanline [ (xMin, yMin), (xMax, yMin) ] of dn- // TPointD b = invAff*TPointD(xMax, yMin);+ // TPointD b = invAff*TPointD(xMax, yMin);TPointD a = invAff * TPointD(xMin, yMin);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + kX*deltaXL < up->getLx()*(1<<PADN),- // 0 <= kMinX <= kX <= kMaxX <= (xMax - xMin)-- // 0 <= yL0 + kY*deltaYL < up->getLy()*(1<<PADN),- // 0 <= kMinY <= kY <= kMaxY <= (yMax - yMin)- int xL0 =- tround((a.x + 0.5) * (1 << PADN)); // xL0 inizializzato per il round- int yL0 =- tround((a.y + 0.5) * (1 << PADN)); // yL0 inizializzato per il round-- // calcola kMinY, kMaxY, kMinX, kMaxX intersecando la (2) con i lati di up- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = yMax - yMin; // clipping su dn- int lxPred =- up->getLx() * (1 << PADN) - 1; // TINT32 predecessore di up->getLx()- int lyPred =- up->getLy() * (1 << PADN) - 1; // TINT32 predecessore di up->getLy()-- // 0 <= xL0 + k*deltaXL < up->getLx()*(1<<PADN)+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + kX*deltaXL < up->getLx()*(1<<PADN),+ // 0 <= kMinX <= kX <= kMaxX <= (xMax - xMin)++ // 0 <= yL0 + kY*deltaYL < up->getLy()*(1<<PADN),+ // 0 <= kMinY <= kY <= kMaxY <= (yMax - yMin)+ int xL0 = tround((a.x + 0.5) * (1 << PADN)); // xL0 initialized for rounding+ int yL0 = tround((a.y + 0.5) * (1 << PADN)); // yL0 initialized for rounding++ // compute kMinY, kMaxY, kMinX, kMaxX by intersecting (2) with the sides of up+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = yMax - yMin; // clipping on dn+ int lxPred = up->getLx() * (1 << PADN) - 1; // predecessor of up->getLx()+ int lyPred = up->getLy() * (1 << PADN) - 1; // predecessor of up->getLy()++ // 0 <= xL0 + k*deltaXL < up->getLx()*(1<<PADN)// <=>- // 0 <= xL0 + k*deltaXL <= lxPred+ // 0 <= xL0 + k*deltaXL <= lxPred- // 0 <= yL0 + k*deltaYL < up->getLy()*(1<<PADN)+ // 0 <= yL0 + k*deltaYL < up->getLy()*(1<<PADN)// <=>- // 0 <= yL0 + k*deltaYL <= lyPred+ // 0 <= yL0 + k*deltaYL <= lyPred- // calcola kMinY, kMaxY intersecando la (2) con i lati- // (y = yMin) e (y = yMax) di up- if (deltaYL > 0) // (deltaYL != 0)+ // compute kMinY, kMaxY by intersecting (2) with the sides+ // (y = yMin) and (y = yMax) of up+ if (deltaYL > 0) // (deltaYL != 0){- assert(yL0 <= lyPred); // [a, b] interno ad up+(bordo destro/basso)- kMaxY = (lyPred - yL0) / deltaYL; // floor+ assert(yL0 <= lyPred); // [a, b] inside up+(right/bottom edge)+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] interno ad up+(bordo destro/basso)+ // [a, b] inside up+(right/bottom edge)assert(0 <= yL0);- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMinY, kMaxY effettuando anche il clippind su dn+ // compute kMinY, kMaxY also performing clipping on dnkMinY = std::max(kMinY, (int)0);kMaxY = std::min(kMaxY, yMax - yMin);- // calcola kMinX, kMaxX intersecando la (2) con i lati- // (x = xMin) e (x = xMax) di up- if (deltaXL > 0) // (deltaXL != 0)+ // compute kMinX, kMaxX by intersecting (2) with the sides+ // (x = xMin) and (x = xMax) of up+ if (deltaXL > 0) // (deltaXL != 0){- // [a, b] interno ad up+(bordo destro/basso)+ // [a, b] inside up+(right/bottom edge)assert(xL0 <= lxPred);- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] interno ad up+(bordo destro/basso)+ // [a, b] inside up+(right/bottom edge)assert(0 <= xL0);- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinX, kMaxX effettuando anche il clippind su dn+ // compute kMinX, kMaxX also performing clipping on dnkMinX = std::max(kMinX, (int)0);kMaxX = std::min(kMaxX, xMax - xMin);@@ -3778,27 +3727,27 @@ void doQuickResampleNoFilter(const TRasterPT<PIX> &dn, const TRasterPT<PIX> &up,PIX *upBasePix = up->pixels();PIX *dnRow = dn->pixels(yMin + kMinY);- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata" del pixel corrente di up- int yL = yL0 + (kMinY - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int yL = yL0 + (kMinY - 1) * deltaYL; // initialize yL- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int kY = kMinY; kY <= kMaxY; kY++, dnRow += dnWrap) {- int xL = xL0 + (kMinX - 1) * deltaXL; // inizializza xL+ int xL = xL0 + (kMinX - 1) * deltaXL; // initialize xLyL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e' approssimato- // con (xI, yI)- int yI = yL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int yI = yL >> PADN; // roundPIX *dnPix = dnRow + xMin + kMinX;PIX *dnEndPix = dnRow + xMin + kMaxX + 1;- // scorre i pixel sulla (yMin + kY)-esima scanline di dn+ // iterate over pixels on the (yMin + kY)-th scanline of dnfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int xI = xL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -3829,15 +3778,15 @@ void doQuickResampleNoFilter(const TRasterPT<PIX> &dn, const TRasterPT<PIX> &up,void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up,const TPaletteP &palette, const TAffine &aff,const TPixel32 &globalColorScale, bool inksOnly) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((aff.a11 * aff.a22 - aff.a12 * aff.a21) == 0) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));@@ -3845,52 +3794,51 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up,TRectD(convert(dn->getBounds())) *(aff * TRectD(-0.5, -0.5, up->getLx() - 0.5, up->getLy() - 0.5));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- // inversa di aff+ // inverse of affTAffine invAff = inv(aff);- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, deltaYD) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, deltaYD) of the corresponding up pixel+ // coordinatesdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- // deltaXD "TLonghizzato" (round)+ // "long-ized" deltaXD (round)int deltaXL = tround(deltaXD * (1 << PADN));- // deltaYD "TLonghizzato" (round)+ // "long-ized" deltaYD (round)int deltaYL = tround(deltaYD * (1 << PADN));- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) && (deltaYL == 0)) return;- // TINT32 predecessore di up->getLx()+ // predecessor of up->getLx()int lxPred = up->getLx() * (1 << PADN) - 1;- // TINT32 predecessore di up->getLy()+ // predecessor of up->getLy()int lyPred = up->getLy() * (1 << PADN) - 1;int dnWrap = dn->getWrap();int upWrap = up->getWrap();std::vector<TPixel32> colors(palette->getStyleCount());- // vector<TPixel32> inks(palette->getStyleCount());+ // std::vector<TPixel32> inks(palette->getStyleCount());if (globalColorScale != TPixel::Black)for (int i = 0; i < palette->getStyleCount(); i++)@@ -3906,139 +3854,139 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up,TPixel32 *dnRow = dn->pixels(yMin);TPixelCM32 *upBasePix = up->pixels();- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int y = yMin; y <= yMax; y++, dnRow += dnWrap) {- // (1) equazione k-parametrica della y-esima scanline di boundingBoxD:+ // (1) parametric k-equation of the y-th scanline of boundingBoxD:// (xMin, y) + k*(1, 0), k = 0, ..., (xMax - xMin)- // (2) equazione k-parametrica dell'immagine mediante invAff di (1):+ // (2) parametric k-equation of the image via invAff of (1):// invAff*(xMin, y) + k*(deltaXD, deltaYD),- // k = kMin, ..., kMax con 0 <= kMin <= kMax <= (xMax - xMin)+ // k = kMin, ..., kMax with 0 <= kMin <= kMax <= (xMax - xMin)- // calcola kMin, kMax per la scanline corrente- // intersecando la (2) con i lati di up+ // compute kMin, kMax for the current scanline by intersecting (2)+ // with the sides of up- // il segmento [a, b] di up e' la controimmagine mediante aff della- // porzione di scanline [ (xMin, y), (xMax, y) ] di dn+ // the segment [a, b] of up is the inverse image via aff of the portion+ // of scanline [ (xMin, y), (xMax, y) ] of dn- // TPointD b = invAff*TPointD(xMax, y);+ // TPointD b = invAff*TPointD(xMax, y);TPointD a = invAff * TPointD(xMin, y);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)//- // 0 <= kMinX- // <= kMin- // <= k- // <= kMax- // <= kMaxX- // <= (xMax - xMin)+ // 0 <= kMinX+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxX+ // <= (xMax - xMin)//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)- // 0 <= kMinY- // <= kMin- // <= k- // <= kMax- // <= kMaxY- // <= (xMax - xMin)+ // 0 <= kMinY+ // <= kMin+ // <= k+ // <= kMax+ // <= kMaxY+ // <= (xMax - xMin)- // xL0 inizializzato per il round+ // xL0 initialized for roundingint xL0 = tround((a.x + 0.5) * (1 << PADN));- // yL0 inizializzato per il round+ // yL0 initialized for roundingint yL0 = tround((a.y + 0.5) * (1 << PADN));- // calcola kMinX, kMaxX, kMinY, kMaxY- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn+ // compute kMinX, kMaxX, kMinY, kMaxY+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dn- // 0 <= xL0 + k*deltaXL- // < up->getLx()*(1<<PADN)- // <=>- // 0 <= xL0 + k*deltaXL- // <= lxPred+ // 0 <= xL0 + k*deltaXL+ // < up->getLx()*(1<<PADN)+ // <=>+ // 0 <= xL0 + k*deltaXL+ // <= lxPred//- // 0 <= yL0 + k*deltaYL- // < up->getLy()*(1<<PADN)- // <=>- // 0 <= yL0 + k*deltaYL- // <= lyPred+ // 0 <= yL0 + k*deltaYL+ // < up->getLy()*(1<<PADN)+ // <=>+ // 0 <= yL0 + k*deltaYL+ // <= lyPred- // calcola kMinX, kMaxX+ // compute kMinX, kMaxXif (deltaXL == 0) {- // [a, b] verticale esterno ad up+(bordo destro/basso)+ // [a, b] vertical outside up+(right/bottom edge)if ((xL0 < 0) || (lxPred < xL0)) continue;- // altrimenti usa solo- // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))+ // otherwise only use+ // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))} else if (deltaXL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinY, kMaxY+ // compute kMinY, kMaxYif (deltaYL == 0) {- // [a, b] orizzontale esterno ad up+(bordo destro/basso)+ // [a, b] horizontal outside up+(right/bottom edge)if ((yL0 < 0) || (lyPred < yL0)) continue;- // altrimenti usa solo+ // otherwise only use// kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))} else if (deltaYL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMin, kMax effettuando anche il clippind su dn+ // compute kMin, kMax also performing clipping on dnint kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});TPixel32 *dnPix = dnRow + xMin + kMin;TPixel32 *dnEndPix = dnRow + xMin + kMax + 1;- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata" del pixel corrente di up- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yL- // scorre i pixel sulla y-esima scanline di boundingBoxD+ // iterate over pixels on the y-th scanline of boundingBoxDfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // round- int yI = yL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int xI = xL >> PADN; // round+ int yI = yL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -4130,13 +4078,15 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up,int lyPred = up->getLy() * (1 << PADN) - 1;int dnWrap = dn->getWrap();int upWrap = up->getWrap();+ // Build colour vectors from palettestd::vector<TPixel32> paints(palette->getStyleCount());std::vector<TPixel32> inks(palette->getStyleCount());+ // If palette has no styles, nothing can be drawn, return early+ if (inks.empty() || paints.empty()) return;+if (s.m_transparencyCheck && !s.m_isOnionSkin) {for (int i = 0; i < palette->getStyleCount(); i++) {- // if the style's autopaint flag is ON, show its original color- // so that users can easily find lines left unpainted.if (i == s.m_gapCheckIndex || palette->getStyle(i)->getFlags() != 0) {paints[i] = inks[i] = applyColorScaleCMapped(palette->getStyle(i)->getAverageColor(), s.m_globalColorScale);@@ -4159,6 +4109,7 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up,TPixel32 *dnRow = dn->pixels(yMin);TPixelCM32 *upBasePix = up->pixels();+for (int y = yMin; y <= yMax; y++, dnRow += dnWrap) {TPointD a = invAff * TPointD(xMin, y);int xL0 = tround((a.x + 0.5) * (1 << PADN));@@ -4169,28 +4120,23 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up,if ((xL0 < 0) || (lxPred < xL0)) continue;} else if (deltaXL > 0) {if (lxPred < xL0) continue;-- kMaxX = (lxPred - xL0) / deltaXL; // floor- if (xL0 < 0) kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMaxX = (lxPred - xL0) / deltaXL;+ if (xL0 < 0) kMinX = ((-xL0) + deltaXL - 1) / deltaXL;} else {if (xL0 < 0) continue;-- kMaxX = xL0 / (-deltaXL); // floor- if (lxPred < xL0)- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMaxX = xL0 / (-deltaXL);+ if (lxPred < xL0) kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL);}if (deltaYL == 0) {if ((yL0 < 0) || (lyPred < yL0)) continue;} else if (deltaYL > 0) {if (lyPred < yL0) continue;-kMaxY = (lyPred - yL0) / deltaYL;if (yL0 < 0) kMinY = ((-yL0) + deltaYL - 1) / deltaYL;} else {if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor- if (lyPred < yL0)- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMaxY = yL0 / (-deltaYL);+ if (lyPred < yL0) kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL);}int kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});@@ -4199,6 +4145,7 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up,TPixel32 *dnEndPix = dnRow + xMin + kMax + 1;int xL = xL0 + (kMin - 1) * deltaXL;int yL = yL0 + (kMin - 1) * deltaYL;+for (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;@@ -4208,33 +4155,37 @@ 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() < paints.size() ? upPix->getPaint() : -1;++ // clamp out‑of‑range paint/ink indices to 0+ int p = (upPix->getPaint() < (int)paints.size()) ? upPix->getPaint() : 0;+ int i = (upPix->getInk() < (int)inks.size()) ? upPix->getInk() : 0;if (t == 0xff && p == 0)continue;else {- int i = upPix->getInk() < inks.size() ? upPix->getInk() : -1;TPixel32 colorUp;if (s.m_inksOnly) switch (t) {case 0:- colorUp = (i == s.m_inkIndex) ? TPixel::Red : inks[i];+ if (s.m_inkCheckEnabled && i == s.m_inkIndex) {+ colorUp = s.m_inkCheckColor;+ } else if (s.m_ink1CheckEnabled && i == 1) {+ colorUp = s.m_ink1CheckColor;+ } else {+ colorUp = inks[i];+ }break;case 255:colorUp = TPixel::Transparent;break;default: {TPixel inkColor;- if (i == s.m_inkIndex) {- inkColor = TPixel::Red;- if (p == 0) {- t = t / 2; // transparency check(for a bug!) darken- // semitrasparent pixels; ghibli likes it, and wants- // it also for ink checks...- // otherwise, ramps goes always from reds towards grey...- }- } else+ if (s.m_inkCheckEnabled && i == s.m_inkIndex) {+ inkColor = s.m_inkCheckColor;+ } else if (s.m_ink1CheckEnabled && i == 1) {+ inkColor = s.m_ink1CheckColor;+ } else {inkColor = inks[i];-+ }colorUp = antialias(inkColor, 255 - t);break;}@@ -4242,24 +4193,34 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up,elseswitch (t) {case 0:- colorUp = (i == s.m_inkIndex) ? TPixel::Red : inks[i];+ if (s.m_inkCheckEnabled && i == s.m_inkIndex) {+ colorUp = s.m_inkCheckColor;+ } else if (s.m_ink1CheckEnabled && i == 1) {+ colorUp = s.m_ink1CheckColor;+ } else {+ colorUp = inks[i];+ }break;case 255:- colorUp = (p == s.m_paintIndex) ? TPixel::Red : paints[p];+ if (s.m_paintCheckEnabled && p == s.m_paintIndex) {+ colorUp = s.m_paintCheckColor;+ } else {+ colorUp = paints[p];+ }break;default: {- TPixel paintColor = (p == s.m_paintIndex) ? TPixel::Red : paints[p];+ TPixel paintColor = (s.m_paintCheckEnabled && p == s.m_paintIndex)+ ? s.m_paintCheckColor+ : paints[p];TPixel inkColor;- if (i == s.m_inkIndex) {- inkColor = TPixel::Red;- if (p == 0) {- paintColor = TPixel::Transparent;- }- } else+ if (s.m_inkCheckEnabled && i == s.m_inkIndex) {+ inkColor = s.m_inkCheckColor;+ } else if (s.m_ink1CheckEnabled && i == 1) {+ inkColor = s.m_ink1CheckColor;+ } else {inkColor = inks[i];-+ }if (s.m_transparencyCheck) t = t / 2;-colorUp = blend(inkColor, paintColor, t, TPixelCM32::getMaxTone());break;}@@ -4282,172 +4243,170 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up,const TPaletteP &palette, double sx, double sy,double tx, double ty, const TPixel32 &globalColorScale,bool inksOnly) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((sx == 0) || (sy == 0)) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)TAffine aff(sx, 0, tx, 0, sy, ty);TRectD boundingBoxD =TRectD(convert(dn->getBounds())) *(aff * TRectD(-0.5, -0.5, up->getLx() - 0.5, up->getLy() - 0.5));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- TAffine invAff = inv(aff); // inversa di aff+ TAffine invAff = inv(aff); // inverse of aff- // nello scorrere le scanline di boundingBoxD, il passaggio alla scanline- // successiva comporta l'incremento (0, deltaYD) delle coordinate dei- // pixels corrispondenti di up+ // when iterating over scanlines of boundingBoxD, moving to the next scanline+ // implies incrementing (0, deltaYD) of the coordinates of the corresponding+ // up pixels- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, 0) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, 0) of the coordinates of the corresponding+ // up pixeldouble deltaXD = invAff.a11;double deltaYD = invAff.a22;- // deltaXD "TLonghizzato" (round)+ // "long-ized" deltaXD (round)int deltaXL = tround(deltaXD * (1 << PADN));- // deltaYD "TLonghizzato" (round)+ // "long-ized" deltaYD (round)int deltaYL = tround(deltaYD * (1 << PADN));- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) || (deltaYL == 0)) return;- // (1) equazione (kX, kY)-parametrica di boundingBoxD:- // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),- // kX = 0, ..., (xMax - xMin),- // kY = 0, ..., (yMax - yMin)+ // (1) parametric (kX, kY)-equation of boundingBoxD:+ // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),+ // kX = 0, ..., (xMax - xMin),+ // kY = 0, ..., (yMax - yMin)- // (2) equazione (kX, kY)-parametrica dell'immagine- // mediante invAff di (1):- // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),- // kX = kMinX, ..., kMaxX- // con 0 <= kMinX <= kMaxX <= (xMax - xMin)+ // (2) parametric (kX, kY)-equation of the image via invAff of (1):+ // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),+ // kX = kMinX, ..., kMaxX+ // with 0 <= kMinX <= kMaxX <= (xMax - xMin)//- // kY = kMinY, ..., kMaxY- // con 0 <= kMinY <= kMaxY <= (yMax - yMin)+ // kY = kMinY, ..., kMaxY+ // with 0 <= kMinY <= kMaxY <= (yMax - yMin)- // calcola kMinX, kMaxX, kMinY, kMaxY intersecando la (2) con i lati di up+ // compute kMinX, kMaxX, kMinY, kMaxY by intersecting (2) with the sides of up- // il segmento [a, b] di up e' la controimmagine mediante aff della- // porzione di scanline [ (xMin, yMin), (xMax, yMin) ] di dn+ // the segment [a, b] of up is the inverse image via aff of the portion+ // of scanline [ (xMin, yMin), (xMax, yMin) ] of dn- // TPointD b = invAff*TPointD(xMax, yMin);+ // TPointD b = invAff*TPointD(xMax, yMin);TPointD a = invAff * TPointD(xMin, yMin);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + kX*deltaXL- // < up->getLx()*(1<<PADN),+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + kX*deltaXL+ // < up->getLx()*(1<<PADN),//- // 0 <= kMinX- // <= kX- // <= kMaxX- // <= (xMax - xMin)+ // 0 <= kMinX+ // <= kX+ // <= kMaxX+ // <= (xMax - xMin)- // 0 <= yL0 + kY*deltaYL- // < up->getLy()*(1<<PADN),+ // 0 <= yL0 + kY*deltaYL+ // < up->getLy()*(1<<PADN),//- // 0 <= kMinY- // <= kY- // <= kMaxY- // <= (yMax - yMin)+ // 0 <= kMinY+ // <= kY+ // <= kMaxY+ // <= (yMax - yMin)- // xL0 inizializzato per il round+ // xL0 initialized for roundingint xL0 = tround((a.x + 0.5) * (1 << PADN));- // yL0 inizializzato per il round+ // yL0 initialized for roundingint yL0 = tround((a.y + 0.5) * (1 << PADN));- // calcola kMinY, kMaxY, kMinX, kMaxX intersecando la (2) con i lati di up- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = yMax - yMin; // clipping su dn+ // compute kMinY, kMaxY, kMinX, kMaxX by intersecting (2) with the sides of up+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = yMax - yMin; // clipping on dn- // TINT32 predecessore di up->getLx()+ // predecessor of up->getLx()int lxPred = up->getLx() * (1 << PADN) - 1;- // TINT32 predecessore di up->getLy()+ // predecessor of up->getLy()int lyPred = up->getLy() * (1 << PADN) - 1;- // 0 <= xL0 + k*deltaXL < up->getLx()*(1<<PADN)+ // 0 <= xL0 + k*deltaXL < up->getLx()*(1<<PADN)// <=>- // 0 <= xL0 + k*deltaXL <= lxPred+ // 0 <= xL0 + k*deltaXL <= lxPred- // 0 <= yL0 + k*deltaYL < up->getLy()*(1<<PADN)+ // 0 <= yL0 + k*deltaYL < up->getLy()*(1<<PADN)// <=>- // 0 <= yL0 + k*deltaYL <= lyPred+ // 0 <= yL0 + k*deltaYL <= lyPred- // calcola kMinY, kMaxY intersecando la (2) con i lati- // (y = yMin) e (y = yMax) di up- if (deltaYL > 0) // (deltaYL != 0)+ // compute kMinY, kMaxY by intersecting (2) with the sides+ // (y = yMin) and (y = yMax) of up+ if (deltaYL > 0) // (deltaYL != 0){- // [a, b] interno ad up+(bordo destro/basso)+ // [a, b] inside up+(right/bottom edge)assert(yL0 <= lyPred);- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] interno ad up+(bordo destro/basso)+ // [a, b] inside up+(right/bottom edge)assert(0 <= yL0);- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMinY, kMaxY effettuando anche il clippind su dn+ // compute kMinY, kMaxY also performing clipping on dnkMinY = std::max(kMinY, (int)0);kMaxY = std::min(kMaxY, yMax - yMin);- // calcola kMinX, kMaxX intersecando la (2) con i lati- // (x = xMin) e (x = xMax) di up- if (deltaXL > 0) // (deltaXL != 0)+ // compute kMinX, kMaxX by intersecting (2) with the sides+ // (x = xMin) and (x = xMax) of up+ if (deltaXL > 0) // (deltaXL != 0){- // [a, b] interno ad up+(bordo destro/basso)+ // [a, b] inside up+(right/bottom edge)assert(xL0 <= lxPred);- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] interno ad up+(bordo destro/basso)+ // [a, b] inside up+(right/bottom edge)assert(0 <= xL0);- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinX, kMaxX effettuando anche il clippind su dn+ // compute kMinX, kMaxX also performing clipping on dnkMinX = std::max(kMinX, (int)0);kMaxX = std::min(kMaxX, xMax - xMin);@@ -4473,31 +4432,31 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up,TPixelCM32 *upBasePix = up->pixels();TPixel32 *dnRow = dn->pixels(yMin + kMinY);- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata" del pixel corrente di up+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel- // inizializza yL+ // initialize yLint yL = yL0 + (kMinY - 1) * deltaYL;- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int kY = kMinY; kY <= kMaxY; kY++, dnRow += dnWrap) {- // inizializza xL+ // initialize xLint xL = xL0 + (kMinX - 1) * deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e' approssimato- // con (xI, yI)- int yI = yL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int yI = yL >> PADN; // roundTPixel32 *dnPix = dnRow + xMin + kMinX;TPixel32 *dnEndPix = dnRow + xMin + kMaxX + 1;- // scorre i pixel sulla (yMin + kY)-esima scanline di dn+ // iterate over pixels on the (yMin + kY)-th scanline of dnfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int xI = xL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -4575,27 +4534,23 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRasterCM32P &up,if (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- int yMin = std::max(tfloor(boundingBoxD.y0), 0); // clipping y su dn+ int yMin = std::max(tfloor(boundingBoxD.y0), 0); // y clipping on dnint yMax =- std::min(tceil(boundingBoxD.y1), dn->getLy() - 1); // clipping y su dn- int xMin = std::max(tfloor(boundingBoxD.x0), 0); // clipping x su dn+ std::min(tceil(boundingBoxD.y1), dn->getLy() - 1); // y clipping on dn+ int xMin = std::max(tfloor(boundingBoxD.x0), 0); // x clipping on dnint xMax =- std::min(tceil(boundingBoxD.x1), dn->getLx() - 1); // clipping x su dn+ std::min(tceil(boundingBoxD.x1), dn->getLx() - 1); // x clipping on dn- TAffine invAff = inv(aff); // inversa di aff+ TAffine invAff = inv(aff); // inverse of affdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- int deltaXL =- tround(deltaXD * (1 << PADN)); // deltaXD "TLonghizzato" (round)- int deltaYL =- tround(deltaYD * (1 << PADN)); // deltaYD "TLonghizzato" (round)+ int deltaXL = tround(deltaXD * (1 << PADN)); // "long-ized" deltaXD (round)+ int deltaYL = tround(deltaYD * (1 << PADN)); // "long-ized" deltaYD (round)if ((deltaXL == 0) && (deltaYL == 0)) return;- int lxPred =- up->getLx() * (1 << PADN) - 1; // TINT32 predecessore di up->getLx()- int lyPred =- up->getLy() * (1 << PADN) - 1; // TINT32 predecessore di up->getLy()+ int lxPred = up->getLx() * (1 << PADN) - 1; // predecessor of up->getLx()+ int lyPred = up->getLy() * (1 << PADN) - 1; // predecessor of up->getLy()int dnWrap = dn->getWrap();int upWrap = up->getWrap();@@ -4609,48 +4564,48 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRasterCM32P &up,TPointD a = invAff * TPointD(xMin, y);int xL0 = tround((a.x + 0.5) * (1 << PADN));int yL0 = tround((a.y + 0.5) * (1 << PADN));- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dnif (deltaXL == 0) {if ((xL0 < 0) || (lxPred < xL0)) continue;} else if (deltaXL > 0) {if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor- if (xL0 < 0) kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil- } else // (deltaXL < 0)+ kMaxX = (lxPred - xL0) / deltaXL; // floor+ if (xL0 < 0) kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ } else // (deltaXL < 0){if (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0)- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}if (deltaYL == 0) {if ((yL0 < 0) || (lyPred < yL0)) continue;} else if (deltaYL > 0) {if (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor- if (yL0 < 0) kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil- } else // (deltaYL < 0)+ kMaxY = (lyPred - yL0) / deltaYL; // floor+ if (yL0 < 0) kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ } else // (deltaYL < 0){if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0)- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}int kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});TPixel32 *dnPix = dnRow + xMin + kMin;TPixel32 *dnEndPix = dnRow + xMin + kMax + 1;- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yLfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- int xI = xL >> PADN; // round- int yI = yL >> PADN; // round+ int xI = xL >> PADN; // round+ int yI = yL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));@@ -4693,60 +4648,59 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRasterCM32P &up,#ifdef OPTIMIZE_FOR_LP64void doQuickResampleFilter_optimized(const TRaster32P &dn, const TRaster32P &up,const TAffine &aff) {- // se aff e' degenere la controimmagine di up e' un segmento (o un punto)+ // if aff is degenerate, the inverse image of up is a segment (or a point)if ((aff.a11 * aff.a22 - aff.a12 * aff.a21) == 0) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // maschera del filtro bilineare+ // bilinear filter maskconst int MASKN = (1 << PADN) - 1;assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)TRectD boundingBoxD = TRectD(convert(dn->getSize())) *(aff * TRectD(0, 0, up->getLx() - 2, up->getLy() - 2));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- TAffine invAff = inv(aff); // inversa di aff+ TAffine invAff = inv(aff); // inverse of aff- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, deltaYD) delle coordinate- // del pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, deltaYD) of the corresponding up pixel+ // coordinatesdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- // deltaXD "TLonghizzato" (round)+ // "long-ized" deltaXD (round)int deltaXL = tround(deltaXD * (1 << PADN));- // deltaYD "TLonghizzato" (round)+ // "long-ized" deltaYD (round)int deltaYL = tround(deltaYD * (1 << PADN));- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e' un- // segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) && (deltaYL == 0)) return;- // naturale predecessore di up->getLx() - 1+ // natural predecessor of up->getLx() - 1int lxPred = (up->getLx() - 2) * (1 << PADN);- // naturale predecessore di up->getLy() - 1+ // natural predecessor of up->getLy() - 1int lyPred = (up->getLy() - 2) * (1 << PADN);int dnWrap = dn->getWrap();@@ -4812,7 +4766,7 @@ void doQuickResampleFilter_optimized(const TRaster32P &dn, const TRaster32P &up,int y = yMin;++yMax;- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (; y < yMax - 32; ++y, dnRow += dnWrap) {EXTERNAL_LOOP_THE_FIRST_X_32}@@ -4845,18 +4799,18 @@ void doQuickResampleFilter_optimized(const TRaster32P &dn, const TRaster32P &up,void doQuickResampleFilter_optimized(const TRaster32P &dn, const TRaster32P &up,double sx, double sy, double tx,double ty) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((sx == 0) || (sy == 0)) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // maschera del filtro bilineare+ // bilinear filter maskconst int MASKN = (1 << PADN) - 1;- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));@@ -4864,141 +4818,138 @@ void doQuickResampleFilter_optimized(const TRaster32P &dn, const TRaster32P &up,TRectD boundingBoxD = TRectD(convert(dn->getSize())) *(aff * TRectD(0, 0, up->getLx() - 2, up->getLy() - 2));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- // clipping y su dn+ // y clipping on dnint yMin = std::max(tfloor(boundingBoxD.y0), 0);- // clipping y su dn+ // y clipping on dnint yMax = std::min(tceil(boundingBoxD.y1), dn->getLy() - 1);- // clipping x su dn+ // x clipping on dnint xMin = std::max(tfloor(boundingBoxD.x0), 0);- // clipping x su dn+ // x clipping on dnint xMax = std::min(tceil(boundingBoxD.x1), dn->getLx() - 1);- // inversa di aff+ // inverse of affTAffine invAff = inv(aff);- // nello scorrere le scanline di boundingBoxD, il passaggio alla scanline- // successiva comporta l'incremento (0, deltaYD) delle coordinate dei- // pixels corrispondenti di up+ // when iterating over scanlines of boundingBoxD, moving to the next scanline+ // implies incrementing (0, deltaYD) of the coordinates of the corresponding+ // up pixels- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, 0) delle coordinate del- // pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, 0) of the coordinates of the corresponding+ // up pixeldouble deltaXD = invAff.a11;double deltaYD = invAff.a22;- int deltaXL =- tround(deltaXD * (1 << PADN)); // deltaXD "TLonghizzato" (round)- int deltaYL =- tround(deltaYD * (1 << PADN)); // deltaYD "TLonghizzato" (round)+ int deltaXL = tround(deltaXD * (1 << PADN)); // "long-ized" deltaXD (round)+ int deltaYL = tround(deltaYD * (1 << PADN)); // "long-ized" deltaYD (round)- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e'- // un segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) || (deltaYL == 0)) return;- // (1) equazione (kX, kY)-parametrica di boundingBoxD:- // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),- // kX = 0, ..., (xMax - xMin),- // kY = 0, ..., (yMax - yMin)+ // (1) parametric (kX, kY)-equation of boundingBoxD:+ // (xMin, yMin) + kX*(1, 0) + kY*(0, 1),+ // kX = 0, ..., (xMax - xMin),+ // kY = 0, ..., (yMax - yMin)- // (2) equazione (kX, kY)-parametrica dell'immagine mediante invAff di (1):- // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),- // kX = kMinX, ..., kMaxX- // con 0 <= kMinX <= kMaxX <= (xMax - xMin)+ // (2) parametric (kX, kY)-equation of the image via invAff of (1):+ // invAff*(xMin, yMin) + kX*(deltaXD, 0) + kY*(0, deltaYD),+ // kX = kMinX, ..., kMaxX+ // with 0 <= kMinX <= kMaxX <= (xMax - xMin)//- // kY = kMinY, ..., kMaxY- // con 0 <= kMinY <= kMaxY <= (yMax - yMin)+ // kY = kMinY, ..., kMaxY+ // with 0 <= kMinY <= kMaxY <= (yMax - yMin)- // calcola kMinX, kMaxX, kMinY, kMaxY intersecando la (2) con i lati di up+ // compute kMinX, kMaxX, kMinY, kMaxY by intersecting (2) with the sides of up- // il segmento [a, b] di up (con gli estremi eventualmente invertiti) e'- // la controimmagine mediante aff della porzione di scanline- // [ (xMin, yMin), (xMax, yMin) ] di dn+ // the segment [a, b] of up (with possibly reversed ends) is the inverse+ // image via aff of the portion of scanline+ // [ (xMin, yMin), (xMax, yMin) ] of dn- // TPointD b = invAff*TPointD(xMax, yMin);+ // TPointD b = invAff*TPointD(xMax, yMin);TPointD a = invAff * TPointD(xMin, yMin);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + kX*deltaXL <= (up->getLx() - 2)*(1<<PADN),- // 0 <= kMinX <= kX <= kMaxX <= (xMax - xMin)- // 0 <= yL0 + kY*deltaYL <= (up->getLy() - 2)*(1<<PADN),- // 0 <= kMinY <= kY <= kMaxY <= (yMax - yMin)+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + kX*deltaXL <= (up->getLx() - 2)*(1<<PADN),+ // 0 <= kMinX <= kX <= kMaxX <= (xMax - xMin)+ // 0 <= yL0 + kY*deltaYL <= (up->getLy() - 2)*(1<<PADN),+ // 0 <= kMinY <= kY <= kMaxY <= (yMax - yMin)- int xL0 = tround(a.x * (1 << PADN)); // xL0 inizializzato- int yL0 = tround(a.y * (1 << PADN)); // yL0 inizializzato+ int xL0 = tround(a.x * (1 << PADN)); // initialize xL0+ int yL0 = tround(a.y * (1 << PADN)); // initialize yL0- // calcola kMinY, kMaxY, kMinX, kMaxX intersecando la (2) con i lati di up- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = yMax - yMin; // clipping su dn+ // compute kMinY, kMaxY, kMinX, kMaxX by intersecting (2) with the sides of up+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = yMax - yMin; // clipping on dn- // TINT32 predecessore di (up->getLx() - 1)+ // predecessor of (up->getLx() - 1)int lxPred = (up->getLx() - 2) * (1 << PADN);- // TINT32 predecessore di (up->getLy() - 1)+ // predecessor of (up->getLy() - 1)int lyPred = (up->getLy() - 2) * (1 << PADN);- // 0 <= xL0 + k*deltaXL <= (up->getLx() - 2)*(1<<PADN)+ // 0 <= xL0 + k*deltaXL <= (up->getLx() - 2)*(1<<PADN)// <=>- // 0 <= xL0 + k*deltaXL <= lxPred+ // 0 <= xL0 + k*deltaXL <= lxPred- // 0 <= yL0 + k*deltaYL <= (up->getLy() - 2)*(1<<PADN)+ // 0 <= yL0 + k*deltaYL <= (up->getLy() - 2)*(1<<PADN)// <=>- // 0 <= yL0 + k*deltaYL <= lyPred+ // 0 <= yL0 + k*deltaYL <= lyPred- // calcola kMinY, kMaxY intersecando la (2) con i lati- // (y = yMin) e (y = yMax) di up- if (deltaYL > 0) // (deltaYL != 0)+ // compute kMinY, kMaxY by intersecting (2) with the sides+ // (y = yMin) and (y = yMax) of up+ if (deltaYL > 0) // (deltaYL != 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(yL0 <= lyPred);- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(0 <= yL0);- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMinY, kMaxY effettuando anche il clippind su dn+ // compute kMinY, kMaxY also performing clipping on dnkMinY = std::max(kMinY, (int)0);kMaxY = std::min(kMaxY, yMax - yMin);- // calcola kMinX, kMaxX intersecando la (2) con i lati- // (x = xMin) e (x = xMax) di up- if (deltaXL > 0) // (deltaXL != 0)+ // compute kMinX, kMaxX by intersecting (2) with the sides+ // (x = xMin) and (x = xMax) of up+ if (deltaXL > 0) // (deltaXL != 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(xL0 <= lxPred);- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] interno ad up contratto+ // [a, b] inside contracted upassert(0 <= xL0);- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinX, kMaxX effettuando anche il clippind su dn+ // compute kMinX, kMaxX also performing clipping on dnkMinX = std::max(kMinX, (int)0);kMaxX = std::min(kMaxX, xMax - xMin);@@ -5010,10 +4961,9 @@ void doQuickResampleFilter_optimized(const TRaster32P &dn, const TRaster32P &up,TPixel32 *upBasePix = up->pixels();TPixel32 *dnRow = dn->pixels(yMin + kMinY);- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata"- // del pixel corrente di up- int yL = yL0 + (kMinY - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int yL = yL0 + (kMinY - 1) * deltaYL; // initialize yLlong c1;long c2;@@ -5057,7 +5007,7 @@ void doQuickResampleFilter_optimized(const TRaster32P &dn, const TRaster32P &up,int kY = kMinY;++kMaxY;- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (; kY < kMaxY - 32; kY++, dnRow += dnWrap) {EXTERNAL_LOOP_THE_SECOND_X_32}@@ -5215,52 +5165,47 @@ void quickPut(const TRasterP &dn, const TRasterP &up, const TAffine &aff,template <typename PIX>void doQuickResampleNoFilter(const TRasterPT<PIX> &dn, const TRasterPT<PIX> &up,const TAffine &aff) {- // se aff := TAffine(sx, 0, tx, 0, sy, ty) e' degenere la controimmagine- // di up e' un segmento (o un punto)+ // if aff := TAffine(sx, 0, tx, 0, sy, ty) is degenerate, the inverse image+ // of up is a segment (or a point)if ((aff.a11 * aff.a22 - aff.a12 * aff.a21) == 0) return;- // contatore bit di shift+ // shift bit counterconst int PADN = 16;- // max dimensioni di up gestibili (limite imposto dal numero di bit- // disponibili per la parte intera di xL, yL)+ // max manageable size of up (limit imposed by number of bits+ // available for the integer part of xL, yL)assert(std::max(up->getLx(), up->getLy()) <(1 << (8 * sizeof(int) - PADN - 1)));TRectD boundingBoxD =TRectD(convert(dn->getBounds())) *(aff * TRectD(-0.5, -0.5, up->getLx() - 0.5, up->getLy() - 0.5));- // clipping+ // clippingif (boundingBoxD.x0 >= boundingBoxD.x1 || boundingBoxD.y0 >= boundingBoxD.y1)return;- int yMin = std::max(tfloor(boundingBoxD.y0), 0); // clipping y su dn+ int yMin = std::max(tfloor(boundingBoxD.y0), 0); // y clipping on dnint yMax =- std::min(tceil(boundingBoxD.y1), dn->getLy() - 1); // clipping y su dn- int xMin = std::max(tfloor(boundingBoxD.x0), 0); // clipping x su dn+ std::min(tceil(boundingBoxD.y1), dn->getLy() - 1); // y clipping on dn+ int xMin = std::max(tfloor(boundingBoxD.x0), 0); // x clipping on dnint xMax =- std::min(tceil(boundingBoxD.x1), dn->getLx() - 1); // clipping x su dn+ std::min(tceil(boundingBoxD.x1), dn->getLx() - 1); // x clipping on dn- TAffine invAff = inv(aff); // inversa di aff+ TAffine invAff = inv(aff); // inverse of aff- // nel disegnare la y-esima scanline di dn, il passaggio al pixel- // successivo comporta l'incremento (deltaXD, deltaYD) delle coordinate- // del pixel corrispondente di up+ // when drawing the y-th scanline of dn, moving to the next pixel+ // implies incrementing (deltaXD, deltaYD) of the corresponding up pixel+ // coordinatesdouble deltaXD = invAff.a11;double deltaYD = invAff.a21;- int deltaXL =- tround(deltaXD * (1 << PADN)); // deltaXD "TLonghizzato" (round)- int deltaYL =- tround(deltaYD * (1 << PADN)); // deltaYD "TLonghizzato" (round)+ int deltaXL = tround(deltaXD * (1 << PADN)); // "long-ized" deltaXD (round)+ int deltaYL = tround(deltaYD * (1 << PADN)); // "long-ized" deltaYD (round)- // se aff "TLonghizzata" (round) e' degenere la controimmagine di up e'- // un segmento (o un punto)+ // if "long-ized" aff is degenerate, the inverse image of up is a segmentif ((deltaXL == 0) && (deltaYL == 0)) return;- int lxPred =- up->getLx() * (1 << PADN) - 1; // TINT32 predecessore di up->getLx()- int lyPred =- up->getLy() * (1 << PADN) - 1; // TINT32 predecessore di up->getLy()+ int lxPred = up->getLx() * (1 << PADN) - 1; // predecessor of up->getLx()+ int lyPred = up->getLy() * (1 << PADN) - 1; // predecessor of up->getLy()int dnWrap = dn->getWrap();int upWrap = up->getWrap();@@ -5270,121 +5215,121 @@ void doQuickResampleNoFilter(const TRasterPT<PIX> &dn, const TRasterPT<PIX> &up,PIX *dnRow = dn->pixels(yMin);PIX *upBasePix = up->pixels();- // scorre le scanline di boundingBoxD+ // iterate over boundingBoxD scanlinesfor (int y = yMin; y <= yMax; y++, dnRow += dnWrap) {- // (1) equazione k-parametrica della y-esima scanline di boundingBoxD:- // (xMin, y) + k*(1, 0),- // k = 0, ..., (xMax - xMin)+ // (1) parametric k-equation of the y-th scanline of boundingBoxD:+ // (xMin, y) + k*(1, 0),+ // k = 0, ..., (xMax - xMin)- // (2) equazione k-parametrica dell'immagine mediante invAff di (1):- // invAff*(xMin, y) + k*(deltaXD, deltaYD),- // k = kMin, ..., kMax- // con 0 <= kMin <= kMax <= (xMax - xMin)+ // (2) parametric k-equation of the image via invAff of (1):+ // invAff*(xMin, y) + k*(deltaXD, deltaYD),+ // k = kMin, ..., kMax+ // with 0 <= kMin <= kMax <= (xMax - xMin)- // calcola kMin, kMax per la scanline corrente intersecando- // la (2) con i lati di up+ // compute kMin, kMax for the current scanline by intersecting (2)+ // with the sides of up- // il segmento [a, b] di up e' la controimmagine mediante aff della- // porzione di scanline [ (xMin, y), (xMax, y) ] di dn+ // the segment [a, b] of up is the inverse image via aff of the portion+ // of scanline [ (xMin, y), (xMax, y) ] of dn- // TPointD b = invAff*TPointD(xMax, y);+ // TPointD b = invAff*TPointD(xMax, y);TPointD a = invAff * TPointD(xMin, y);- // (xL0, yL0) sono le coordinate di a (inizializzate per il round)- // in versione "TLonghizzata"- // 0 <= xL0 + k*deltaXL < up->getLx()*(1<<PADN),- // 0 <= kMinX <= kMin <= k <= kMax <= kMaxX <= (xMax - xMin)+ // (xL0, yL0) are the coordinates of a (initialized for rounding)+ // in "long-ized" version+ // 0 <= xL0 + k*deltaXL < up->getLx()*(1<<PADN),+ // 0 <= kMinX <= kMin <= k <= kMax <= kMaxX <= (xMax - xMin)- // 0 <= yL0 + k*deltaYL < up->getLy()*(1<<PADN),- // 0 <= kMinY <= kMin <= k <= kMax <= kMaxY <= (xMax - xMin)+ // 0 <= yL0 + k*deltaYL < up->getLy()*(1<<PADN),+ // 0 <= kMinY <= kMin <= k <= kMax <= kMaxY <= (xMax - xMin)- // xL0 inizializzato per il round+ // xL0 initialized for roundingint xL0 = tround((a.x + 0.5) * (1 << PADN));- // yL0 inizializzato per il round+ // yL0 initialized for roundingint yL0 = tround((a.y + 0.5) * (1 << PADN));- // calcola kMinX, kMaxX, kMinY, kMaxY- int kMinX = 0, kMaxX = xMax - xMin; // clipping su dn- int kMinY = 0, kMaxY = xMax - xMin; // clipping su dn- // 0 <= xL0 + k*deltaXL < up->getLx()*(1<<PADN)+ // compute kMinX, kMaxX, kMinY, kMaxY+ int kMinX = 0, kMaxX = xMax - xMin; // clipping on dn+ int kMinY = 0, kMaxY = xMax - xMin; // clipping on dn+ // 0 <= xL0 + k*deltaXL < up->getLx()*(1<<PADN)// <=>- // 0 <= xL0 + k*eltaXL <= lxPred+ // 0 <= xL0 + k*deltaXL <= lxPred- // 0 <= yL0 + k*deltaYL < up->getLy()*(1<<PADN)+ // 0 <= yL0 + k*deltaYL < up->getLy()*(1<<PADN)// <=>- // 0 <= yL0 + k*deltaYL <= lyPred+ // 0 <= yL0 + k*deltaYL <= lyPred- // calcola kMinX, kMaxX+ // compute kMinX, kMaxXif (deltaXL == 0) {- // [a, b] verticale esterno ad up+(bordo destro/basso)+ // [a, b] vertical outside up+(right/bottom edge)if ((xL0 < 0) || (lxPred < xL0)) continue;- // altrimenti usa solo- // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))+ // otherwise only use+ // kMinY, kMaxY ((deltaXL != 0) || (deltaYL != 0))} else if (deltaXL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lxPred < xL0) continue;- kMaxX = (lxPred - xL0) / deltaXL; // floor+ kMaxX = (lxPred - xL0) / deltaXL; // floorif (xL0 < 0) {- kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil+ kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil}- } else // (deltaXL < 0)+ } else // (deltaXL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (xL0 < 0) continue;- kMaxX = xL0 / (-deltaXL); // floor+ kMaxX = xL0 / (-deltaXL); // floorif (lxPred < xL0) {- kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil+ kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); // ceil}}- // calcola kMinY, kMaxY+ // compute kMinY, kMaxYif (deltaYL == 0) {- // [a, b] orizzontale esterno ad up+(bordo destro/basso)+ // [a, b] horizontal outside up+(right/bottom edge)if ((yL0 < 0) || (lyPred < yL0)) continue;- // altrimenti usa solo- // kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))+ // otherwise only use+ // kMinX, kMaxX ((deltaXL != 0) || (deltaYL != 0))} else if (deltaYL > 0) {- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (lyPred < yL0) continue;- kMaxY = (lyPred - yL0) / deltaYL; // floor+ kMaxY = (lyPred - yL0) / deltaYL; // floorif (yL0 < 0) {- kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil+ kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil}- } else // (deltaYL < 0)+ } else // (deltaYL < 0){- // [a, b] esterno ad up+(bordo destro/basso)+ // [a, b] outside up+(right/bottom edge)if (yL0 < 0) continue;- kMaxY = yL0 / (-deltaYL); // floor+ kMaxY = yL0 / (-deltaYL); // floorif (lyPred < yL0) {- kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil+ kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); // ceil}}- // calcola kMin, kMax effettuando anche il clippind su dn+ // compute kMin, kMax also performing clipping on dnint kMin = std::max({kMinX, kMinY, (int)0});int kMax = std::min({kMaxX, kMaxY, xMax - xMin});PIX *dnPix = dnRow + xMin + kMin;PIX *dnEndPix = dnRow + xMin + kMax + 1;- // (xL, yL) sono le coordinate (inizializzate per il round)- // in versione "TLonghizzata" del pixel corrente di up- int xL = xL0 + (kMin - 1) * deltaXL; // inizializza xL- int yL = yL0 + (kMin - 1) * deltaYL; // inizializza yL+ // (xL, yL) are the coordinates (initialized for rounding)+ // in "long-ized" version of the current up pixel+ int xL = xL0 + (kMin - 1) * deltaXL; // initialize xL+ int yL = yL0 + (kMin - 1) * deltaYL; // initialize yL- // scorre i pixel sulla y-esima scanline di boundingBoxD+ // iterate over pixels on the y-th scanline of boundingBoxDfor (; dnPix < dnEndPix; ++dnPix) {xL += deltaXL;yL += deltaYL;- // il punto di up TPointD(xL/(1<<PADN), yL/(1<<PADN)) e'- // approssimato con (xI, yI)- int xI = xL >> PADN; // round- int yI = yL >> PADN; // round+ // the up point TPointD(xL/(1<<PADN), yL/(1<<PADN)) is approximated+ // with (xI, yI)+ int xI = xL >> PADN; // round+ int yI = yL >> PADN; // roundassert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) &&(yI <= up->getLy() - 1));diff --git a/toonz/sources/common/tvrender/tglregions.cpp b/toonz/sources/common/tvrender/tglregions.cppindex 43d6e1715..f306225bc 100644--- a/toonz/sources/common/tvrender/tglregions.cpp+++ b/toonz/sources/common/tvrender/tglregions.cpp@@ -39,8 +39,6 @@#undef checkErrorsByGL#define checkErrorsByGL-using namespace std;-//-----------------------------------------------------------------------------/*DV_EXPORT_API void mylog(std::string s)@@ -75,7 +73,7 @@ bool checkQuadraticDistance(TStroke *stroke, bool checkThickness) {const TThickQuadratic *q;TThickPoint p1, p2, p3;- // se i punti coincidono e' una stroke puntiforme ed e' ammessa+ // if the points coincide it's a point-like stroke and it's allowedif (qCount == 1) return true;for (i = 0; i != qCount; i++) {@@ -258,11 +256,10 @@ void tglDraw(const TVectorRenderData &rd, TRegion *r, bool pushAttribs) {int colorCount = 0;TColorStyleP style;- if (rd.m_paintCheckEnabled && r->getStyle() == rd.m_colorCheckIndex) {- static TSolidColorStyle *redColor = new TSolidColorStyle();- redColor->addRef();- redColor->setMainColor(TPixel::Red);- style = redColor;+ if (rd.m_paintCheckEnabled && r->getStyle() == rd.m_paintIndex) {+ TSolidColorStyle *colorStyle = new TSolidColorStyle();+ colorStyle->setMainColor(rd.m_paintCheckColor);+ style = colorStyle;} else if (rd.m_tcheckEnabled) {static TSolidColorStyle *color = new TSolidColorStyle();color->addRef();@@ -284,7 +281,7 @@ void tglDraw(const TVectorRenderData &rd, TRegion *r, bool pushAttribs) {}if (visible) {TRegionProp *prop = r->getProp(/*rd.m_palette*/);- /// questo codice satva dentro tregion::getprop/////+ /// this code was inside tregion::getprop/////int styleId = r->getStyle();if (styleId) {// TColorStyle * style = rd.m_palette->getStyle(styleId);@@ -304,7 +301,7 @@ void tglDraw(const TVectorRenderData &rd, TRegion *r, bool pushAttribs) {if (pushAttribs) glPushAttrib(GL_ALL_ATTRIB_BITS);tglEnableLineSmooth(true);-//#define DRAW_EDGE_NUMBERS+// #define DRAW_EDGE_NUMBERS#ifdef DRAW_EDGE_NUMBERSglPushMatrix();tglMultMatrix(rd.m_aff);@@ -389,7 +386,7 @@ void tglDraw(const TVectorRenderData &rd, TRegion *r, bool pushAttribs) {glColorMask(red, green, blue, alpha);} else {- // pezza: in render, le aree fillate dei custom styles sparivano.+ // workaround: in render, the filled areas of custom styles disappeared.if (!rd.m_isOfflineRender || !rd.m_isImagePattern)tglRgbOnlyColorMask(); // RGB components only@@ -448,17 +445,13 @@ void tglDraw(const TVectorRenderData &rd, const TStroke *s, bool pushAttribs) {TColorStyleP style;TStroke *stroke = const_cast<TStroke *>(s);if (rd.m_inkCheckEnabled && s->getStyle() == rd.m_colorCheckIndex) {- static TSolidColorStyle *redColor = new TSolidColorStyle();- redColor->addRef();- redColor->setMainColor(TPixel::Red);- style = redColor;+ TSolidColorStyle *colorStyle = new TSolidColorStyle();+ colorStyle->setMainColor(rd.m_inkCheckColor);+ style = colorStyle;} else if (rd.m_ink1CheckEnabled && s->getStyle() == 1) {- // Ink #1 Check.- // Could possibly merge with above.- static TSolidColorStyle *redColor = new TSolidColorStyle();- redColor->addRef();- redColor->setMainColor(TPixel::Red);- style = redColor;+ TSolidColorStyle *colorStyle = new TSolidColorStyle();+ colorStyle->setMainColor(rd.m_ink1CheckColor);+ style = colorStyle;} else if (rd.m_tcheckEnabled) {static TSolidColorStyle *color = new TSolidColorStyle();color->addRef();@@ -474,12 +467,12 @@ void tglDraw(const TVectorRenderData &rd, const TStroke *s, bool pushAttribs) {&& !rd.m_tcheckEnabled) // I wonder why this?return;- // const TStroke& stroke = *s; //serve???+ // const TStroke& stroke = *s; // is it needed?assert(rd.m_palette);prop = s->getProp(/*rd.m_palette*/);- /////questo codice stava dentro tstroke::getprop/////////+ /////this code was inside tstroke::getprop/////////if (prop) prop->getMutex()->lock();if (!style->isStrokeStyle() || style->isEnabled() == false) {@@ -508,8 +501,8 @@ void tglDraw(const TVectorRenderData &rd, const TStroke *s, bool pushAttribs) {bool alphaChannel = rd.m_alphaChannel, antialias = rd.m_antiAliasing;TVectorImagePatternStrokeProp *aux =dynamic_cast<TVectorImagePatternStrokeProp *>(prop);- if (aux) // gli image pattern vettoriali tornano in questa funzione....non- // facendo il corpo dell'else'si evita di disegnarli due volte!+ if (aux) // the vector image patterns return to this function....by not+ // executing the else body, we avoid drawing them twice!prop->draw(rd);else {if (antialias)@@ -642,15 +635,13 @@ void doDraw(const TVectorImage *vim, const TVectorRenderData &_rd,TVectorRenderData rdRegions = rd;- /*if (rd.m_drawRegions && rd.m_isImagePattern)//gli image pattern hanno-bisogno dell'antialiasig per le linee, ma sulle aree ci sarebbero un sacco di-assert+ /*if (rd.m_drawRegions && rd.m_isImagePattern)// the image patterns need+antialiasing for lines, but on the areas there would be a lot of assertsrdRegions.m_alphaChannel = rdRegions.m_antiAliasing = false;*/UINT strokeIndex = 0;Index = 0;- while (strokeIndex <- vim->getStrokeCount()) // ogni ciclo di while disegna un gruppo+ while (strokeIndex < vim->getStrokeCount()) // each while loop draws a group{int currStrokeIndex = strokeIndex;if (!rd.m_isIcon && vim->isInsideGroup() > 0 &&@@ -720,6 +711,3 @@ void tglDraw(const TVectorRenderData &rd, const TVectorImage *vim,checkErrorsByGL;// mylog("tglDraw stop");}--//------------------------------------------------------------------------------//-----------------------------------------------------------------------------diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.hindex afdb16eb5..ea7860cb2 100644--- a/toonz/sources/include/toonz/preferences.h+++ b/toonz/sources/include/toonz/preferences.h@@ -511,6 +511,10 @@ public:ink = getColorValue(transpCheckInkOnWhite);paint = getColorValue(transpCheckPaint);}+ // Returns the configured colors used for Ink and Paint check operations+ TPixel getInkCheckColor() const { return getColorValue(inkCheckColor); }+ TPixel getInk1CheckColor() const { return getColorValue(ink1CheckColor); }+ TPixel getPaintCheckColor() const { return getColorValue(paintCheckColor); }// Version Control tabbool isSVNEnabled() const { return getBoolValue(SVNEnabled); }diff --git a/toonz/sources/include/toonz/preferencesitemids.h b/toonz/sources/include/toonz/preferencesitemids.hindex dfea7896f..a71ac5138 100644--- a/toonz/sources/include/toonz/preferencesitemids.h+++ b/toonz/sources/include/toonz/preferencesitemids.h@@ -192,6 +192,9 @@ enum PreferencesItemId {transpCheckInkOnWhite,transpCheckInkOnBlack,transpCheckPaint,+ inkCheckColor,+ ink1CheckColor,+ paintCheckColor,//----------// Version Controldiff --git a/toonz/sources/include/toonzqt/icongenerator.h b/toonz/sources/include/toonzqt/icongenerator.hindex 1ca7aa3ef..c7834fdd8 100644--- a/toonz/sources/include/toonzqt/icongenerator.h+++ b/toonz/sources/include/toonzqt/icongenerator.h@@ -74,13 +74,19 @@ public:bool m_inksOnly;int m_inkIndex;int m_paintIndex;+ bool m_inkCheckEnabled;+ bool m_ink1CheckEnabled;+ bool m_paintCheckEnabled;Settings(): m_transparencyCheck(false), m_blackBgCheck(false), m_inksOnly(false), m_inkIndex(-1)- , m_paintIndex(-1) {}+ , m_paintIndex(-1)+ , m_inkCheckEnabled(false)+ , m_ink1CheckEnabled(false)+ , m_paintCheckEnabled(false) {}};public:diff --git a/toonz/sources/include/trop.h b/toonz/sources/include/trop.hindex 23c0f0264..2c6760624 100644--- a/toonz/sources/include/trop.h+++ b/toonz/sources/include/trop.h@@ -184,6 +184,14 @@ public:bool m_inksOnly, m_transparencyCheck, m_blackBgCheck, m_isOnionSkin;int m_gapCheckIndex = -1;+ bool m_inkCheckEnabled;+ bool m_ink1CheckEnabled;+ bool m_paintCheckEnabled;++ TPixel m_inkCheckColor;+ TPixel m_ink1CheckColor;+ TPixel m_paintCheckColor;+CmappedQuickputSettings(): m_globalColorScale(TPixel32::Black), m_inksOnly(false)@@ -192,7 +200,13 @@ public:, m_isOnionSkin(false), m_gapCheckIndex(-1), m_inkIndex(-1)- , m_paintIndex(-1) {}+ , m_paintIndex(-1)+ , m_inkCheckEnabled(false)+ , m_ink1CheckEnabled(false)+ , m_paintCheckEnabled(false)+ , m_inkCheckColor(TPixel::Red)+ , m_ink1CheckColor(TPixel::Red)+ , m_paintCheckColor(TPixel::Red) {}};DVAPI void quickPut(const TRasterP &dn, const TRasterCM32P &upCM32,diff --git a/toonz/sources/include/tvectorrenderdata.h b/toonz/sources/include/tvectorrenderdata.hindex 457d900ee..d74420804 100644--- a/toonz/sources/include/tvectorrenderdata.h+++ b/toonz/sources/include/tvectorrenderdata.h@@ -59,11 +59,15 @@ public://! restricted on;//! if empty, clipping is assumed to be disabled.//! \internal Coordinates reference?- TPixel m_tCheckInk; //!< Color to be used for <I>ink check</I> mode.- TPixel m_tCheckPaint; //!< Color to be used for <I>paint check</I> mode.-- int m_colorCheckIndex; //!< Color index to be highlighted in <I>color- //! check</I> mode.+ TPixel m_tCheckInk; //!< Color to be used for <I>ink check</I> mode.+ TPixel m_tCheckPaint; //!< Color to be used for <I>paint check</I> mode.+ TPixel m_inkCheckColor; //!< ^ <I>Ink check</I> mode.+ TPixel m_ink1CheckColor; //!< ^ <I>Ink1 check</I> mode.+ TPixel m_paintCheckColor; //!< ^ <I>Paint check</I> mode.+ int m_colorCheckIndex; //!< Color index to be highlighted in <I>color+ //! check</I> mode.+ int m_paintIndex; //!< Color index to be highlighted in <I>paint check</I>+ //!< mode.int m_indexToHighlight; // for guided vector drawingbool m_alphaChannel, //!< Whether alpha channel is enabled.@@ -100,7 +104,11 @@ public:, m_clippingRect(clippingRect), m_tCheckInk(TPixel::Black), m_tCheckPaint(TPixel(128, 128, 128))+ , m_inkCheckColor(TPixel::Red)+ , m_ink1CheckColor(TPixel::Red)+ , m_paintCheckColor(TPixel::Red), m_colorCheckIndex(-1)+ , m_paintIndex(-1), m_alphaChannel(false) // Camera stand-like widgets have opaque background, m_antiAliasing(@@ -135,6 +143,7 @@ public:, m_tCheckInk(TPixel::Black), m_tCheckPaint(TPixel(128, 128, 128)), m_colorCheckIndex(-1)+ , m_paintIndex(-1), m_alphaChannel(true) // No opaque background - freestanding images with alpha, m_antiAliasing(true) // Jaggy-free pretty images@@ -165,7 +174,11 @@ public:, m_clippingRect(clippingRect), m_tCheckInk(other.m_tCheckInk), m_tCheckPaint(other.m_tCheckPaint)+ , m_inkCheckColor(other.m_inkCheckColor)+ , m_ink1CheckColor(other.m_ink1CheckColor)+ , m_paintCheckColor(other.m_paintCheckColor), m_colorCheckIndex(other.m_colorCheckIndex)+ , m_paintIndex(other.m_paintIndex), m_alphaChannel(other.m_alphaChannel), m_antiAliasing(other.m_antiAliasing), m_isImagePattern(other.m_isImagePattern)@@ -197,7 +210,11 @@ public:, m_clippingRect(clippingRect), m_tCheckInk(TPixel::Black), m_tCheckPaint(TPixel(128, 128, 128))+ , m_inkCheckColor(TPixel::Red)+ , m_ink1CheckColor(TPixel::Red)+ , m_paintCheckColor(TPixel::Red), m_colorCheckIndex(-1)+ , m_paintIndex(-1), m_alphaChannel(alphaChannel), m_antiAliasing(antiAliasing), m_isImagePattern(false)diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cppindex 3eb026755..b25d623e1 100644--- a/toonz/sources/toonz/preferencespopup.cpp+++ b/toonz/sources/toonz/preferencespopup.cpp@@ -1406,6 +1406,9 @@ QString PreferencesPopup::getUIString(PreferencesItemId id) {{transpCheckInkOnWhite, tr("Ink Color on White BG:")},{transpCheckInkOnBlack, tr("Ink Color on Black BG:")},{transpCheckPaint, tr("Paint Color:")},+ {inkCheckColor, tr("Ink Check Color:")},+ {ink1CheckColor, tr("Ink#1 Check Color:")},+ {paintCheckColor, tr("Paint Check Color:")},// Version Control{SVNEnabled, tr("Enable Version Control*")},@@ -2333,6 +2336,14 @@ QWidget* PreferencesPopup::createColorsPage() {insertUI(transpCheckInkOnBlack, tcLay);insertUI(transpCheckPaint, tcLay);}++ QGridLayout* ipcLay = insertGroupBox(tr("Ink and Paint Check"), lay);+ {+ insertUI(inkCheckColor, ipcLay);+ insertUI(ink1CheckColor, ipcLay);+ insertUI(paintCheckColor, ipcLay);+ }+lay->setRowStretch(lay->rowCount(), 1);widget->setLayout(lay);@@ -2351,6 +2362,12 @@ QWidget* PreferencesPopup::createColorsPage() {m_onEditedFuncMap.insert(chessboardColor2,&PreferencesPopup::onChessboardChanged);+ m_onEditedFuncMap.insert(inkCheckColor,+ &PreferencesPopup::onTranspCheckDataChanged);+ m_onEditedFuncMap.insert(ink1CheckColor,+ &PreferencesPopup::onTranspCheckDataChanged);+ m_onEditedFuncMap.insert(paintCheckColor,+ &PreferencesPopup::onTranspCheckDataChanged);return widget;}diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cppindex 4826fbd11..5c13799e6 100644--- a/toonz/sources/toonz/sceneviewer.cpp+++ b/toonz/sources/toonz/sceneviewer.cpp@@ -1,4 +1,3 @@-#if defined(LINUX) || defined(FREEBSD) || defined(HAIKU)#define GL_GLEXT_PROTOTYPES#endif@@ -186,7 +185,7 @@ void copyFrontBufferToBackBuffer() {glReadBuffer(GL_BACK);}//------------------------------------------------------------------------------/*! Compute new 3Dposition and new 2D position. */+/*! Compute new 3D position and new 2D position. */T3DPointD computeNew3DPosition(T3DPointD start3DPos, TPointD delta2D,TPointD &new2dPos, GLdouble modelView3D[16],GLdouble projection3D[16], GLint viewport3D[4],@@ -205,13 +204,12 @@ T3DPointD computeNew3DPosition(T3DPointD start3DPos, TPointD delta2D,//-----------------------------------------------------------------------------#ifdef DA_RIVEDERE-// Il metodo copia una porzione del BACK_BUFFER definita da rect nel-// FRONTE_BUFFER-// Attualmente si notano delle brutture intorno al rettangolo.-// Per il momento si lavora nel BACK_BUFFER e sicopia tutto il FRONT_BUFFER.-// Riattivando questo metodo bisogna ricordarsi di disattivare lo swapbuffer in-// GLInvalidateRect prima di-// fare updateGL() e riattivarlo immediatamernte dopo!+// The method copies a portion of the BACK_BUFFER defined by rect into the+// FRONT_BUFFER. Currently there are some artifacts around the rectangle.+// For the moment we work in the BACK_BUFFER and copy the entire FRONT_BUFFER.+// If reactivating this method, remember to disable swapbuffer in+// GLInvalidateRect before calling updateGL() and reactivate it immediately+// after!void copyBackBufferToFrontBuffer(const TRect &rect) {static GLint viewport[4];static GLfloat raster_pos[4];@@ -299,6 +297,11 @@ void invalidateIcons() {s.m_blackBgCheck = mask & ToonzCheck::eBlackBg;s.m_transparencyCheck = mask & ToonzCheck::eTransparency;s.m_inksOnly = mask & ToonzCheck::eInksOnly;++ s.m_inkCheckEnabled = (mask & ToonzCheck::eInk) != 0;+ s.m_ink1CheckEnabled = (mask & ToonzCheck::eInk1) != 0;+ s.m_paintCheckEnabled = (mask & ToonzCheck::ePaint) != 0;+// emphasize lines with style#1 regardless of the current styleif (mask & ToonzCheck::eInk1) s.m_inkIndex = 1;// emphasize lines with the current style@@ -311,12 +314,12 @@ void invalidateIcons() {// Force icons to refresh for Toonz Vector levelsTXshLevel *sl = TApp::instance()->getCurrentLevel()->getLevel();- if (sl && sl->getType() == PLI_XSHLEVEL) {+ if (sl) {std::vector<TFrameId> fids;sl->getFids(fids);-- for (int i = 0; i < (int)fids.size(); i++)- IconGenerator::instance()->invalidate(sl, fids[i]);+ for (const auto &fid : fids) {+ IconGenerator::instance()->invalidate(sl, fid);+ }}// Do not remove icons here as they will be re-used for updating icons in the@@ -391,8 +394,7 @@ public:} tinksOnlyToggle;//------------------------------------------------------------------------------/*! emphasize lines with style#1 regardless of the current style- */+/*! emphasize lines with style#1 regardless of the current style */class Ink1CheckToggleCommand final : public MenuItemHandler {public:Ink1CheckToggleCommand() : MenuItemHandler("MI_Ink1Check") {}@@ -883,9 +885,9 @@ SceneViewer::~SceneViewer() {if (m_fbo) delete m_fbo;// release all the registered context (once when exit the software)- std::set<TGlContext>::iterator ct, cEnd(l_contexts.end());- for (ct = l_contexts.begin(); ct != cEnd; ++ct)- TGLDisplayListsManager::instance()->releaseContext(*ct);+ for (const auto &ctx : l_contexts) {+ TGLDisplayListsManager::instance()->releaseContext(ctx);+ }l_contexts.clear();}@@ -1034,8 +1036,8 @@ void SceneViewer::enablePreview(int previewMode) {//-----------------------------------------------------------------------------TPointD SceneViewer::winToWorld(const QPointF &pos) const {- // coordinate window (origine in alto a sinistra) -> coordinate colonna- // (origine al centro dell'immagine)+ // window coordinate (origin top-left) -> column coordinate (origin at image+ // center)TPointD pp(pos.x() - (double)width() / 2.0,-pos.y() + (double)height() / 2.0);if (is3DView()) {@@ -1052,9 +1054,9 @@ TPointD SceneViewer::winToWorld(const QPointF &pos) const {double sn_phi = sin(phi);double cs_theta = cos(theta);double sn_theta = sin(theta);- TPointD a(cs_phi, sn_theta * sn_phi); // proiezione di (1,0,0)- TPointD b(0, cs_theta); // proiezione di (0,1,0)- TPointD c(sn_phi, -sn_theta * cs_phi); // proiezione di (0,0,1)+ TPointD a(cs_phi, sn_theta * sn_phi); // projection of (1,0,0)+ TPointD b(0, cs_theta); // projection of (0,1,0)+ TPointD c(sn_phi, -sn_theta * cs_phi); // projection of (0,0,1)TPointD aa = rotate90(a);TPointD bb = rotate90(b);@@ -1098,63 +1100,60 @@ void SceneViewer::showEvent(QShowEvent *) {TApp *app = TApp::instance();TSceneHandle *sceneHandle = app->getCurrentScene();- bool ret = connect(sceneHandle, SIGNAL(sceneSwitched()), this,- SLOT(resetSceneViewer()));- ret = ret && connect(sceneHandle, SIGNAL(sceneChanged()), this,- SLOT(onSceneChanged()));- ret = ret && connect(sceneHandle, SIGNAL(preferenceChanged(const QString &)),- this, SLOT(onPreferenceChanged(const QString &)));+ connect(sceneHandle, &TSceneHandle::sceneSwitched, this,+ &SceneViewer::resetSceneViewer);+ connect(sceneHandle, &TSceneHandle::sceneChanged, this,+ &SceneViewer::onSceneChanged);+ connect(sceneHandle, &TSceneHandle::preferenceChanged, this,+ &SceneViewer::onPreferenceChanged);TFrameHandle *frameHandle = app->getCurrentFrame();- ret = ret && connect(frameHandle, SIGNAL(frameSwitched()), this,- SLOT(onFrameSwitched()));+ connect(frameHandle, &TFrameHandle::frameSwitched, this,+ &SceneViewer::onFrameSwitched);TPaletteHandle *paletteHandle =app->getPaletteController()->getCurrentLevelPalette();- ret = ret && connect(paletteHandle, SIGNAL(colorStyleChanged(bool)), this,- SLOT(update()));-- ret = ret && connect(app->getCurrentObject(), SIGNAL(objectSwitched()), this,- SLOT(onObjectSwitched()));- ret = ret && connect(app->getCurrentObject(), SIGNAL(objectChanged(bool)),- this, SLOT(update()));-- ret =- ret && connect(app->getCurrentOnionSkin(), SIGNAL(onionSkinMaskChanged()),- this, SLOT(onOnionSkinMaskChanged()));-- ret = ret && connect(app->getCurrentLevel(), SIGNAL(xshLevelChanged()), this,- SLOT(update()));- ret = ret && connect(app->getCurrentLevel(), SIGNAL(xshCanvasSizeChanged()),- this, SLOT(update()));+ connect(paletteHandle, &TPaletteHandle::colorStyleChanged, this,+ [this](bool) { update(); });++ connect(app->getCurrentObject(), &TObjectHandle::objectSwitched, this,+ &SceneViewer::onObjectSwitched);+ connect(app->getCurrentObject(), &TObjectHandle::objectChanged, this,+ [this](bool) { update(); });++ connect(app->getCurrentOnionSkin(),+ &TOnionSkinMaskHandle::onionSkinMaskChanged, this,+ &SceneViewer::onOnionSkinMaskChanged);++ connect(app->getCurrentLevel(), &TXshLevelHandle::xshLevelChanged, this,+ [this] { update(); });+ connect(app->getCurrentLevel(), &TXshLevelHandle::xshCanvasSizeChanged, this,+ [this] { update(); });// when level is switched, update m_dpiScale in order to show white background// for Ink&Paint work properly- ret = ret &&- connect(app->getCurrentLevel(), SIGNAL(xshLevelSwitched(TXshLevel *)),- this, SLOT(onLevelSwitched()));+ connect(app->getCurrentLevel(), &TXshLevelHandle::xshLevelSwitched, this,+ [this](TXshLevel *) { onLevelSwitched(); });- ret = ret && connect(app->getCurrentXsheet(), SIGNAL(xsheetChanged()), this,- SLOT(onXsheetChanged()));- ret = ret && connect(app->getCurrentXsheet(), SIGNAL(xsheetSwitched()), this,- SLOT(update()));+ connect(app->getCurrentXsheet(), &TXsheetHandle::xsheetChanged, this,+ &SceneViewer::onXsheetChanged);+ connect(app->getCurrentXsheet(), &TXsheetHandle::xsheetSwitched, this,+ [this] { update(); });// update tooltip when tool options are changed- ret = ret && connect(app->getCurrentTool(), SIGNAL(toolChanged()), this,- SLOT(onToolChanged()));- ret = ret && connect(app->getCurrentTool(), SIGNAL(toolCursorTypeChanged()),- this, SLOT(onToolChanged()));+ connect(app->getCurrentTool(), &ToolHandle::toolChanged, this,+ &SceneViewer::onToolChanged);+ connect(app->getCurrentTool(), &ToolHandle::toolCursorTypeChanged, this,+ &SceneViewer::onToolChanged);- ret = ret &&- connect(app, SIGNAL(tabletLeft()), this, SLOT(resetTabletStatus()));+ connect(app, &TApp::tabletLeft, this, &SceneViewer::resetTabletStatus);#if defined(x64)if (m_stopMotion) {- ret = ret && connect(m_stopMotion, SIGNAL(newLiveViewImageReady()), this,- SLOT(onNewStopMotionImageReady()));- ret = ret && connect(m_stopMotion, SIGNAL(liveViewStopped()), this,- SLOT(onStopMotionLiveViewStopped()));+ connect(m_stopMotion, &StopMotion::newLiveViewImageReady, this,+ &SceneViewer::onNewStopMotionImageReady);+ connect(m_stopMotion, &StopMotion::liveViewStopped, this,+ &SceneViewer::onStopMotionLiveViewStopped);}#endif- assert(ret);if (m_hRuler && m_vRuler) {if (!viewRulerToggle.getStatus()) {@@ -1211,14 +1210,14 @@ void SceneViewer::hideEvent(QHideEvent *) {ToolHandle *toolHandle = app->getCurrentTool();if (toolHandle) toolHandle->disconnect(this);- disconnect(app, SIGNAL(tabletLeft()), this, SLOT(resetTabletStatus()));+ disconnect(app, &TApp::tabletLeft, this, &SceneViewer::resetTabletStatus);#if defined(x64)if (m_stopMotion) {- disconnect(m_stopMotion, SIGNAL(newImageReady()), this,- SLOT(onNewStopMotionImageReady()));- disconnect(m_stopMotion, SIGNAL(liveViewStopped()), this,- SLOT(onStopMotionLiveViewStopped()));+ disconnect(m_stopMotion, &StopMotion::newLiveViewImageReady, this,+ &SceneViewer::onNewStopMotionImageReady);+ disconnect(m_stopMotion, &StopMotion::liveViewStopped, this,+ &SceneViewer::onStopMotionLiveViewStopped);}#endif}@@ -1287,8 +1286,8 @@ void SceneViewer::onPreferenceChanged(const QString &prefName) {elsem_lutCalibrator->cleanup();m_lutCalibrator->initialize();- connect(context(), SIGNAL(aboutToBeDestroyed()), this,- SLOT(onContextAboutToBeDestroyed()));+ connect(context(), &QOpenGLContext::aboutToBeDestroyed, this,+ &SceneViewer::onContextAboutToBeDestroyed);if (m_lutCalibrator->isValid() && !m_fbo) {if (Preferences::instance()->is30bitDisplayEnabled()) {QOpenGLFramebufferObjectFormat format;@@ -1312,8 +1311,8 @@ void SceneViewer::initializeGL() {// to be computed once through the softwareif (m_lutCalibrator && !m_lutCalibrator->isInitialized()) {m_lutCalibrator->initialize();- connect(context(), SIGNAL(aboutToBeDestroyed()), this,- SLOT(onContextAboutToBeDestroyed()));+ connect(context(), &QOpenGLContext::aboutToBeDestroyed, this,+ &SceneViewer::onContextAboutToBeDestroyed);}// glClearColor(1.0,1.0,1.0,1);@@ -1456,8 +1455,8 @@ void SceneViewer::drawBackground() {glClear(GL_COLOR_BUFFER_BIT);if (glGetError() == GL_INVALID_FRAMEBUFFER_OPERATION) {- /* 起動時一回目になぜか GL_FRAMEBUFFER_COMPLETE なのに invalid operation- * が出る */+ /* At first startup, for some reason we get invalid operation even though+ GL_FRAMEBUFFER_COMPLETE */GLenum status = 0;#ifdef _WIN32PROC proc = wglGetProcAddress("glCheckFramebufferStatusEXT");@@ -2008,14 +2007,15 @@ static void drawFpsGraph(int t0, int t1) {glVertex2d(x0, y);glVertex2d(x1, y);}- for (int i = 0; i < (int)times.size(); i++) {- double x = x1 - i;+ int i = 0;+ for (const auto &time : times) {+ double x = x1 - i++;glColor3d(1, 0, 0);glVertex2d(x, y0);- glVertex2d(x, y0 + 5 + times[i].first / 5);+ glVertex2d(x, y0 + 5 + time.first / 5);glColor3d(0, 1, 0);- glVertex2d(x, y0 + 5 + times[i].first / 5);- glVertex2d(x, y0 + 5 + times[i].second / 5);+ glVertex2d(x, y0 + 5 + time.first / 5);+ glVertex2d(x, y0 + 5 + time.second / 5);}glEnd();glPopMatrix();@@ -2028,8 +2028,8 @@ static void drawFpsGraph(int t0, int t1) {void SceneViewer::paintGL() {#ifdef _DEBUGif (!check_framebuffer_status()) {- /* QGLWidget の widget 生成/削除のタイミングで(platform によって?)- * GL_FRAMEBUFFER_UNDEFINED の状態で paintGL() が呼ばれてしまうようだ */+ /* QGLWidget's widget creation/destruction timing (depending on platform?)+ * seems to call paintGL() with GL_FRAMEBUFFER_UNDEFINED */return;}#endif@@ -2066,7 +2066,7 @@ void SceneViewer::paintGL() {}}- // Il freezed e' attivo ed e' in stato "normale": mostro l'immagine grabbata.+ // Freeze is active and in 'normal' state: show the grabbed image.if (m_freezedStatus == NORMAL_FREEZED) {assert(!!m_viewGrabImage);m_viewGrabImage->lock();@@ -2110,7 +2110,7 @@ void SceneViewer::paintGL() {drawViewerIndicators();- // Il freezed e' attivo ed e' in stato "update": faccio il grab del viewer.+ // Freeze is active and in 'update' state: grab the viewer.if (m_freezedStatus == UPDATE_FREEZED) {m_viewGrabImage = rasterFromQImage(grabFramebuffer());m_freezedStatus = NORMAL_FREEZED;@@ -2192,7 +2192,7 @@ void SceneViewer::drawScene() {m_minZ = painter.getMinZ();} else {- // camera 2D (normale)+ // camera 2D (normal)TDimension viewerSize(width(), height());TAffine viewAff = getViewMatrix();@@ -2330,8 +2330,8 @@ void SceneViewer::drawScene() {// gather animated guide strokes' bounding boxes// it is used for updating viewer next timestd::vector<TStroke *> guidedStrokes = painter.getGuidedStrokes();- for (auto itr = guidedStrokes.begin(); itr != guidedStrokes.end(); ++itr) {- m_guidedDrawingBBox += (*itr)->getBBox();+ for (auto stroke : guidedStrokes) {+ m_guidedDrawingBBox += stroke->getBBox();}}}@@ -2988,13 +2988,13 @@ void SceneViewer::resetSceneViewer() {m_rotationAngle[i] = 0.0;}- m_pos = QPoint(0, 0);- m_pan3D = TPointD(0, 0);-- m_theta3D = 20;- m_phi3D = 30;- m_isFlippedX = false;- m_isFlippedY = false;+ m_pos = QPoint(0, 0);+ m_pan3D = TPointD(0, 0);++ m_theta3D = 20;+ m_phi3D = 30;+ m_isFlippedX = false;+ m_isFlippedY = false;fitToCameraOutline();m_zoomScale3D = 1.0;emit onZoomChanged();@@ -3186,7 +3186,7 @@ int SceneViewer::pick(const TPointD &point) {glSelectBuffer(selectBuffer.size(), selectBuffer.data());glRenderMode(GL_SELECT);- // definisco la matrice di proiezione+ // set the projection matrixglMatrixMode(GL_PROJECTION);GLdouble mat[16];glGetDoublev(GL_PROJECTION_MATRIX, mat);@@ -3196,7 +3196,7 @@ int SceneViewer::pick(const TPointD &point) {glMultMatrixd(mat);assert(glGetError() == GL_NO_ERROR);- // disegno la scena+ // draw the sceneglMatrixMode(GL_MODELVIEW);glPushMatrix();glInitNames();@@ -3232,14 +3232,14 @@ int SceneViewer::pick(const TPointD &point) {assert(glGetError() == GL_NO_ERROR);glPopMatrix();- // rimetto a posto la matrice di proiezione+ // restore the projection matrixglMatrixMode(GL_PROJECTION);glPopMatrix();glMatrixMode(GL_MODELVIEW);assert(glGetError() == GL_NO_ERROR);- // conto gli hits+ // count hitsint ret = -1;int hitCount = glRenderMode(GL_RENDER);GLuint *p = selectBuffer.data();@@ -3560,8 +3560,8 @@ void SceneViewer::onContextAboutToBeDestroyed() {makeCurrent();m_lutCalibrator->cleanup();doneCurrent();- disconnect(context(), SIGNAL(aboutToBeDestroyed()), this,- SLOT(onContextAboutToBeDestroyed()));+ disconnect(context(), &QOpenGLContext::aboutToBeDestroyed, this,+ &SceneViewer::onContextAboutToBeDestroyed);}//-----------------------------------------------------------------------------diff --git a/toonz/sources/toonz/tapp.cpp b/toonz/sources/toonz/tapp.cppindex 2a6451b69..8f7f14798 100644--- a/toonz/sources/toonz/tapp.cpp+++ b/toonz/sources/toonz/tapp.cpp@@ -52,6 +52,7 @@#include "trasterimage.h"#include "tunit.h"#include "tsystem.h"+#include "sceneviewer.h"// Qt includes#include <QTimer>@@ -120,76 +121,51 @@ TApp::TApp()m_paletteController = new PaletteController();- bool ret = true;-- ret = ret && QObject::connect(m_currentXsheet, SIGNAL(xsheetChanged()), this,- SLOT(onXsheetChanged()));-- ret = ret && QObject::connect(m_currentXsheet, SIGNAL(xsheetSoundChanged()),- this, SLOT(onXsheetSoundChanged()));-- ret = ret && QObject::connect(m_currentScene, SIGNAL(sceneSwitched()), this,- SLOT(onSceneSwitched()));-- ret = ret && QObject::connect(m_currentScene, SIGNAL(sceneChanged()), this,- SLOT(onSceneChanged()));-- ret = ret && QObject::connect(m_currentXsheet, SIGNAL(xsheetSwitched()), this,- SLOT(onXsheetSwitched()));-- ret = ret && QObject::connect(m_currentFrame, SIGNAL(frameSwitched()), this,- SLOT(onFrameSwitched()));-- ret = ret && QObject::connect(m_currentFrame, SIGNAL(frameSwitched()), this,- SLOT(onImageChanged()));-- ret = ret && QObject::connect(m_currentFx, SIGNAL(fxSwitched()), this,- SLOT(onFxSwitched()));-- ret = ret && QObject::connect(m_currentColumn, SIGNAL(columnIndexSwitched()),- this, SLOT(onColumnIndexSwitched()));-- ret = ret && QObject::connect(m_currentColumn, SIGNAL(columnIndexSwitched()),- this, SLOT(onImageChanged()));-- ret = ret &&- QObject::connect(m_currentLevel, SIGNAL(xshLevelSwitched(TXshLevel *)),- this, SLOT(onImageChanged()));-- ret = ret &&- QObject::connect(m_currentLevel, SIGNAL(xshLevelSwitched(TXshLevel *)),- this, SLOT(onXshLevelSwitched(TXshLevel *)));-- ret = ret && QObject::connect(m_currentLevel, SIGNAL(xshLevelChanged()), this,- SLOT(onXshLevelChanged()));-- ret = ret && QObject::connect(m_currentObject, SIGNAL(objectSwitched()), this,- SLOT(onObjectSwitched()));-- ret = ret && QObject::connect(m_currentObject, SIGNAL(splineChanged()), this,- SLOT(onSplineChanged()));-- ret = ret && QObject::connect(m_paletteController->getCurrentLevelPalette(),- SIGNAL(paletteChanged()), this,- SLOT(onPaletteChanged()));-- ret = ret && QObject::connect(m_paletteController->getCurrentLevelPalette(),- SIGNAL(colorStyleSwitched()), this,- SLOT(onLevelColorStyleSwitched()));-- ret = ret && QObject::connect(m_paletteController->getCurrentLevelPalette(),- SIGNAL(colorStyleChangedOnMouseRelease()), this,- SLOT(onLevelColorStyleChanged()));-- ret = ret && QObject::connect(m_paletteController->getCurrentCleanupPalette(),- SIGNAL(paletteChanged()), m_currentScene,- SIGNAL(sceneChanged()));+ connect(m_currentXsheet, &TXsheetHandle::xsheetChanged, this,+ &TApp::onXsheetChanged);+ connect(m_currentXsheet, &TXsheetHandle::xsheetSoundChanged, this,+ &TApp::onXsheetSoundChanged);+ connect(m_currentScene, &TSceneHandle::sceneSwitched, this,+ &TApp::onSceneSwitched);+ connect(m_currentScene, &TSceneHandle::sceneChanged, this,+ &TApp::onSceneChanged);+ connect(m_currentXsheet, &TXsheetHandle::xsheetSwitched, this,+ &TApp::onXsheetSwitched);+ connect(m_currentFrame, &TFrameHandle::frameSwitched, this,+ &TApp::onFrameSwitched);+ connect(m_currentFrame, &TFrameHandle::frameSwitched, this,+ &TApp::onImageChanged);+ connect(m_currentFx, &TFxHandle::fxSwitched, this, &TApp::onFxSwitched);+ connect(m_currentColumn, &TColumnHandle::columnIndexSwitched, this,+ &TApp::onColumnIndexSwitched);+ connect(m_currentColumn, &TColumnHandle::columnIndexSwitched, this,+ &TApp::onImageChanged);+ connect(m_currentLevel, &TXshLevelHandle::xshLevelSwitched, this,+ &TApp::onImageChanged);+ connect(m_currentLevel, &TXshLevelHandle::xshLevelSwitched, this,+ &TApp::onXshLevelSwitched);+ connect(m_currentLevel, &TXshLevelHandle::xshLevelChanged, this,+ &TApp::onXshLevelChanged);+ connect(m_currentObject, &TObjectHandle::objectSwitched, this,+ &TApp::onObjectSwitched);+ connect(m_currentObject, &TObjectHandle::splineChanged, this,+ &TApp::onSplineChanged);+ connect(m_paletteController->getCurrentLevelPalette(),+ &TPaletteHandle::paletteChanged, this, &TApp::onPaletteChanged);+ connect(m_paletteController->getCurrentLevelPalette(),+ &TPaletteHandle::colorStyleSwitched, this,+ &TApp::onLevelColorStyleSwitched);+ connect(m_paletteController->getCurrentLevelPalette(),+ &TPaletteHandle::colorStyleChangedOnMouseRelease, this,+ &TApp::onLevelColorStyleChanged);+ connect(m_paletteController->getCurrentCleanupPalette(),+ &TPaletteHandle::paletteChanged, m_currentScene,+ &TSceneHandle::sceneChanged);TMeasureManager::instance()->addCameraMeasures(getCurrentCameraSize);m_autosaveTimer = new QTimer(this);- ret = ret &&- connect(m_autosaveTimer, SIGNAL(timeout()), this, SLOT(autosave()));+ connect(m_autosaveTimer, &QTimer::timeout, this, &TApp::autosave);Preferences *preferences = Preferences::instance();@@ -198,18 +174,16 @@ TApp::TApp()(int)(/*15*1024*/ TSystem::getFreeMemorySize(true) * .8)))DVGui::warning(tr("Error allocating memory: not enough memory."));}- ret = ret &&- connect(preferences, SIGNAL(stopAutoSave()), SLOT(onStopAutoSave()));- ret = ret &&- connect(preferences, SIGNAL(startAutoSave()), SLOT(onStartAutoSave()));- ret = ret && connect(m_currentTool, SIGNAL(toolEditingFinished()),- SLOT(onToolEditingFinished()));+ connect(preferences, &Preferences::stopAutoSave, this, &TApp::onStopAutoSave);+ connect(preferences, &Preferences::startAutoSave, this,+ &TApp::onStartAutoSave);+ connect(m_currentTool, &ToolHandle::toolEditingFinished, this,+ &TApp::onToolEditingFinished);if (preferences->isAutosaveEnabled())m_autosaveTimer->start(preferences->getAutosavePeriod() * 1000 * 60);UnitParameters::setCurrentDpiGetter(getCurrentDpi);- assert(ret);}//-----------------------------------------------------------------------------@@ -278,8 +252,8 @@ void TApp::setCurrentLevelStyleIndex(int index, bool forceUpdate) {//-----------------------------------------------------------------------------int TApp::getCurrentImageType() {- /*-- 現在のセルの種類に関係無く、Splineを選択中はベクタを編集できるようにする- * --*/+ // When a spline is selected, allow vector editing regardless of the current+ // cell type.if (getCurrentObject()->isSpline()) return TImage::VECTOR;TXshSimpleLevel *sl = 0;@@ -293,8 +267,8 @@ int TApp::getCurrentImageType() {? TImage::VECTOR: // RASTER image type includes both TZI_XSHLEVEL(levelType == TZP_XSHLEVEL)- ? TImage::TOONZ_RASTER- : TImage::RASTER; // and OVL_XSHLEVEL level types+ ? TImage::TOONZ_RASTER+ : TImage::RASTER; // and OVL_XSHLEVEL level types}TXsheet *xsh = getCurrentXsheet()->getXsheet();@@ -305,9 +279,9 @@ int TApp::getCurrentImageType() {int r0, r1;xsh->getCellRange(col, r0, r1);if (0 <= r0 && r0 <= r1) {- /*-- Columnに格納されている一番上のLevelのTypeに合わせる--*/+ // Use the type of the topmost level stored in the columncell = xsh->getCell(r0, col);- } else /*-- Columnが空の場合 --*/+ } else /* Column is empty */{return TImage::NONE;/*@@ -367,8 +341,8 @@ void TApp::updateXshLevel() {TXshCell cell = xsheet->getCell(frame, column);xl = cell.m_level.getPointer();- // Se sono su una cella vuota successiva a celle di un certo livello- // prendo questo come livello corrente.+ // If the current cell is empty but there is a level in the previous cell+ // of the same column, take that as the current level.if (!xl && frame > 0) {TXshCell cell = xsheet->getCell(frame - 1, column);xl = cell.m_level.getPointer();@@ -387,10 +361,8 @@ void TApp::updateXshLevel() {m_paletteController->getCurrentLevelPalette()->setPalette(xl->getSimpleLevel()->getPalette(), styleIndex);- // Se il nuovo livello selezionato e' un ovl,- // la paletta corrente e' una cleanup palette- // => setto come handle corrente quello della paletta di cleanup.-+ // If the new selected level is an OVL and the current palette is a+ // cleanup palette, then set the current handle to the cleanup palette.if (xl->getType() == OVL_XSHLEVEL && currentPalette &¤tPalette->isCleanupPalette())@@ -528,14 +500,13 @@ void TApp::onXshLevelSwitched(TXshLevel *) {if (level) {TXshSimpleLevel *simpleLevel = level->getSimpleLevel();- // Devo aggiornare la paletta corrente+ // Update the current paletteif (simpleLevel) {m_paletteController->getCurrentLevelPalette()->setPalette(simpleLevel->getPalette());- // Se il nuovo livello selezionato e' un ovl,- // la paletta corrente e' una cleanup palette- // => setto come handle corrente quello della paletta di cleanup.+ // If the new selected level is an OVL and the current palette is a+ // cleanup palette, then set the current handle to the cleanup palette.TPalette *currentPalette =m_paletteController->getCurrentPalette()->getPalette();@@ -608,39 +579,42 @@ void TApp::onPaletteChanged() { m_currentScene->setDirtyFlag(true); }void TApp::onLevelColorStyleSwitched() {TXshLevel *sl = m_currentLevel->getLevel();- if (!sl || (sl->getType() != TZP_XSHLEVEL && sl->getType() != PLI_XSHLEVEL))- return;+ if (!sl) return;TPaletteHandle *ph = m_paletteController->getCurrentLevelPalette();assert(ph);- if (ToonzCheck::instance()->setColorIndex(ph->getStyleIndex())) {- ToonzCheck *tc = ToonzCheck::instance();- int mask = tc->getChecks();-- if (mask & ToonzCheck::eInk || mask & ToonzCheck::ePaint) {- IconGenerator::Settings s;- s.m_blackBgCheck = mask & ToonzCheck::eBlackBg;- s.m_transparencyCheck = mask & ToonzCheck::eTransparency;- s.m_inksOnly = mask & ToonzCheck::eInksOnly;- s.m_inkIndex = mask & ToonzCheck::eInk ? tc->getColorIndex() : -1;- s.m_paintIndex = mask & ToonzCheck::ePaint ? tc->getColorIndex() : -1;-- IconGenerator::instance()->setSettings(s);-- if (sl->getType() == PLI_XSHLEVEL) {- std::vector<TFrameId> fids;- sl->getFids(fids);- for (int i = 0; i < (int)fids.size(); i++)- IconGenerator::instance()->invalidate(sl, fids[i]);- }+ ToonzCheck *tc = ToonzCheck::instance();+ int styleIndex = ph->getStyleIndex();- m_currentLevel->notifyLevelViewChange();- }+ // Sync the current style index+ tc->setColorIndex(styleIndex);- /*-- 表示オプションが切り替わっただけなので、DirtyFlagを立てない --*/- m_currentScene->notifySceneChanged(false);- }+ int mask = tc->getChecks();++ // Update IconGenerator settings.+ // We do this every time to ensure that if checks are turned off (mask == 0),+ // the generator knows to stop highlighting.+ IconGenerator::Settings s;+ s.m_blackBgCheck = mask & ToonzCheck::eBlackBg;+ s.m_transparencyCheck = mask & ToonzCheck::eTransparency;+ s.m_inksOnly = mask & ToonzCheck::eInksOnly;+ s.m_inkIndex = (mask & ToonzCheck::eInk) ? styleIndex : -1;+ s.m_paintIndex = (mask & ToonzCheck::ePaint) ? styleIndex : -1;++ IconGenerator::instance()->setSettings(s);++ // To fix the "frozen icons" in other columns, we must invalidate the global+ // icon cache. This ensures that all visible levels in the filmstrip/xsheet+ // reflect the current check state.+ invalidateIcons();++ // Notify the system that level views need refreshing+ m_currentLevel->notifyLevelViewChange();++ // Notify scene change for UI consistency (e.g., Scene Cast) without setting+ // the dirty flag+ m_currentScene->notifySceneChanged(false);}//-----------------------------------------------------------------------------@@ -659,7 +633,7 @@ static void notifyPaletteChanged(TXshSimpleLevel *simpleLevel) {// update related panels.if (simpleLevel->getType() == TZP_XSHLEVEL)IconGenerator::instance()->notifyIconGenerated();- else { // ToonzVecor needs to re-generate icons since it includes colors in+ else { // ToonzVector needs to re-generate icons since it includes colors in// the cache.for (int i = 0; i < (int)fids.size(); i++)IconGenerator::instance()->invalidate(simpleLevel, fids[i]);@@ -704,8 +678,8 @@ void TApp::autosave() {if (m_saveInProgress) return;- //DVGui::ProgressDialog pb(- // "Autosaving scene..." + toQString(scene->getScenePath()), 0, 0, 1);+ // DVGui::ProgressDialog pb(+ // "Autosaving scene..." + toQString(scene->getScenePath()), 0, 0, 1);Preferences *pref = Preferences::instance();if (pref->isAutosaveSceneEnabled() && pref->isAutosaveOtherFilesEnabled()) {@@ -715,7 +689,6 @@ void TApp::autosave() {} else if (pref->isAutosaveOtherFilesEnabled()) {IoCmd::saveNonSceneFiles();}-}//-----------------------------------------------------------------------------@@ -749,14 +722,15 @@ bool TApp::eventFilter(QObject *watched, QEvent *e) {} else if (e->type() == QEvent::TabletLeaveProximity) {// if the user is painting very quickly with the pen, a number of events// could be still in the queue- // the must be processed as tabled events (not mouse events)+ // they must be processed as tablet events (not mouse events)if (m_isPenCloseToTablet) qApp->processEvents();m_isPenCloseToTablet = false;emit tabletLeft();}- return false; // I want just peek at the event. It must be processed anyway.+ return false; // I just want to peek at the event. It must be processed+ // anyway.}//-----------------------------------------------------------------------------diff --git a/toonz/sources/toonzlib/imagepainter.cpp b/toonz/sources/toonzlib/imagepainter.cppindex 33e16497c..4ad7bf575 100644--- a/toonz/sources/toonzlib/imagepainter.cpp+++ b/toonz/sources/toonzlib/imagepainter.cpp@@ -97,6 +97,13 @@ inline void quickput(const TRasterP &rout, const TRasterP &rin,Preferences::instance()->getTranspCheckData(settings.m_transpCheckBg, settings.m_transpCheckInk,settings.m_transpCheckPaint);++ settings.m_inkCheckColor = Preferences::instance()->getInkCheckColor();+ settings.m_ink1CheckColor =+ Preferences::instance()->getInk1CheckColor();+ settings.m_paintCheckColor =+ Preferences::instance()->getPaintCheckColor();+TRop::quickPut(rout, srcCM32, palette, aff, settings);}srcCM32 = TRasterCM32P();diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cppindex 36cd61a2b..22040ba95 100644--- a/toonz/sources/toonzlib/preferences.cpp+++ b/toonz/sources/toonzlib/preferences.cpp@@ -676,6 +676,10 @@ void Preferences::definePreferenceItems() {QColor(Qt::white));define(transpCheckPaint, "transpCheckPaint", QMetaType::QColor,QColor(127, 127, 127));+ define(inkCheckColor, "inkCheckColor", QMetaType::QColor, QColor(Qt::red));+ define(ink1CheckColor, "ink1CheckColor", QMetaType::QColor, QColor(Qt::red));+ define(paintCheckColor, "paintCheckColor", QMetaType::QColor,+ QColor(Qt::red));// Version Controldefine(SVNEnabled, "SVNEnabled", QMetaType::Bool, false);diff --git a/toonz/sources/toonzlib/stagevisitor.cpp b/toonz/sources/toonzlib/stagevisitor.cppindex a837338b8..5a72a283a 100644--- a/toonz/sources/toonzlib/stagevisitor.cpp+++ b/toonz/sources/toonzlib/stagevisitor.cpp@@ -628,15 +628,14 @@ void RasterPainter::flushRasterImages() {settings.m_blackBgCheck = tc & ToonzCheck::eBlackBg;// Highlight specific ink/paint only for current column- settings.m_inkIndex =- m_nodes[i].m_isCurrentColumn- ? (tc & ToonzCheck::eInk ? index- : (tc & ToonzCheck::eInk1 ? 1 : -1))- : -1;+ settings.m_inkIndex = m_nodes[i].m_isCurrentColumn ? index : -1;- settings.m_paintIndex = m_nodes[i].m_isCurrentColumn- ? (tc & ToonzCheck::ePaint ? index : -1)- : -1;+ settings.m_paintIndex = m_nodes[i].m_isCurrentColumn+ ? (tc & ToonzCheck::ePaint ? index : -1)+ : -1;+ settings.m_inkCheckEnabled = (tc & ToonzCheck::eInk) != 0;+ settings.m_ink1CheckEnabled = (tc & ToonzCheck::eInk1) != 0;+ settings.m_paintCheckEnabled = (tc & ToonzCheck::ePaint) != 0;Preferences::instance()->getTranspCheckData(settings.m_transpCheckBg, settings.m_transpCheckInk,@@ -645,6 +644,12 @@ void RasterPainter::flushRasterImages() {settings.m_isOnionSkin = m_nodes[i].m_onionMode != Node::eOnionSkinNone;settings.m_gapCheckIndex = gapCheckIndex;+ settings.m_inkCheckColor = Preferences::instance()->getInkCheckColor();+ settings.m_ink1CheckColor =+ Preferences::instance()->getInk1CheckColor();+ settings.m_paintCheckColor =+ Preferences::instance()->getPaintCheckColor();+// ==============================================================// Transparency Check: (see helper above)// Apply high-tone empty pixel fix@@ -944,6 +949,10 @@ void RasterPainter::onVectorImage(TVectorImage *vi,rd.m_paintCheckEnabled = tc & ToonzCheck::ePaint;rd.m_blackBgEnabled = tc & ToonzCheck::eBlackBg;rd.m_colorCheckIndex = ToonzCheck::instance()->getColorIndex();+ rd.m_paintIndex = ToonzCheck::instance()->getColorIndex();+ rd.m_inkCheckColor = Preferences::instance()->getInkCheckColor();+ rd.m_ink1CheckColor = Preferences::instance()->getInk1CheckColor();+ rd.m_paintCheckColor = Preferences::instance()->getPaintCheckColor();rd.m_show0ThickStrokes = prefs.getShow0ThickLines();rd.m_regionAntialias = prefs.getRegionAntialias();rd.m_animatedGuidedDrawing = prefs.getAnimatedGuidedDrawing();diff --git a/toonz/sources/toonzqt/icongenerator.cpp b/toonz/sources/toonzqt/icongenerator.cppindex bc3427fc1..8f4b0f2e8 100644--- a/toonz/sources/toonzqt/icongenerator.cpp+++ b/toonz/sources/toonzqt/icongenerator.cpp@@ -95,6 +95,12 @@ bool getIcon(const std::string &iconName, QPixmap &pix,s.m_paintIndex = settings.m_paintIndex;Preferences::instance()->getTranspCheckData(s.m_transpCheckBg, s.m_transpCheckInk, s.m_transpCheckPaint);+ s.m_inkCheckEnabled = settings.m_inkCheckEnabled;+ s.m_ink1CheckEnabled = settings.m_ink1CheckEnabled;+ s.m_paintCheckEnabled = settings.m_paintCheckEnabled;+ s.m_inkCheckColor = Preferences::instance()->getInkCheckColor();+ s.m_ink1CheckColor = Preferences::instance()->getInk1CheckColor();+ s.m_paintCheckColor = Preferences::instance()->getPaintCheckColor();TRop::quickPut(icon, timgp->getRaster(), simpleLevel->getPalette(),TAffine(), s);@@ -209,6 +215,7 @@ void makeChessBackground(const TRaster32P &ras) {//------------------------------------------namespace {+TRaster32P convertToIcon(TVectorImageP vimage, int frame,const TDimension &iconSize,const IconGenerator::Settings &settings) {@@ -220,51 +227,63 @@ TRaster32P convertToIcon(TVectorImageP vimage, int frame,TOfflineGL *glContext = IconGenerator::instance()->getOfflineGLContext();- // The image and contained within Imagebox- // (add a small margin also to prevent problems with empty images)+ // Image bounding box with a small margin to prevent issues with empty imagesTRectD imageBox;{QMutexLocker sl(vimage->getMutex());imageBox = vimage->getBBox().enlarge(.1);}+TPointD imageCenter = (imageBox.getP00() + imageBox.getP11()) * 0.5;- // Calculate a transformation matrix that moves the image inside the icon.- // The scale factor is chosen so that the image is entirely- // contained in the icon (with a margin of 'margin' pixels)+ // Calculate transformation matrix to fit the image inside the iconconst int margin = 10;double scx = (iconSize.lx - margin) / imageBox.getLx();double scy = (iconSize.ly - margin) / imageBox.getLy();double sc = std::min(scx, scy);- // Add the translation: the center point of the image is at the point- // middle of the pixmap.+ // The center point of the image is at the point middle of the pixmap.TPointD iconCenter(iconSize.lx * 0.5, iconSize.ly * 0.5);TAffine aff = TScale(sc).place(imageCenter, iconCenter);- // RenderData+ // Initialize VectorRenderDataTVectorRenderData rd(aff, TRect(iconSize), plt, 0, true);- rd.m_tcheckEnabled = settings.m_transparencyCheck;- rd.m_blackBgEnabled = settings.m_blackBgCheck;- rd.m_drawRegions = !settings.m_inksOnly;- rd.m_inkCheckEnabled = settings.m_inkIndex != -1;- rd.m_paintCheckEnabled = settings.m_paintIndex != -1;- rd.m_colorCheckIndex =- rd.m_inkCheckEnabled ? settings.m_inkIndex : settings.m_paintIndex;- rd.m_isIcon = true;+ rd.m_tcheckEnabled = settings.m_transparencyCheck;+ rd.m_blackBgEnabled = settings.m_blackBgCheck;+ rd.m_drawRegions = !settings.m_inksOnly;+ rd.m_isIcon = true;++ // Sync Check Flags+ rd.m_inkCheckEnabled = settings.m_inkCheckEnabled;+ rd.m_ink1CheckEnabled = settings.m_ink1CheckEnabled;+ rd.m_paintCheckEnabled = settings.m_paintCheckEnabled;+ rd.m_paintIndex = settings.m_paintIndex;++ // Define the target color index for highlighting (Priority: Ink > Paint)+ if (rd.m_inkCheckEnabled || rd.m_ink1CheckEnabled)+ rd.m_colorCheckIndex = settings.m_inkIndex;+ else if (rd.m_paintCheckEnabled)+ rd.m_colorCheckIndex = settings.m_paintIndex;+ else+ rd.m_colorCheckIndex = -1;- // Draw the image.+ // Set check colors from Preferences+ Preferences *pref = Preferences::instance();+ rd.m_inkCheckColor = pref->getInkCheckColor();+ rd.m_ink1CheckColor = pref->getInk1CheckColor();+ rd.m_paintCheckColor = pref->getPaintCheckColor();++ // Draw the vector image to the offline GL contextglContext->makeCurrent();glContext->clear(rd.m_blackBgEnabled ? TPixel::Black : TPixel32::White);glContext->draw(vimage, rd);+ // Retrieve the rendered rasterTRaster32P ras(iconSize);glContext->getRaster(ras);-glContext->doneCurrent();delete plt;-return ras;}@@ -292,7 +311,6 @@ TRaster32P convertToIcon(TToonzImageP timage, int frame,elseiconLy = tround((double(ly) * iconSize.lx) / lx);- // icon size with correct aspect ratioTDimension iconSize2 = TDimension(iconLx, iconLy);TRaster32P icon(iconSize2);@@ -318,6 +336,12 @@ TRaster32P convertToIcon(TToonzImageP timage, int frame,s.m_paintIndex = settings.m_paintIndex;Preferences::instance()->getTranspCheckData(s.m_transpCheckBg, s.m_transpCheckInk, s.m_transpCheckPaint);+ s.m_inkCheckEnabled = settings.m_inkCheckEnabled;+ s.m_ink1CheckEnabled = settings.m_ink1CheckEnabled;+ s.m_paintCheckEnabled = settings.m_paintCheckEnabled;+ s.m_inkCheckColor = Preferences::instance()->getInkCheckColor();+ s.m_ink1CheckColor = Preferences::instance()->getInk1CheckColor();+ s.m_paintCheckColor = Preferences::instance()->getPaintCheckColor();TRop::quickPut(icon, rasCM32, timage->getPalette(), TAffine(), s);} else@@ -339,11 +363,8 @@ TRaster32P convertToIcon(TToonzImageP timage, int frame,TRaster32P convertToIcon(TRasterImageP rimage, const TDimension &iconSize) {if (!rimage) return TRaster32P();-TRasterP ras = rimage->getRaster();-if (!(TRaster32P)ras && !(TRasterGR8P)ras) return TRaster32P();-if (ras->getSize() == iconSize) return ras;TRaster32P icon(iconSize);@@ -367,50 +388,33 @@ TRaster32P convertToIcon(TMeshImageP mi, int frame, const TDimension &iconSize,if (!mi) return TRaster32P();TOfflineGL *glContext = IconGenerator::instance()->getOfflineGLContext();-- // The image and contained within Imagebox- // (add a small margin also to prevent problems with empty images)- TRectD imageBox;- imageBox = mi->getBBox().enlarge(.1);-+ TRectD imageBox = mi->getBBox().enlarge(.1);TPointD imageCenter(0.5 * (imageBox.getP00() + imageBox.getP11()));- // Calculate a transformation matrix that moves the image inside the icon.- // The scale factor is chosen so that the image is entirely- // contained in the icon (with a margin of 'margin' pixels)const int margin = 10;double scx = (iconSize.lx - margin) / imageBox.getLx();double scy = (iconSize.ly - margin) / imageBox.getLy();double sc = std::min(scx, scy);- // Add the translation: the center point of the image is at the point- // middle of the pixmap.TPointD iconCenter(iconSize.lx * 0.5, iconSize.ly * 0.5);TAffine aff = TScale(sc).place(imageCenter, iconCenter);- // Draw the image.glContext->makeCurrent();glContext->clear(settings.m_blackBgCheck ? TPixel::Black : TPixel32::White);glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT);glEnable(GL_BLEND);glEnable(GL_LINE_SMOOTH);-glPushMatrix();tglMultMatrix(aff);-glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);-glColor4f(0.0f, 1.0f, 0.0f, 0.7f);tglDrawEdges(*mi);-glPopMatrix();-glPopAttrib();TRaster32P ras(iconSize);glContext->getRaster(ras);-glContext->doneCurrent();return ras;@@ -477,15 +481,14 @@ IconRenderer::IconRenderer(const std::string &id, const TDimension &iconSize), m_id(id), m_started(false), m_terminated(false) {- connect(this, SIGNAL(started(TThread::RunnableP)), IconGenerator::instance(),- SLOT(onStarted(TThread::RunnableP)));- connect(this, SIGNAL(finished(TThread::RunnableP)), IconGenerator::instance(),- SLOT(onFinished(TThread::RunnableP)));- connect(this, SIGNAL(canceled(TThread::RunnableP)), IconGenerator::instance(),- SLOT(onCanceled(TThread::RunnableP)), Qt::QueuedConnection);- connect(this, SIGNAL(terminated(TThread::RunnableP)),- IconGenerator::instance(), SLOT(onTerminated(TThread::RunnableP)),- Qt::QueuedConnection);+ connect(this, &IconRenderer::started, IconGenerator::instance(),+ &IconGenerator::onStarted);+ connect(this, &IconRenderer::finished, IconGenerator::instance(),+ &IconGenerator::onFinished);+ connect(this, &IconRenderer::canceled, IconGenerator::instance(),+ &IconGenerator::onCanceled, Qt::QueuedConnection);+ connect(this, &IconRenderer::terminated, IconGenerator::instance(),+ &IconGenerator::onTerminated, Qt::QueuedConnection);}//-----------------------------------------------------------------------------@@ -909,9 +912,9 @@ TRaster32P XsheetIconRenderer::generateRaster(double sx = (double)iconSize.lx / res.lx;double sy = (double)iconSize.ly / res.ly;- double s = std::min(sx, sy);- res.lx = tround(res.lx * s);- res.ly = tround(res.ly * s);+ double s = std::min(sx, sy);+ res.lx = tround(res.lx * s);+ res.ly = tround(res.ly * s);}}TRaster32P ras(res);