149 template<
class inRamCanvasT>
156 inline typename inRamCanvasT::coordIntType
getNumPixX() {
return attachedRC.getNumPixX(); }
157 inline typename inRamCanvasT::coordIntType
getNumPixY() {
return attachedRC.getNumPixY(); }
160 template<
class inRamCanvasT>
168 template<
class inRamCanvasT>
172 typedef typename inRamCanvasT::colorType::colConRGBbyte
colorType;
176 template<
class inRamCanvasT>
180 typedef typename inRamCanvasT::colorType::colConRGBAbyte
colorType;
184 template<
class inRamCanvasT>
188 typedef typename inRamCanvasT::colorType::colConRGBdbl
colorType;
192 template<
class inRamCanvasT>
196 typedef typename inRamCanvasT::colorType::colConRGBAdbl
colorType;
201 template<
class inRamCanvasT,
class outColorT,
class colorScheme,
bool clamp,
int factor,
int chan>
209 csi = mjr::math::ivl::clamp(csi, colorScheme::numC-1);
210 return colorScheme::c(csi);
215 template<
class inRamCanvasT,
class outColorChanT>
306 const static intCrdT intCrdMax = (1ul << ((
sizeof(intCrdT)*CHAR_BIT-1)/2)) - 3;
325 const static intCrdT intCrdGrdMax = intCrdMax+1;
326 const static intCrdT intCrdGrdMin = -1;
397 void drawFillTriangleUtl(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorT c1, colorT c2, colorT c3,
bool solid);
409 void writeUIntToStream(std::ostream& oStream,
endianType endianness,
int numBytes, uint64_t data);
422 void updRealCoords();
431 void newIntCoordsNC(intCrdT numPixX_p, intCrdT numPixY_p);
443 void reallocCanvas(intCrdT numPixX_p, intCrdT numPixY_p);
449 void rePointPixels(colorT *new_pixels, intCrdT new_numPixX, intCrdT new_numPixY);
457 void triangleEdger(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT* pts,
bool findMin);
491 int exportRasterData(
void* &rasterData, intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2,
int redChan,
int greenChan,
int blueChan,
int alphaChan);
512 ramCanvasTpl(intCrdT numPixX_p, intCrdT numPixY_p, fltCrdT minRealX_p=-1, fltCrdT maxRealX_p=1, fltCrdT minRealY_p=-1, fltCrdT maxRealY_p=1);
543 intCrdT origNumPixX = getNumPixX();
544 expandCanvas(origNumPixX + theCanvas.
getNumPixX(), std::max(getNumPixY(), theCanvas.
getNumPixY()));
545 insertCanvas(theCanvas, origNumPixX);
554 intCrdT origNumPixX = getNumPixX();
555 expandCanvas(origNumPixX + theCanvas.
getNumPixX(), std::max(getNumPixY(), theCanvas.
getNumPixY()), origNumPixX);
556 insertCanvas(theCanvas);
565 intCrdT origNumPixY = getNumPixY();
566 expandCanvas(std::max(getNumPixX(), theCanvas.
getNumPixX()), origNumPixY + theCanvas.
getNumPixY(), 0, origNumPixY);
567 insertCanvas(theCanvas, 0, 0);
576 intCrdT origNumPixY = getNumPixY();
577 expandCanvas(std::max(getNumPixX(), theCanvas.
getNumPixX()), origNumPixY + theCanvas.
getNumPixY());
578 insertCanvas(theCanvas, 0, origNumPixY);
589 for(intCrdT y=0; y<theCanvas.
getNumPixY(); y++)
590 for(intCrdT x=0; x<theCanvas.
getNumPixX(); x++)
603 void resizeCanvas(intCrdT new_numPixX_p, intCrdT new_numPixY_p);
613 void expandCanvas(intCrdT new_numPixX_p, intCrdT new_numPixY_p, intCrdT x1 = 0, intCrdT y1 = 0, colorArgType color = colorT(colorT::minChanVal));
620 void cropCanvas(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2);
632 void newRealCoords(fltCrdT minRealX_p, fltCrdT maxRealX_p, fltCrdT minRealY_p, fltCrdT maxRealY_p);
657 if (isNotSameSize(inRC))
659 for(intCrdT y=0; y<numPixY; y++)
660 for(intCrdT x=0; x<numPixX; x++)
661 if ( !(getPxColorRefNC(x, y).isClose(inRC.
getPxColorRefNC(x, y), epsilon)))
668 if (isNotSameSize(inRC))
670 for(intCrdT y=0; y<numPixY; y++)
671 for(intCrdT x=0; x<numPixX; x++)
708 void flipTranspose();
719 void scaleUpProximal(
int xfactor);
725 void scaleDown1pt(
int xfactor);
730 void scaleDownMax(
int xfactor);
736 void scaleDownMean(
int xfactor);
758 ramCanvasTpl geomTfrmRevRPoly(std::vector<double>
const& RPoly,
763 colorArgType errorColor = colorCornerEnum::GREEN,
764 interpolationType interpMethod = interpolationType::BILINEAR);
777 ramCanvasTpl geomTfrmRevBiPoly(std::vector<double>
const& BiPolyX,
778 std::vector<double>
const& BiPolyY,
782 colorArgType errorColor = colorCornerEnum::GREEN,
783 interpolationType interpMethod = interpolationType::BILINEAR);
800 ramCanvasTpl geomTfrmRevAff(std::vector<double>
const& HAMatrix,
804 colorArgType errorColor = colorCornerEnum::GREEN,
805 interpolationType interpMethod = interpolationType::BILINEAR);
821 colorArgType errorColor = colorCornerEnum::GREEN,
822 interpolationType interpMethod = interpolationType::BILINEAR);
837 void convolution(
double *kernel,
int kWide,
int kTall,
double divisor);
838 void convolution(
double *kernel,
int kSize,
double divisor);
839 void convolution(
double *kernel,
int kSize);
850 void computeConvolutionMatrixGausian(
double *kernel,
int kSize,
double sd);
855 void computeConvolutionMatrixBox(
double *kernel,
int kSize);
862 colorT *
end() {
return pixelsE; }
875 void applyHomoPixTfrm(colorT& (colorT::*HPT)());
876 void applyHomoPixTfrm(colorT& (colorT::*HPT)(double), double);
877 void applyHomoPixTfrm(colorT& (colorT::*HPT)(double, double), double, double);
878 void applyHomoPixTfrm(colorT& (colorT::*HPT)(double, double, double), double, double, double);
879 void applyHomoPixTfrm(colorT& (colorT::*HPT)(double, double, double, double), double, double, double, double);
880 void applyHomoPixTfrm(colorT& (colorT::*HPT)(double, double, double, double, double), double, double, double, double, double);
881 void applyHomoPixTfrm(colorT& (colorT::*HPT)(double, double, double, double, double, double), double, double, double, double, double, double);
882 void applyHomoPixTfrm(colorT& (colorT::*HPT)(int), int);
883 void applyHomoPixTfrm(colorT& (colorT::*HPT)(int, int), int, int);
884 void applyHomoPixTfrm(colorT& (colorT::*HPT)(int, int, int), int, int, int);
885 void applyHomoPixTfrm(colorT& (colorT::*HPT)(int, int, int, int), int, int, int, int);
886 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT), colorT);
887 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT), colorT, colorT);
888 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT, colorT), colorT, colorT, colorT);
889 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT, colorT, colorT), colorT, colorT, colorT, colorT);
899 void autoHistStrech();
904 void autoMaxHistStrechRGB();
920 void combineRamCanvasBinOp(colorT& (colorT::*HPT)(colorT),
922 intCrdT trgX = 0, intCrdT trgY = 0,
923 intCrdT wide = -1, intCrdT tall = -1,
924 intCrdT srcX = 0, intCrdT srcY = 0);
942 void clrCanvasToBlack();
945 void clrCanvasToWhite();
948 void clrCanvasChannelToMin(
int chan);
951 void clrCanvasChannelToMax(
int chan);
967 inline void moveTo(intCrdT x, intCrdT y) { dfltX = x; dfltY = y; }
968 inline void moveTo(fltCrdT x, fltCrdT y) {
moveTo(real2intX(x), real2intY(y)); }
979 inline void setDfltColor(std::string cornerColor) { dfltColor.setToCorner(cornerColor); }
980 inline void setDfltColor(
const char* cornerColor) { dfltColor.setToCorner(std::string(cornerColor)); }
995 drawPointNC(x, y, color);
1039 void drawLine(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, colorArgType color);
1049 inline void drawLine(fltCrdT x, fltCrdT y) {
drawLine( dfltX, dfltY, real2intX(x), real2intY(y), dfltColor); }
1052 inline void drawLine(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2) {
drawLine( x1, y1, x2, y2, dfltColor); }
1053 inline void drawLine(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2) {
drawLine( x1, y1, x2, y2, dfltColor); }
1054 inline void drawLine(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2,
colorArgType color) {
drawLine( real2intX(x1), real2intY(y1), real2intX(x2), real2intY(y2), color); }
1070 void drawTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorArgType color);
1073 real2intX(thePoints[1].x), real2intY(thePoints[1].y),
1074 real2intX(thePoints[2].x), real2intY(thePoints[2].y), dfltColor); }
1076 real2intX(thePoints[1].x), real2intY(thePoints[1].y),
1077 real2intX(thePoints[2].x), real2intY(thePoints[2].y), color); }
1081 real2intX(point2.
x), real2intY(point2.
y),
1082 real2intX(point3.
x), real2intY(point3.
y), dfltColor); }
1084 real2intX(point2.
x), real2intY(point2.
y),
1085 real2intX(point3.
x), real2intY(point3.
y), color); }
1087 inline void drawTriangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, fltCrdT x3, fltCrdT y3) {
drawTriangle(real2intX(x1), real2intY(y1), real2intX(x2), real2intY(y2), real2intX(x3), real2intY(y3), dfltColor); }
1088 inline void drawTriangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, fltCrdT x3, fltCrdT y3,
colorArgType color) {
drawTriangle(real2intX(x1), real2intY(y1), real2intX(x2), real2intY(y2), real2intX(x3), real2intY(y3), color); }
1089 inline void drawTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3) {
drawTriangle(x1, y1, x2, y2, x3, y3, dfltColor); }
1106 void drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorArgType color);
1109 real2intX(thePoints[1].x), real2intY(thePoints[1].y),
1110 real2intX(thePoints[2].x), real2intY(thePoints[2].y), dfltColor); }
1112 real2intX(thePoints[1].x), real2intY(thePoints[1].y),
1113 real2intX(thePoints[2].x), real2intY(thePoints[2].y), color); }
1115 thePoints[1].x, thePoints[1].y,
1116 thePoints[2].x, thePoints[2].y, dfltColor); }
1119 real2intX(point2.
x), real2intY(point2.
y),
1120 real2intX(point3.
x), real2intY(point3.
y), dfltColor); }
1122 real2intX(point2.
x), real2intY(point2.
y),
1123 real2intX(point3.
x), real2intY(point3.
y), color); }
1125 inline void drawFillTriangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, fltCrdT x3, fltCrdT y3) {
drawFillTriangle(real2intX(x1), real2intY(y1), real2intX(x2), real2intY(y2), real2intX(x3), real2intY(y3), dfltColor); }
1126 inline void drawFillTriangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, fltCrdT x3, fltCrdT y3,
colorArgType color) {
drawFillTriangle(real2intX(x1), real2intY(y1), real2intX(x2), real2intY(y2), real2intX(x3), real2intY(y3), color); }
1127 inline void drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3) {
drawFillTriangle(x1, y1, x2, y2, x3, y3, dfltColor); }
1147 void drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorArgType color1, colorArgType color2, colorArgType color3);
1162 void drawRectangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, colorArgType color);
1171 inline void drawRectangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2) {
drawRectangle(real2intX(x1), real2intY(y1), real2intX(x2), real2intY(y2), dfltColor); }
1188 void drawFillRectangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, colorArgType color);
1219 void drawCircle(intCrdT centerX, intCrdT centerY, intCrdT radiusX, colorArgType color);
1226 inline void drawCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX) {
drawCircle(real2intX(centerX), real2intY(centerY), realDelta2intX(radiusX), dfltColor); }
1227 inline void drawCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX,
colorArgType color) {
drawCircle(real2intX(centerX), real2intY(centerY), realDelta2intX(radiusX), color); }
1228 inline void drawCircle(intCrdT centerX, intCrdT centerY, intCrdT radiusX) {
drawCircle(centerX, centerY, radiusX, dfltColor); }
1246 void drawFillCircle(intCrdT centerX, intCrdT centerY, intCrdT radiusX, colorArgType color);
1253 inline void drawFillCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX) {
drawFillCircle(real2intX(centerX), real2intY(centerY), realDelta2intX(radiusX), dfltColor); }
1265 void drawPLCurve(
int numPoints, intCrdT *x, intCrdT *y, colorArgType color);
1266 void drawPLCurve(
int numPoints, intCrdT *x, intCrdT *y);
1267 void drawPLCurve(
int numPoints, fltCrdT *x, fltCrdT *y, colorArgType color);
1268 void drawPLCurve(
int numPoints, fltCrdT *x, fltCrdT *y);
1269 void drawPLCurve(
int numPoints, pointIntType *thePoints, colorArgType color);
1270 void drawPLCurve(
int numPoints, pointIntType *thePoints);
1271 void drawPLCurve(
int numPoints, pointFltType *thePoints, colorArgType color);
1272 void drawPLCurve(
int numPoints, pointFltType *thePoints);
1288 void drawHersheyGlyph(
int glyphNum, intCrdT x, intCrdT y,
double magX,
double magY, colorArgType aColor);
1289 void drawHersheyGlyph(
int glyphNum, fltCrdT x, fltCrdT y,
double magX,
double magY,
colorArgType aColor) {
drawHersheyGlyph(glyphNum, real2intX(x), real2intY(y), magX, magY, aColor); }
1306 void drawString(std::string aString,
mjr::hershey::font aFont, intCrdT x, intCrdT y, colorArgType aColor,
double cex, intCrdT spc);
1308 drawString(aString, aFont, real2intX(x), real2intY(y), aColor, cex, spc);
1320 void drawStringBox(std::string aString,
mjr::hershey::font aFont, intCrdT x, intCrdT y, colorArgType stringColor, colorArgType boxColor,
double cex, intCrdT spc);
1322 drawStringBox(aString, aFont, real2intX(x), real2intY(y), stringColor, boxColor, cex, spc);
1332 bool supportLibTIFF();
1371 int readTIFFfile(std::string fileName);
1408 template <
class rcConT>
int writeTIFFfile(std::string fileName, rcConT rcConverter,
bool markAlpha);
1411 int writeTIFFfile(std::string fileName,
bool markAlpha =
true);
1429 int writeTGAfile(std::string fileName);
1472 int readRAWfile(std::string fileName);
1523 template <
class rcConT>
int writeRAWfile(std::string fileName, rcConT rcConverter);
1526 int writeRAWfile(std::string fileName);
1537 inline int isCliped(fltCrdT x, fltCrdT y)
const {
return isCliped(real2intX(x), real2intY(y)); }
1538 inline int isCliped(intCrdT x, intCrdT y)
const {
return ((x < 0) || (y < 0) || (x >= numPixX) || (y >= numPixY)); }
1544 inline int isOnCanvas(fltCrdT x, fltCrdT y)
const {
return isCliped(real2intX(x), real2intY(y)); }
1545 inline int isOnCanvas(intCrdT x, intCrdT y)
const {
return ((x >= 0) && (y >= 0) && (x < numPixX) && (y < numPixY)); }
1555 intCrdT real2intX(fltCrdT x)
const;
1560 intCrdT real2intY(fltCrdT y)
const;
1565 fltCrdT int2realX(intCrdT x);
1570 fltCrdT int2realY(intCrdT y);
1606 inline pointFltType int2corner(intCrdT x, intCrdT y,
int cornerX,
int cornerY) {
return point2d(int2realX(x+cornerX)-pixWidX/2.0, int2realY(y+cornerY)-pixWidY/2.0); }
1625 inline intCrdT
realDelta2intX(fltCrdT x)
const {
return static_cast<intCrdT
>(
static_cast<fltCrdT
>(x)/pixWidX); }
1630 inline intCrdT
realDelta2intY(fltCrdT y)
const {
return static_cast<intCrdT
>(
static_cast<fltCrdT
>(y)/pixWidY); }
1635 inline fltCrdT
intDelta2realX(intCrdT x)
const {
return static_cast<fltCrdT
>(x)*pixWidX; }
1640 inline fltCrdT
intDelta2realY(intCrdT y)
const {
return static_cast<fltCrdT
>(y)*pixWidY; }
1734 colorT *clonePixels();
1757 colorT getPxColor(intCrdT x, intCrdT y)
const;
1772 colorT getPxColorInterpolate(
double x,
double y, interpolationType interpMethod = interpolationType::BILINEAR);
1778 colorT getPxColorInterpBLin(
double x,
double y);
1784 colorT getPxColorInterpTrunc(
double x,
double y);
1790 colorT getPxColorInterpNear(
double x,
double y);
1796 colorT getPxColorInterpAvg4(
double x,
double y);
1802 colorT getPxColorInterpAvg9(
double x,
double y);
1816 void drawPointNC(intCrdT x, intCrdT y, colorArgType color);
1821 inline colorT
getPxColorNC(intCrdT x, intCrdT y)
const {
return pixels[numPixX * y + x]; }
1827 inline colorT&
getPxColorRefNC(intCrdT x, intCrdT y)
const {
return pixels[numPixX * y + x]; }
1834 inline void drawHorzLineNC(intCrdT xMin, intCrdT xMax, intCrdT yConst,
colorArgType color) {
for(intCrdT x=xMin;x<=xMax;x++) drawPointNC(x, yConst, color); }
1841 inline void drawVertLineNC(intCrdT yMin, intCrdT yMax, intCrdT xConst,
colorArgType color) {
for(intCrdT y=yMin;y<=yMax;y++) drawPointNC(xConst, y, color); }
1868 void colorizeFltCanvas(std::function<colorT (fltCrdT, fltCrdT)> cFun);
1869 void colorizeFltCanvas(std::function<colorT (pointFltType)> cFun);
1871 void colorizeIntCanvas(std::function<colorT (intCrdT, intCrdT)> cFun);
1872 void colorizeIntCanvas(std::function<colorT (pointIntType)> cFun);
1882 intCrdT retCount = 0;
1883 if( !isCliped(x1, y1) && !isCliped(x2, y2) ) {
1888 for(intCrdT y=y1;y<=y2;y++)
1889 for(intCrdT x=x1;x<=x2;x++)
1891 if ( !(getPxColorRefNC(x, y).isBlack()))
1898 return statNumNonZeroPixels(0, 0, numPixX-1, numPixY-1);
1905 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1906 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1908 newIntCoordsNC(-1, -1);
1909 newRealCoords(0.0, 0.0, 0.0, 0.0);
1912 setRealAxisDefaultOrientation();
1913 setIntAxisDefaultOrientation();
1914 setDefaultDrawMode();
1919 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1920 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1931 for(intCrdT y=0; y<numPixY; y++)
1932 for(intCrdT x=0; x<numPixX; x++)
1938 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1939 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1948 pixels = theCanvas.
pixels;
1954 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1955 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1958 if (
this != &theCanvas) {
1966 pixels = theCanvas.
pixels;
1974 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1975 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1977 newIntCoordsNC(numPixX_p, numPixY_p);
1978 newRealCoords(minRealX_p, maxRealX_p, minRealY_p, maxRealY_p);
1979 pixels =
new colorT[numPixX * numPixY];
1980 pixelsE = pixels + (numPixX * numPixY);
1981 setRealAxisDefaultOrientation();
1982 setIntAxisDefaultOrientation();
1983 setDefaultDrawMode();
1988 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1989 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1991 if(pixels != NULL) {
1998 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1999 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2002 if(numPixX_p > intCrdMax) {
2003 throw std::invalid_argument(
"newIntCoordsNC: numPixX_p argument too large.");
2004 }
else if (numPixY_p > intCrdMax) {
2005 throw std::invalid_argument(
"newIntCoordsNC: numPixY_p argument too large.");
2007 numPix = numPixX_p * numPixY_p;;
2008 numPixX = numPixX_p;
2009 numPixY = numPixY_p;
2014 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2015 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2018 if(minRealX_p > maxRealX_p) {
2019 throw std::invalid_argument(
"newRealCoords: minRealX_p > maxRealX_p.");
2020 }
else if (minRealY_p > maxRealY_p) {
2021 throw std::invalid_argument(
"newRealCoords: minRealY_p > maxRealY_p.");
2023 minRealX = minRealX_p;
2024 maxRealX = maxRealX_p;
2025 minRealY = minRealY_p;
2026 maxRealY = maxRealY_p;
2032 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2033 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2036 canvasWidX = maxRealX - minRealX;
2037 canvasWidY = maxRealY - minRealY;
2038 pixWidX = (numPixX == 0 ? 0 : canvasWidX / numPixX);
2039 pixWidY = (numPixY == 0 ? 0 : canvasWidY / numPixY);
2043 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2044 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2047 for(intCrdT y=0; y<numPixY; y++)
2048 for(intCrdT x=0; x<numPixX; x++)
2049 getPxColorRefNC(x, y).setChanToMin(chan);
2053 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2054 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2057 for(intCrdT y=0; y<numPixY; y++)
2058 for(intCrdT x=0; x<numPixX; x++)
2059 getPxColorRefNC(x, y).setChanToMax(chan);
2063 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2064 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2082 for(intCrdT y=0; y<numPixY; y++)
2083 for(intCrdT x=0; x<numPixX; x++)
2084 getPxColorRefNC(x, y).setToBlack();
2091 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2092 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2095 for(intCrdT y=0; y<numPixY; y++)
2096 for(intCrdT x=0; x<numPixX; x++)
2097 getPxColorRefNC(x, y).setToWhite();
2101 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2102 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2105 clrCanvas(dfltColor);
2109 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2110 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2113 for(intCrdT y=0; y<numPixY; y++)
2114 for(intCrdT x=0; x<numPixX; x++)
2115 drawPointS(x, y, color);
2119 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2120 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2125 for(intCrdT y=0;y<numPixY;y++) {
2126 for(intCrdT x=0;x<numPixX;x++) {
2127 colorT daColor = getPxColorNC(x, y);
2137 double c = 1.0 *
static_cast<double>(colorT::maxChanVal-colorT::minChanVal) /
static_cast<double>(cmax-cmin);
2138 double b =
static_cast<double>(colorT::maxChanVal) - 1.0 * c *
static_cast<double>(cmax);
2139 applyHomoPixTfrm(&colorT::tfrmLinearGreyLevelScale, c, b);
2144 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2145 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2148 colorT cmin; cmin.setChans(cmin.maxChanVal);
2149 colorT cmax; cmax.setChans(cmin.minChanVal);
2150 for(intCrdT y=0;y<numPixY;y++) {
2151 for(intCrdT x=0;x<numPixX;x++) {
2152 colorT daColor = getPxColorNC(x, y);
2153 cmin.tfrmMin(daColor);
2154 cmax.tfrmMax(daColor);
2159 if(absCompMax-absCompMin > 0) {
2160 double rc = 1.0*
static_cast<double>(cmin.maxChanVal-cmin.minChanVal)/
static_cast<double>(cmax.getRed()-cmin.getRed());
2161 double rb = cmin.maxChanVal - 1.0*rc*cmax.getRed();
2162 double gc = 1.0*
static_cast<double>(cmin.maxChanVal-cmin.minChanVal)/
static_cast<double>(cmax.getGreen()-cmin.getGreen());
2163 double gb = cmin.maxChanVal - 1.0*gc*cmax.getGreen();
2164 double bc = 1.0*
static_cast<double>(cmin.maxChanVal-cmin.minChanVal)/
static_cast<double>(cmax.getBlue()-cmin.getBlue());
2165 double bb = cmin.maxChanVal - 1.0*bc*cmax.getBlue();
2166 applyHomoPixTfrm(&colorT::tfrmLinearGreyLevelScaleRGB, rc, rb, gc, gb, bc, bb);
2171 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2172 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2175 for(intCrdT y=0; y<numPixY; y++)
2176 for(intCrdT x=0; x<numPixX; x++)
2177 (getPxColorRefNC(x, y).*HPT)();
2181 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2182 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2185 for(intCrdT y=0; y<numPixY; y++)
2186 for(intCrdT x=0; x<numPixX; x++)
2187 (getPxColorRefNC(x, y).*HPT)(arg1);
2191 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2192 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2195 for(intCrdT y=0; y<numPixY; y++)
2196 for(intCrdT x=0; x<numPixX; x++)
2197 (getPxColorRefNC(x, y).*HPT)(arg1, arg2);
2201 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2202 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2205 for(intCrdT y=0; y<numPixY; y++)
2206 for(intCrdT x=0; x<numPixX; x++)
2207 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3);
2211 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2212 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2214 ramCanvasTpl<colorT, intCrdT, fltCrdT, enableDrawModes>::applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT, colorT, colorT), colorT arg1, colorT arg2, colorT arg3, colorT arg4) {
2215 for(intCrdT y=0; y<numPixY; y++)
2216 for(intCrdT x=0; x<numPixX; x++)
2217 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4);
2221 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2222 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2225 for(intCrdT y=0; y<numPixY; y++)
2226 for(intCrdT x=0; x<numPixX; x++)
2227 (getPxColorRefNC(x, y).*HPT)(arg1);
2231 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2232 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2235 for(intCrdT y=0; y<numPixY; y++)
2236 for(intCrdT x=0; x<numPixX; x++)
2237 (getPxColorRefNC(x, y).*HPT)(arg1, arg2);
2241 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2242 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2245 for(intCrdT y=0; y<numPixY; y++)
2246 for(intCrdT x=0; x<numPixX; x++)
2247 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3);
2251 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2252 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2254 ramCanvasTpl<colorT, intCrdT, fltCrdT, enableDrawModes>::applyHomoPixTfrm(colorT& (colorT::*HPT)(int, int, int, int), int arg1, int arg2, int arg3, int arg4) {
2255 for(intCrdT y=0; y<numPixY; y++)
2256 for(intCrdT x=0; x<numPixX; x++)
2257 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4);
2261 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2262 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2265 for(intCrdT y=0; y<numPixY; y++)
2266 for(intCrdT x=0; x<numPixX; x++)
2267 (getPxColorRefNC(x, y).*HPT)(arg1);
2271 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2272 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2275 for(intCrdT y=0; y<numPixY; y++)
2276 for(intCrdT x=0; x<numPixX; x++)
2277 (getPxColorRefNC(x, y).*HPT)(arg1, arg2);
2281 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2282 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2285 for(intCrdT y=0; y<numPixY; y++)
2286 for(intCrdT x=0; x<numPixX; x++)
2287 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3);
2291 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2292 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2295 double arg1, double arg2, double arg3, double arg4) {
2296 for(intCrdT y=0; y<numPixY; y++)
2297 for(intCrdT x=0; x<numPixX; x++)
2298 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4);
2302 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2303 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2306 double arg1, double arg2, double arg3, double arg4, double arg5) {
2307 for(intCrdT y=0; y<numPixY; y++)
2308 for(intCrdT x=0; x<numPixX; x++)
2309 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4, arg5);
2313 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2314 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2316 double arg1, double arg2, double arg3, double arg4, double arg5, double arg6) {
2317 for(intCrdT y=0; y<numPixY; y++)
2318 for(intCrdT x=0; x<numPixX; x++)
2319 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4, arg5, arg6);
2323 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2324 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2327 intCrdT trgX, intCrdT trgY,
2328 intCrdT wide, intCrdT tall,
2329 intCrdT srcX, intCrdT srcY) {
2332 wide = numPixX-trgX;
2335 if(wide > (numPixX-srcX))
2344 tall = numPixY-srcY;
2347 if(tall > (numPixY-srcY))
2348 tall = numPixY-srcY;
2354 intCrdT xMax = trgX+wide;
2355 intCrdT yMax = trgY+tall;
2356 for(intCrdT y=trgY, ys=srcY; y<yMax; y++, ys++)
2357 for(intCrdT x=trgX, xs=srcX; x<xMax; x++, xs++)
2358 (getPxColorRefNC(x, y).*HPT)(theCanvas.
getPxColor(xs, ys));
2362 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2363 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2369 if( (y1 < 0) || (y1 >= numPixY) )
2377 drawHorzLineNC(x1, x2, y1, color);
2378 }
else if(x1 == x2) {
2379 if( (x1 < 0) || (x1 >= numPixX) )
2387 drawVertLineNC(y1, y2, x1, color);
2397 if( (y2 < 0) || (x2 < 0) || (x1 >= numPixX) || (y1 >= numPixY) )
2408 y2 = y2 - (x2 - numPixX) - 1;
2412 x2 = x2 - (y2 - numPixY) - 1;
2415 for(x=x1,y=y1;x<=x2;y++,x++)
2416 drawPointNC(x, y, color);
2417 }
else if(dx == -dy) {
2418 if( (x2 < 0) || (y2 >= numPixY) || (x1 >= numPixX) || (y1 < 0) )
2425 y2 = y2 + (x2 - (numPixX - 1));
2433 x1 = x1 + (y1 - (numPixY - 1));
2436 for(x=x1,y=y1;x<=x2;y--,x++)
2437 drawPointNC(x, y, color);
2443 if( (y2 < 0) || (x2 < 0) || (x1 >= numPixX) || (y1 >= numPixY) )
2446 y1 = (int)(1.0*y1-x1*dy/dx);
2450 x1 = (int)(1.0*x1-y1*dx/dy);
2454 y2 = (int)((1.0*dy*(numPixX-1)+y1*dx-x1*dy)/dx);
2458 x2 = (int)(((numPixY-1)*dx-y2*dx+x2*dy)/dy);
2467 drawPoint(x, y, color);
2481 drawPoint(x, y, color);
2492 if( (x2 < 0) || (y2 >= numPixY) || (x1 >= numPixX) || (y1 < 0) )
2495 y1 = (int)(1.0*y1-x1*dy/dx);
2499 x2 = (int)(1.0*x2-y2*dx/dy);
2503 y2 = (int)((1.0*dy*(numPixX-1)+y2*dx-x2*dy)/dx);
2507 x1 = (int)(((numPixY-1)*dx-y1*dx+x1*dy)/dy);
2515 drawPoint(x, y, color);
2529 drawPoint(x, y, color);
2545 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2546 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2549 newIntCoordsNC(-1, -1);
2550 if(pixels != NULL) {
2558 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2559 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2563 newIntCoordsNC(new_numPixX, new_numPixY);
2565 if(new_pixels != NULL)
2566 pixels = new_pixels;
2570 pixelsE = pixels+(new_numPixX * new_numPixY);
2574 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2575 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2578 if((numPixX_p<=0) || (numPixY_p<=0)) {
2581 if( (numPixX_p!=numPixX) || (numPixY_p!=numPixY) ) {
2582 colorT *new_pixels =
new colorT[numPixX_p * numPixY_p];
2583 rePointPixels(new_pixels, numPixX_p, numPixY_p);
2591 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2592 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2595 reallocCanvas(new_numPixX_p, new_numPixY_p);
2599 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2600 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2603 if( (new_numPixX_p != numPixX) || (new_numPixY_p != numPixY) ) {
2605 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2608 for(intCrdT y=0;y<new_numPixY_p;y++)
2609 for(intCrdT x=0;x<new_numPixX_p;x++)
2610 new_pixels[new_numPixX_p * (y) + (x)] = color;
2612 intCrdT yMax = std::min(numPixY+y1, new_numPixY_p);
2613 intCrdT xMax = std::min(numPixX+x1, new_numPixX_p);
2616 if ((x1 < new_numPixX_p) && (y1 < new_numPixY_p))
2617 for(intCrdT y=y1;y<yMax;y++)
2618 for(intCrdT x=x1;x<xMax;x++)
2619 new_pixels[new_numPixX_p * (y) + (x)] = getPxColor(x-x1, y-y1);
2621 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2626 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2627 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2630 if( !isCliped(x1, y1) && !isCliped(x2, y2) ) {
2635 intCrdT xp, yp, x, y;
2636 intCrdT new_numPixX_p = x2-x1+1;
2637 intCrdT new_numPixY_p = y2-y1+1;
2638 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2641 for(y=y1,yp=0;y<=y2;y++,yp++)
2642 for(x=x1,xp=0;x<=x2;x++,xp++)
2643 new_pixels[new_numPixX_p * yp + xp] = getPxColor(x, y);
2645 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2650 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2651 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2654 for(intCrdT y=0; y<numPixY/2; y++)
2655 for(intCrdT x=0; x<numPixX; x++) {
2656 colorT aColor = getPxColor(x, numPixY-y-1);
2657 drawPointNC(x, numPixY-y-1, getPxColor(x, y));
2658 drawPointNC(x, y, aColor);
2663 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2664 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2667 for(intCrdT x=0; x<numPixX/2; x++)
2668 for(intCrdT y=0; y<numPixY; y++) {
2669 colorT aColor = getPxColor(numPixX-x-1, y);
2670 drawPointNC(numPixX-x-1, y, getPxColor(x, y));
2671 drawPointNC(x, y, aColor);
2676 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2677 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2680 intCrdT new_numPixX_p = numPixY;
2681 intCrdT new_numPixY_p = numPixX;
2682 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2683 for(intCrdT y=0; y<numPixY; y++)
2684 for(intCrdT x=0; x<numPixX; x++)
2685 new_pixels[new_numPixX_p * (x) + (y)] = getPxColor(x, y);
2686 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2690 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2691 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2694 intCrdT new_numPixX_p = numPixY;
2695 intCrdT new_numPixY_p = numPixX;
2696 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2697 for(intCrdT y=0; y<numPixY; y++)
2698 for(intCrdT x=0; x<numPixX; x++)
2699 new_pixels[new_numPixX_p * (numPixX-x-1) + (y)] = getPxColor(x, y);
2700 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2704 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2705 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2708 intCrdT new_numPixX_p = numPixY;
2709 intCrdT new_numPixY_p = numPixX;
2710 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2711 for(intCrdT y=0; y<numPixY; y++)
2712 for(intCrdT x=0; x<numPixX; x++)
2713 new_pixels[new_numPixX_p * (x) + (numPixY-y-1)] = getPxColor(x, y);
2714 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2718 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2719 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2722 intCrdT new_numPixX_p = numPixX;
2723 intCrdT new_numPixY_p = numPixY;
2724 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2725 for(intCrdT y=0; y<numPixY; y++)
2726 for(intCrdT x=0; x<numPixX; x++)
2727 new_pixels[new_numPixX_p * (numPixY-y-1) + (numPixX-x-1)] = getPxColor(x, y);
2728 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2732 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2733 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2736 unsigned int endiannessProbe = 1;
2737 if(((
char *)&endiannessProbe)[0]) {
2738 return endianType::LITTLE;
2740 return endianType::BIG;
2745 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2746 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2753 if (numBytes == 1) {
2754 uint8_t tmp = (data & 0xff);
2755 oStream.write((
const char *)&tmp, 1);
2758 endianType endiannessToUse = (endianness == endianType::AUTO ? platformEndianness() : endianness);
2759 if(endiannessToUse == endianType::LITTLE) {
2760 for(
int curByte=0; curByte<numBytes; curByte++) {
2761 uint8_t tmp = ((data >> (8*curByte)) & 0xff);
2762 oStream.write((
const char *)&tmp, 1);
2765 for(
int curByte=(numBytes-1); curByte>=0; curByte--) {
2766 uint8_t tmp = ((data >> (8*curByte)) & 0xff);
2767 oStream.write((
const char *)&tmp, 1);
2776 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2777 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2780 for(intCrdT yi=0;yi<numPixY;yi++) {
2781 for(intCrdT xi=0;xi<numPixX;xi++) {
2782 fltCrdT xf = int2realX(xi);
2783 fltCrdT yf = int2realY(yi);
2784 colorT aColor = cFun(xf, yf);
2785 drawPoint(xi, yi, aColor);
2791 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2792 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2795 for(intCrdT yi=0;yi<numPixY;yi++) {
2796 for(intCrdT xi=0;xi<numPixX;xi++) {
2798 colorT aColor = cFun(xyPt);
2799 drawPoint(xi, yi, aColor);
2805 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2806 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2809 for(intCrdT yi=0;yi<numPixY;yi++) {
2810 for(intCrdT xi=0;xi<numPixX;xi++) {
2811 colorT aColor = cFun(xi, yi);
2812 drawPoint(xi, yi, aColor);
2818 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2819 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2822 for(intCrdT yi=0;yi<numPixY;yi++) {
2823 for(intCrdT xi=0;xi<numPixX;xi++) {
2825 colorT aColor = cFun(xyPt);
2826 drawPoint(xi, yi, aColor);
2832 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2833 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2837 std::ofstream outStream;
2838 outStream.open(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
2839 if (outStream.is_open())
2840 outStream.imbue(std::locale::classic());
2846 if(numPixX > 0xffff)
2850 if(numPixY > 0xffff)
2854 writeUIntToStream(outStream, endianType::LITTLE, 1, 0);
2855 writeUIntToStream(outStream, endianType::LITTLE, 1, 0);
2856 writeUIntToStream(outStream, endianType::LITTLE, 1, 2);
2857 writeUIntToStream(outStream, endianType::LITTLE, 2, 0);
2858 writeUIntToStream(outStream, endianType::LITTLE, 2, 0);
2859 writeUIntToStream(outStream, endianType::LITTLE, 1, 0);
2860 writeUIntToStream(outStream, endianType::LITTLE, 2, 0);
2861 writeUIntToStream(outStream, endianType::LITTLE, 2, 0);
2862 writeUIntToStream(outStream, endianType::LITTLE, 2, numPixX);
2863 writeUIntToStream(outStream, endianType::LITTLE, 2, numPixY);
2864 writeUIntToStream(outStream, endianType::LITTLE, 1, 24);
2865 writeUIntToStream(outStream, endianType::LITTLE, 1, 0);
2871 bool yNat = isIntAxOrientationNaturalY();
2872 bool xNat = isIntAxOrientationNaturalX();
2873 for((yNat?y=0:y=(numPixY-1)); (yNat?y<numPixY:y>=0); (yNat?y++:y--)) {
2874 for((xNat?x=0:x=(numPixX-1)); (xNat?x<numPixX:x>=0); (xNat?x++:x--)) {
2875 colorT aColor = getPxColorRefNC(x, y);
2876 writeUIntToStream(outStream, endianType::LITTLE, 1, aColor.getChan_byte(aColor.bestBlueChan()));
2877 writeUIntToStream(outStream, endianType::LITTLE, 1, aColor.getChan_byte(aColor.bestGreenChan()));
2878 writeUIntToStream(outStream, endianType::LITTLE, 1, aColor.getChan_byte(aColor.bestRedChan()));
2885 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2886 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2890 return writeRAWfile(fileName, tmp);
2894 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2895 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2896 template <class rcConT>
2900 std::ofstream outStream;
2901 outStream.open(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
2902 if (outStream.is_open())
2903 outStream.imbue(std::locale::classic());
2907 outStream <<
"MJRRAW\n";
2908 outStream << std::setw(19) << std::setfill(
'0') << rcConverter.
getNumPixX() <<
"x";
2909 outStream << std::setw(19) << std::setfill(
'0') << rcConverter.getNumPixY() <<
"y";
2910 outStream << std::setw(27) << std::setfill(
'0') << rcConT::colorType::channelCount <<
"c";
2911 outStream << std::setw(11) << std::setfill(
'0') << rcConT::colorType::bitsPerChan <<
"b";
2912 outStream << (rcConT::colorType::chanIsUnsigned ?
"UNS" :
"SGN") <<
"s";
2913 outStream << (rcConT::colorType::chanIsInt ?
"INT" :
"FLT") <<
"t";
2914 outStream << (platformEndianness() == endianType::LITTLE ?
"LTL" :
"BIG") <<
"i";
2920 bool yNat = !(rcConverter.isIntAxOrientationNaturalY());
2921 bool xNat = rcConverter.isIntAxOrientationNaturalX();
2922 for((yNat?y=0:y=(rcConverter.getNumPixY()-1)); (yNat?y<rcConverter.getNumPixY():y>=0); (yNat?y++:y--)) {
2923 for((xNat?x=0:x=(rcConverter.getNumPixX()-1)); (xNat?x<rcConverter.getNumPixX():x>=0); (xNat?x++:x--)) {
2924 typename rcConT::colorType aColor = rcConverter.getPxColorNC(x, y);
2925 for(
int c=0; c<aColor.channelCount; c++) {
2926 typename rcConT::colorType::channelType aChanValue = aColor.getChan(c);
2927 outStream.write((
const char *)&aChanValue,
sizeof(
colorChanType));
2935 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2936 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2940 return writeTIFFfile(fileName, tmp, markAlpha);
2944 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2945 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2946 template <class rcConT>
2950 if(rcConT::colorType::bitsPerChan < 8)
2952 if(rcConT::colorType::bitsPerChan > 0xffff)
2954 if(rcConT::colorType::channelCount < 1)
2956 if(rcConT::colorType::channelCount > 0xffff)
2958 if(rcConverter.getNumPixX() < 1)
2960 if(rcConverter.getNumPixX() > 0x7fffffff)
2962 if(rcConverter.getNumPixY() < 1)
2964 if(rcConverter.getNumPixY() > 0x7fffffff)
2966 unsigned long bytesPerRow = rcConverter.
getNumPixX() * rcConT::colorType::bitsPerChan / 8ul * rcConT::colorType::channelCount;
2967 if(bytesPerRow > 0xffffffff)
2969 if(bytesPerRow * rcConverter.getNumPixY() > 0xfffffffff)
2973 const uint16_t tcTIFF_BIGENDIAN = 0x4d4d;
2974 const uint16_t tcTIFF_LITTLEENDIAN = 0x4949;
2975 const uint16_t tcPHOTOMETRIC_MINISBLACK = 1;
2976 const uint16_t tcPHOTOMETRIC_RGB = 2;
2977 const uint16_t tcORIENTATION_TOPLEFT = 1;
2978 const uint16_t tcPLANARCONFIG_CONTIG = 1;
2979 const uint16_t tcRESUNIT_NONE = 1;
2980 const uint16_t tcSAMPLEFORMAT_UINT = 1;
2981 const uint16_t tcSAMPLEFORMAT_IEEEFP = 3;
3002 uint16_t endianNum = (fe == endianType::LITTLE ? tcTIFF_LITTLEENDIAN : tcTIFF_BIGENDIAN);
3003 uint32_t tifWidth = (uint32_t)rcConverter.getNumPixX();
3004 uint32_t tifLength = (uint32_t)rcConverter.getNumPixY();
3005 uint32_t tifSPP = (uint32_t)rcConT::colorType::channelCount;
3006 uint16_t tifBPS = (uint16_t)(rcConT::colorType::bitsPerChan);
3007 uint32_t bytePerSmp = tifBPS / 8;
3008 uint32_t tifSBC = tifLength * tifWidth * bytePerSmp * tifSPP;
3009 bool haveRGB = tifSPP>=3;
3010 uint16_t numImgSmp = (haveRGB ? 3 : 1);
3011 uint16_t tifPMI = (haveRGB ? tcPHOTOMETRIC_RGB : tcPHOTOMETRIC_MINISBLACK);
3012 uint16_t tifPC = tcPLANARCONFIG_CONTIG;
3013 uint16_t tifOri = tcORIENTATION_TOPLEFT;
3014 uint16_t tifResU = tcRESUNIT_NONE;
3015 bool haveXS = !((tifSPP==1) || (tifSPP==3));
3016 bool haveManyXS = tifSPP>4;
3017 uint16_t numTags = 1+14 + (haveXS ? 1 : 0);
3018 bool haveManyBPS = tifSPP>1;
3019 uint32_t numXS = tifSPP - numImgSmp;
3020 uint32_t xResOff = 14 + 12 * numTags;
3021 uint32_t yResOff = xResOff + 8;
3022 uint32_t bpsOff = yResOff + 8;
3023 uint32_t xsOff = bpsOff + (haveManyBPS ? 2 * tifSPP : 0);
3024 uint32_t imgOff = xsOff + (haveManyXS ? 2 * numXS : 0);
3025 uint16_t sampFmt = (rcConT::colorType::chanIsInt ? tcSAMPLEFORMAT_UINT : tcSAMPLEFORMAT_IEEEFP);
3027 std::ofstream outStream;
3028 outStream.open(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
3029 if (outStream.is_open())
3030 outStream.imbue(std::locale::classic());
3034 writeUIntToStream(outStream, fe, 2, endianNum);
3035 writeUIntToStream(outStream, fe, 2, 42);
3036 writeUIntToStream(outStream, fe, 4, 8);
3037 writeUIntToStream(outStream, fe, 2, numTags);
3038 writeUIntToStream(outStream, fe, 2, 0x100); writeUIntToStream(outStream, fe, 2, 4);
3039 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, tifWidth);
3040 writeUIntToStream(outStream, fe, 2, 0x101); writeUIntToStream(outStream, fe, 2, 4);
3041 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, tifLength);
3042 writeUIntToStream(outStream, fe, 2, 0x102); writeUIntToStream(outStream, fe, 2, 3);
3043 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifBPS); writeUIntToStream(outStream, fe, 2, 0);
3044 writeUIntToStream(outStream, fe, 2, 0x103); writeUIntToStream(outStream, fe, 2, 3);
3045 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, 1); writeUIntToStream(outStream, fe, 2, 0);
3046 writeUIntToStream(outStream, fe, 2, 0x106); writeUIntToStream(outStream, fe, 2, 3);
3047 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifPMI); writeUIntToStream(outStream, fe, 2, 0);
3048 writeUIntToStream(outStream, fe, 2, 0x111); writeUIntToStream(outStream, fe, 2, 4);
3049 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, imgOff);
3050 writeUIntToStream(outStream, fe, 2, 0x112); writeUIntToStream(outStream, fe, 2, 3);
3051 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifOri); writeUIntToStream(outStream, fe, 2, 0);
3052 writeUIntToStream(outStream, fe, 2, 0x115); writeUIntToStream(outStream, fe, 2, 3);
3053 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifSPP); writeUIntToStream(outStream, fe, 2, 0);
3054 writeUIntToStream(outStream, fe, 2, 0x116); writeUIntToStream(outStream, fe, 2, 4);
3055 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, tifLength);
3056 writeUIntToStream(outStream, fe, 2, 0x117); writeUIntToStream(outStream, fe, 2, 4);
3057 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, tifSBC);
3058 writeUIntToStream(outStream, fe, 2, 0x11A); writeUIntToStream(outStream, fe, 2, 5);
3059 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, xResOff);
3060 writeUIntToStream(outStream, fe, 2, 0x11B); writeUIntToStream(outStream, fe, 2, 5);
3061 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, yResOff);
3062 writeUIntToStream(outStream, fe, 2, 0x11C); writeUIntToStream(outStream, fe, 2, 3);
3063 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifPC); writeUIntToStream(outStream, fe, 2, 0);
3064 writeUIntToStream(outStream, fe, 2, 0x128); writeUIntToStream(outStream, fe, 2, 3);
3065 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifResU); writeUIntToStream(outStream, fe, 2, 0);
3068 writeUIntToStream(outStream, fe, 2, 0x152); writeUIntToStream(outStream, fe, 2, 3);
3069 writeUIntToStream(outStream, fe, 4, numXS); writeUIntToStream(outStream, fe, 4, xsOff);
3072 writeUIntToStream(outStream, fe, 2, 0x152); writeUIntToStream(outStream, fe, 2, 3);
3073 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, 1);
3075 writeUIntToStream(outStream, fe, 2, 0x152); writeUIntToStream(outStream, fe, 2, 3);
3076 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, 0);
3081 writeUIntToStream(outStream, fe, 2, 0x153);
3082 writeUIntToStream(outStream, fe, 2, 3); writeUIntToStream(outStream, fe, 4, 1);
3083 writeUIntToStream(outStream, fe, 2, sampFmt); writeUIntToStream(outStream, fe, 2, 0);
3085 writeUIntToStream(outStream, fe, 4, 0);
3086 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, 1);
3087 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, 1);
3089 for(
unsigned int i=0; i<tifSPP; i++)
3090 writeUIntToStream(outStream, fe, 2, tifBPS);
3093 for(
unsigned int i=0; i<numXS; i++)
3094 writeUIntToStream(outStream, fe, 4, 0);
3097 bool yNat = !(rcConverter.isIntAxOrientationNaturalY());
3098 bool xNat = rcConverter.isIntAxOrientationNaturalX();
3099 for((yNat?y=0:y=(rcConverter.getNumPixY()-1)); (yNat?y<rcConverter.getNumPixY():y>=0); (yNat?y++:y--)) {
3100 for((xNat?x=0:x=(rcConverter.getNumPixX()-1)); (xNat?x<rcConverter.getNumPixX():x>=0); (xNat?x++:x--)) {
3101 typename rcConT::colorType aColor = rcConverter.getPxColorNC(x, y);
3102 for(
int c=0; c<aColor.channelCount; c++) {
3103 typename rcConT::colorType::channelType aChanValue = aColor.getChan(c);
3104 if (rcConT::colorType::chanIsInt)
3105 writeUIntToStream(outStream, fe, bytePerSmp, aChanValue);
3107 outStream.write((
const char *)&aChanValue, bytePerSmp);
3116 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3117 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3120 intCrdT x1, intCrdT y1,
3121 intCrdT x2, intCrdT y2,
3122 int redChan,
int greenChan,
int blueChan,
int alphaChan) {
3128 if(x1 < 0)
return 1;
3129 if(x2 >= numPixX)
return 1;
3130 if(y1 < 0)
return 1;
3131 if(y2 >= numPixY)
return 1;
3132 if(x2 < x1)
return 2;
3133 if(y2 < y1)
return 3;
3135 int bytesPerPix = (redChan<0?0:1) + (greenChan<0?0:1) + (blueChan<0?0:1) + (alphaChan<0?0:1);
3136 if(bytesPerPix < 1)
return 4;
3139 rasterData = (uint8_t *)
new uint8_t[(y2-y1+1)*(x2-x1+1)*bytesPerPix];
3141 if(rasterData == 0)
return 5;
3143 uint8_t *curPixComp = (uint8_t *)rasterData;
3144 for(intCrdT y=y1; y<=y2; y++) {
3145 for(intCrdT x=x1; x<=x2; x++) {
3146 colorT aColor = getPxColorNC(x, y);
3147 if(redChan >= 0) curPixComp[redChan] = aColor.getChan_byte(aColor.bestRedChan());
3148 if(greenChan >= 0) curPixComp[greenChan] = aColor.getChan_byte(aColor.bestGreenChan());
3149 if(blueChan >= 0) curPixComp[blueChan] = aColor.getChan_byte(aColor.bestBlueChan());
3150 if(alphaChan >= 0) curPixComp[alphaChan] = aColor.getChan_byte(aColor.bestAlphaChan());
3151 curPixComp += bytesPerPix;
3159 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3160 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3163 if(realAxOrientationX == realAxisOrientation::NATURAL)
3164 return static_cast<intCrdT
>((
static_cast<fltCrdT
>(x) - minRealX) / pixWidX);
3166 return static_cast<intCrdT
>((maxRealX -
static_cast<fltCrdT
>(x)) / pixWidX);
3170 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3171 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3174 if(realAxOrientationY == realAxisOrientation::NATURAL)
3175 return static_cast<intCrdT
>((
static_cast<fltCrdT
>(y) - minRealY) / pixWidY);
3177 return static_cast<intCrdT
>((maxRealY -
static_cast<fltCrdT
>(y)) / pixWidY);
3181 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3182 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3185 if(realAxOrientationX == realAxisOrientation::NATURAL)
3186 return static_cast<fltCrdT
>(x) * pixWidX + minRealX;
3188 return maxRealX -
static_cast<fltCrdT
>(x) * pixWidX;
3192 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3193 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3196 if(realAxOrientationY == realAxisOrientation::NATURAL)
3197 return static_cast<fltCrdT
>(y) * pixWidY + minRealY;
3199 return maxRealY -
static_cast<fltCrdT
>(y) * pixWidY;
3203 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3204 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3207 colorT *pixelsCopy =
new colorT[numPixX * numPixY];
3208 for(intCrdT y=0; y<numPixY; y++)
3209 for(intCrdT x=0; x<numPixX; x++)
3210 pixelsCopy[numPixX * y + x] = getPxColorNC(x, y);
3214 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3215 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3218 if(isOnCanvas(x, y)) [[likely]]
3219 return pixels[numPixX * y + x];
3221 return colorT().setToBlack();
3225 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3226 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3229 switch (interpMethod) {
3230 case interpolationType::BILINEAR :
return getPxColorInterpBLin(x, y);
3231 case interpolationType::TRUNCATE :
return getPxColorInterpBLin(x, y);
3232 case interpolationType::NEAREST :
return getPxColorInterpBLin(x, y);
3233 case interpolationType::AVERAGE4 :
return getPxColorInterpBLin(x, y);
3234 case interpolationType::AVERAGE9 :
return getPxColorInterpBLin(x, y);
3235 default :
return colorT(
"green");
3240 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3241 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3244 double x1 = std::floor(x);
3245 double y1 = std::floor(y);
3246 double x2 = std::ceil(x);
3247 double y2 = std::ceil(y);
3249 intCrdT x1i =
static_cast<intCrdT
>(x1);
3250 intCrdT y1i =
static_cast<intCrdT
>(y1);
3251 intCrdT x2i =
static_cast<intCrdT
>(x2);
3252 intCrdT y2i =
static_cast<intCrdT
>(y2);
3256 if ((x1i >= 0) && (y1i >= 0) && (x2i < numPixX) && (y2i < numPixY)) {
3257 double eps = 0.00001;
3258 double xD21 = x2 - x1;
3259 double yD21 = y2 - y1;
3262 wH = (x - x1) / xD21;
3265 wV = (y - y1) / yD21;
3269 c1.linearInterpolate(wH, getPxColorRefNC(x1i, y1i), getPxColorRefNC(x2i, y1i));
3270 c2.linearInterpolate(wH, getPxColorRefNC(x1i, y2i), getPxColorRefNC(x2i, y2i));
3271 cF.linearInterpolate(wV, c1, c2);
3279 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3280 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3283 return getPxColor(
static_cast<intCrdT
>(std::trunc(x)),
static_cast<intCrdT
>(std::trunc(y)));
3287 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3288 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3291 return getPxColor(
static_cast<intCrdT
>(std::round(x)),
static_cast<intCrdT
>(std::round(y)));
3295 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3296 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3299 intCrdT xi =
static_cast<intCrdT
>(std::round(x));
3300 intCrdT yi =
static_cast<intCrdT
>(std::round(y));
3302 for(
int chan=0; chan<colorT::channelCount; chan++) {
3304 for(intCrdT ydi=-1; ydi<=1; ydi++) {
3305 intCrdT icY = yi + ydi;
3306 for(intCrdT xdi=-1; xdi<=1; xdi++) {
3307 intCrdT icX = xi + xdi;
3308 if (!(isCliped(icX, icY))) {
3309 newChanValue += getPxColor(icX, icY).getChan(chan);
3313 newColor.setChan(chan,
static_cast<colorChanType>(newChanValue / 9));
3319 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3320 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3323 double x1 = std::floor(x);
3324 double y1 = std::floor(y);
3325 double x2 = std::ceil(x);
3326 double y2 = std::ceil(y);
3328 intCrdT x1i =
static_cast<intCrdT
>(x1);
3329 intCrdT y1i =
static_cast<intCrdT
>(y1);
3330 intCrdT x2i =
static_cast<intCrdT
>(x2);
3331 intCrdT y2i =
static_cast<intCrdT
>(y2);
3333 if ((x1i >= 0) && (y1i >= 0) && (x2i < numPixX) && (y2i < numPixY)) {
3335 colorT c1 = pixels[numPixX * y1i + x1i];
3336 c1.tfrmMean(pixels[numPixX * y1i + x2i]);
3338 colorT c2 = pixels[numPixX * y2i + x1i];
3339 c2.tfrmMean(pixels[numPixX * y2i + x2i]);
3345 return colorT().setToBlack();
3540 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3541 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3549 for(y=y1; y<=y2; y++)
3560 for(x=x1,y=y1;x<=x2;y++,x++)
3562 }
else if(dx == -dy) {
3563 for(x=x1,y=y1;x<=x2;y--,x++)
3673 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3674 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3677 drawFillTriangleUtl(x1, y1, x2, y2, x3, y3, color, color, color,
true);
3681 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3682 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3685 intCrdT x2, intCrdT y2,
3686 intCrdT x3, intCrdT y3,
3688 drawFillTriangleUtl(x1, y1, x2, y2, x3, y3, color1, color2, color3,
false);
3692 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3693 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3696 intCrdT x2, intCrdT y2,
3697 intCrdT x3, intCrdT y3,
3698 colorT c1, colorT c2, colorT c3,
bool solid) {
3699 static intCrdT *minPts, *maxPts;
3700 static intCrdT numPts;
3702 if( isCliped(x1, y1) || isCliped(x2, y2) || isCliped(x3, y3))
3707 if(minPts == NULL) {
3708 minPts =
new intCrdT[numPixY];
3709 maxPts =
new intCrdT[numPixY];
3712 if(numPts != numPixY) {
3715 minPts =
new intCrdT[numPixY];
3716 maxPts =
new intCrdT[numPixY];
3722 if (!(solid) && ((x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2)) == 0))
3792 minPts[y1] = mjr::math::odr::min3(x1, x2, x3);
3793 maxPts[y1] = mjr::math::odr::max3(x1, x2, x3);
3797 triangleEdger(x1, y1, x3, y3, minPts,
true);
3798 triangleEdger(x2, y2, x3, y3, maxPts,
false);
3800 triangleEdger(x1, y1, x3, y3, minPts,
true);
3801 triangleEdger(x2, y2, x3, y3, maxPts,
false);
3803 triangleEdger(x1, y1, x3, y3, maxPts,
false);
3804 triangleEdger(x2, y2, x3, y3, minPts,
true);
3808 triangleEdger(x1, y1, x3, y3, minPts,
true);
3809 triangleEdger(x2, y2, x1, y1, maxPts,
false);
3811 triangleEdger(x1, y1, x3, y3, maxPts,
false);
3812 triangleEdger(x2, y2, x1, y1, minPts,
true);
3814 triangleEdger(x1, y1, x3, y3, minPts,
true);
3815 triangleEdger(x2, y2, x1, y1, maxPts,
false);
3818 double xOt = (x1*y3+x3*y2-x1*y2-x3*y1);
3819 double xOb = (y3-y1);
3821 triangleEdger(x1, y1, x3, y3, minPts,
true);
3822 triangleEdger(x2, y2, x1, y1, maxPts,
false);
3823 triangleEdger(x2, y2, x3, y3, maxPts,
false);
3825 triangleEdger(x1, y1, x3, y3, maxPts,
false);
3826 triangleEdger(x2, y2, x1, y1, minPts,
true);
3827 triangleEdger(x2, y2, x3, y3, minPts,
true);
3835 for(intCrdT y=y3; y<=y1; y++)
3836 drawLine(minPts[y], y, maxPts[y], y, c1);
3838 for(intCrdT y=y3; y<=y1; y++)
3839 for(intCrdT x=minPts[y]; x<=maxPts[y]; x++) {
3850 drawPointNC(x, y, colorT().wMean(w1/(w1+w2+w3), w2/(w1+w2+w3), w3/(w1+w2+w3), c1, c2, c3));
3856 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3857 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3860 drawPLCurve(numPoints, x, y, dfltColor);
3864 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3865 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3868 for(
int i=0; i<numPoints-1; i++)
3869 drawLine(real2intX(x[i]), real2intY(y[i]), real2intX(x[i+1]), real2intY(y[i+1]), color);
3873 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3874 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3877 drawPLCurve(numPoints, x, y, dfltColor);
3881 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3882 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3885 for(
int i=0; i<numPoints-1; i++)
3886 drawLine(x[i], y[i], x[i+1], y[i+1], color);
3890 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3891 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3894 for(
int i=0; i<numPoints-1; i++)
3895 drawLine(thePoints[i].x, thePoints[i].y, thePoints[i+1].x, thePoints[i+1].y, color);
3899 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3900 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3903 for(
int i=0; i<numPoints-1; i++)
3904 drawLine(thePoints[i].x, thePoints[i].y, thePoints[i+1].x, thePoints[i+1].y, color);
3908 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3909 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3912 drawPLCurve(numPoints, thePoints, dfltColor);
3916 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3917 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3920 drawPLCurve(numPoints, thePoints, dfltColor);
3924 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3925 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3928 drawLine(x1, y1, x2, y2, color);
3929 drawLine(x2, y2, x3, y3, color);
3930 drawLine(x3, y3, x1, y1, color);
3934 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3935 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3940 int d = 1 - radiusX;
3942 int deltaSE = -2 * radiusX + 5;
3944 drawPoint( x+centerX, y+centerY, color);
3945 drawPoint( x+centerX,-y+centerY, color);
3946 drawPoint(-x+centerX, y+centerY, color);
3947 drawPoint(-x+centerX,-y+centerY, color);
3948 drawPoint( y+centerX, x+centerY, color);
3949 drawPoint( y+centerX,-x+centerY, color);
3950 drawPoint(-y+centerX, x+centerY, color);
3951 drawPoint(-y+centerX,-x+centerY, color);
3965 drawPoint( x+centerX, y+centerY, color);
3966 drawPoint( x+centerX,-y+centerY, color);
3967 drawPoint(-x+centerX, y+centerY, color);
3968 drawPoint(-x+centerX,-y+centerY, color);
3969 drawPoint( y+centerX, x+centerY, color);
3970 drawPoint( y+centerX,-x+centerY, color);
3971 drawPoint(-y+centerX, x+centerY, color);
3972 drawPoint(-y+centerX,-x+centerY, color);
3978 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3979 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3985 int d = 1 - radiusX;
3987 int deltaSE = -2 * radiusX + 5;
3993 drawLine( x+centerX, y+centerY, x+centerX, minXY+centerY, color);
3994 drawLine( -x+centerX, y+centerY, -x+centerX, minXY+centerY, color);
3995 drawLine( x+centerX, -y+centerY, x+centerX, -minXY+centerY, color);
3996 drawLine( -x+centerX, -y+centerY, -x+centerX, -minXY+centerY, color);
3997 drawLine( y+centerX, x+centerY, minXY+centerX, x+centerY, color);
3998 drawLine( y+centerX, -x+centerY, minXY+centerX, -x+centerY, color);
3999 drawLine( -y+centerX, x+centerY, -minXY+centerX, x+centerY, color);
4000 drawLine( -y+centerX, -x+centerY, -minXY+centerX, -x+centerY, color);
4019 drawLine( x+centerX, y+centerY, x+centerX, minXY+centerY, color);
4020 drawLine( -x+centerX, y+centerY, -x+centerX, minXY+centerY, color);
4021 drawLine( x+centerX, -y+centerY, x+centerX, -minXY+centerY, color);
4022 drawLine( -x+centerX, -y+centerY, -x+centerX, -minXY+centerY, color);
4023 drawLine( y+centerX, x+centerY, minXY+centerX, x+centerY, color);
4024 drawLine( y+centerX, -x+centerY, minXY+centerX, -x+centerY, color);
4025 drawLine( -y+centerX, x+centerY, -minXY+centerX, x+centerY, color);
4026 drawLine( -y+centerX, -x+centerY, -minXY+centerX, -x+centerY, color);
4031 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4032 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4039 if( (y1 < numPixY) && (x1 < numPixX) && (y2 >= 0) && (x2 >= 0) ) {
4040 int noTop, noBottom, noLeft, noRight;
4041 if((noTop=(y1 < 0)))
4043 if((noLeft=(x1 < 0)))
4045 if((noBottom=(y2 >= numPixY)))
4047 if((noRight=(x2 >= numPixX)))
4051 drawVertLineNC(y1, y2, x1, color);
4053 drawVertLineNC(y1, y2, x2, color);
4055 drawHorzLineNC(x1, x2, y1, color);
4057 drawHorzLineNC(x1, x2, y2, color);
4062 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4063 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4071 if( (y1 >= numPixY) || (x1 >= numPixX) || (y2 < 0) || (x2 < 0) )
4081 for(intCrdT y=y1;y<=y2;y++)
4082 drawHorzLineNC(x1, x2, y, color);
4086 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4087 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4091 if (enableDrawModes)
4093 case drawModeType::SET: getPxColorRefNC(x, y).copy(color);
break;
4094 case drawModeType::XOR: getPxColorRefNC(x, y).tfrmXor(color);
break;
4095 case drawModeType::ADDCLAMP: getPxColorRefNC(x, y).tfrmAddClamp(color);
break;
4096 case drawModeType::AND: getPxColorRefNC(x, y).tfrmAnd(color);
break;
4097 case drawModeType::OR: getPxColorRefNC(x, y).tfrmOr(color);
break;
4098 case drawModeType::DIFFCLAMP: getPxColorRefNC(x, y).tfrmDiffClamp(color);
break;
4099 case drawModeType::MULTCLAMP: getPxColorRefNC(x, y).tfrmMultClamp(color);
break;
4102 getPxColorRefNC(x, y).copy(color);
4106 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4107 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4110 intCrdT new_numPixX_p = xfactor*numPixX;
4111 intCrdT new_numPixY_p = xfactor*numPixY;
4112 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4113 for(intCrdT y=0, y1=0; y<numPixY; y++) {
4114 for(intCrdT x=0, x1=0; x<numPixX; x++) {
4115 for(
int i=0; i<xfactor; i++) {
4116 for(
int j=0; j<xfactor; j++) {
4117 new_pixels[new_numPixX_p * y1 + x1] = getPxColor(x, y);
4128 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
4132 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4133 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4136 intCrdT new_numPixX_p = numPixX/xfactor;
4137 intCrdT new_numPixY_p = numPixY/xfactor;
4138 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4139 for(intCrdT y=0, y1=0; y<new_numPixY_p; y++, y1+=xfactor)
4140 for(intCrdT x=0, x1=0; x<new_numPixX_p; x++, x1+=xfactor)
4141 new_pixels[new_numPixX_p * y + x] = getPxColor(x1, y1);
4143 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
4147 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4148 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4151 intCrdT new_numPixX_p = numPixX/xfactor;
4152 intCrdT new_numPixY_p = numPixY/xfactor;
4153 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4154 for(intCrdT y=0, y1=0; y<new_numPixY_p; y++, y1+=xfactor)
4155 for(intCrdT x=0, x1=0; x<new_numPixX_p; x++, x1+=xfactor) {
4156 std::vector<colorChanArithSDPType> sums(colorT::channelCount,
static_cast<colorChanArithSDPType>(0));
4157 for(
int j=0; j<xfactor; j++)
4158 for(
int i=0; i<xfactor; i++)
4159 for(
int c=0; c<colorT::channelCount; c++)
4160 sums[c] += getPxColor(x1+i, y1+j).getChan(c);
4162 for(
int c=0; c<colorT::channelCount; c++)
4163 aColor.setChan(c,
static_cast<colorChanType>(sums[c] / (xfactor*xfactor)));
4164 new_pixels[new_numPixX_p * y + x] = aColor;
4167 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
4171 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4172 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4175 intCrdT new_numPixX_p = numPixX/xfactor;
4176 intCrdT new_numPixY_p = numPixY/xfactor;
4177 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4179 for(intCrdT y=0, y1=0; y<new_numPixY_p; y++, y1+=xfactor)
4180 for(intCrdT x=0, x1=0; x<new_numPixX_p; x++, x1+=xfactor) {
4181 colorT maxColor = getPxColor(xfactor*x, xfactor*y);
4182 for(
int yi=0; yi<xfactor; yi++)
4183 for(
int xi=0; xi<xfactor; xi++)
4184 maxColor.tfrmMaxI(getPxColor(xfactor*x+xi, xfactor*y+yi));
4185 new_pixels[new_numPixX_p * y + x] = maxColor;
4188 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
4192 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4193 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4196 for(
int yi=0, yis=-(kSize/2); yi<kSize; yi++, yis++)
4197 for(
int xi=0,xis=-(kSize/2); xi<kSize; xi++, xis++)
4198 kernel[kSize * yi + xi] = exp(-(xis*xis+yis*yis)/(2*sd*sd))/(sd*sd*6.283185307179586477);
4200 for(
int i=0; i<(kSize*kSize); i++)
4201 divisor += kernel[i];
4202 for(
int i=0; i<(kSize*kSize); i++)
4203 kernel[i] /= divisor;
4207 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4208 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4211 for(
int yi=0, yis=-(kSize/2); yi<kSize; yi++, yis++)
4212 for(
int xi=0,xis=-(kSize/2); xi<kSize; xi++, xis++)
4213 kernel[kSize * yi + xi] = 1.0/(kSize*kSize);
4217 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4218 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4221 colorT *new_pixels =
new colorT[numPixX * numPixY];
4223 if(std::abs(divisor) < 0.0001) {
4225 for(
int i=0; i<(kWide*kTall); i++)
4226 divisor += kernel[i];
4229 double tmp[colorT::channelCount];
4230 for(intCrdT y=0; y<numPixY; y++) {
4231 for(intCrdT x=0; x<numPixX; x++) {
4233 for(
int chan=0; chan<colorT::channelCount; chan++)
4235 for(
int yi=0, yis=-(kTall/2); yi<kTall; yi++, yis++) {
4236 intCrdT icY = y + yis;
4237 for(
int xi=0,xis=-(kWide/2); xi<kWide; xi++, xis++) {
4238 intCrdT icX = x + xis;
4239 if (!(isCliped(icX, icY))) {
4240 for(
int chan=0; chan<colorT::channelCount; chan++)
4241 tmp[chan] +=
static_cast<double>(getPxColor(icX, icY).getChan(chan)) * kernel[kWide * yi + xi];
4245 for(
int chan=0; chan<colorT::channelCount; chan++)
4246 new_pixels[numPixX * y + x].setChan(chan,
static_cast<colorChanType>(tmp[chan] / divisor));
4249 rePointPixels(new_pixels, numPixX, numPixY);
4253 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4254 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4257 convolution(kernel, kSize, kSize, divisor);
4260 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4261 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4264 convolution(kernel, kSize, kSize, 1.0);
4268 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4269 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4275 if( (glyphNum < 0) || (glyphNum > 3934) )
4283 if(isIntAxOrientationNaturalX())
4284 x1 =
static_cast<intCrdT
>(magX * ((
mjr::hershey::chars[glyphNum]).components[2*i] -
'R'));
4286 x1 =
static_cast<intCrdT
>(magX * (
'R' - (
mjr::hershey::chars[glyphNum]).components[2*i]));
4288 if(isIntAxOrientationNaturalY())
4289 y1 =
static_cast<intCrdT
>(magY * (
'R' - (
mjr::hershey::chars[glyphNum]).components[2*i+1]));
4291 y1 =
static_cast<intCrdT
>(magY * ((
mjr::hershey::chars[glyphNum]).components[2*i+1] -
'R'));
4293 if(actionIsMoveTo) {
4297 drawLine(x1+x, y1+y, aColor);
4304 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4305 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4308 for(
auto &c : aString) {
4310 if((c>=32) && (c<=126))
4312 drawHersheyGlyph(glyphNum, x, y, cex, cex, aColor);
4313 x+=
static_cast<intCrdT
>(spc*cex);
4318 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4319 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4323 intCrdT x, intCrdT y,
4325 double cex, intCrdT spc) {
4326 drawFillRectangle(
static_cast<intCrdT
>(x-spc*cex),
4327 static_cast<intCrdT
>(y-spc*cex),
4328 static_cast<intCrdT
>(x+spc*cex*
static_cast<int>(aString.length())),
4329 static_cast<intCrdT
>(y+spc*cex),
4331 drawString(aString, aFont, x, y, stringColor, cex, spc);
4335 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4336 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4341 std::ifstream iStream(fileName, std::ios_base::binary);
4343 if (!(iStream.good()))
4346 iStream.getline(strBuf, 10,
'\n');
4347 if (!(iStream.good()))
4349 if (iStream.gcount() != 7)
4351 if(std::string(strBuf) != std::string(
"MJRRAW"))
4357 int fileBitPerChan = -1;
4358 bool fileIsSGN =
true, fileHasS =
false;
4359 bool fileIsInt =
true, fileHasT =
false;
4360 bool fileIsLTL =
true, fileHasI =
false;
4362 iStream.getline(strBuf, 100,
'\n');
4363 if (!(iStream.good()))
4365 if (iStream.gcount() != 93)
4368 std::string::size_type tagIdx;
4369 std::string::size_type prcIdx = 0;
4370 std::string strBufS(strBuf);
4371 std::string delChrs(
"abcdefghijklmnopqrstuvwxyz");
4372 int stoiErrorCount = 0;
4375 tagIdx = strBufS.find_first_of(delChrs, prcIdx);
4376 if (tagIdx == std::string::npos)
4381 switch(strBufS[tagIdx]) {
4382 case 'x' : fileWide = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4383 case 'y' : fileTall = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4384 case 'c' : fileChans = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4385 case 'b' : fileBitPerChan = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4386 case 's' : fileIsSGN = (strBufS[prcIdx] ==
'S'); fileHasS =
true;
break;
4387 case 't' : fileIsInt = (strBufS[prcIdx] ==
'I'); fileHasT =
true;
break;
4388 case 'i' : fileIsLTL = (strBufS[prcIdx] ==
'L'); fileHasI =
true;
break;
4396 int fileBytePerChan = fileBitPerChan / 8;
4407 if (stoiErrorCount > 0)
4416 if (fileBitPerChan < 0)
4424 if (fileWide > intCrdMax)
4426 if (fileTall > intCrdMax)
4429 resizeCanvas(fileWide, fileTall);
4431 if (fileWide != numPixX)
4433 if (fileTall != numPixY)
4440 fileIsSGN = ( !(fileIsInt));
4442 if ((colorT::chanIsInt && fileIsSGN))
4445 if ((colorT::chanIsInt && !fileIsInt) ||
4446 (colorT::chanIsFloat && fileIsInt))
4449 if(fileChans != colorT::channelCount)
4452 if(fileBitPerChan != colorT::bitsPerChan)
4456 fileIsLTL = (platformEndianness() == endianType::LITTLE);
4458 bool reverseBits = (( fileIsLTL && (platformEndianness() == endianType::BIG)) ||
4459 (!(fileIsLTL) && (platformEndianness() == endianType::LITTLE)));
4462 bool yNat = !(isIntAxOrientationNaturalY());
4463 bool xNat = isIntAxOrientationNaturalX();
4464 for((yNat?y=0:y=(numPixY-1)); (yNat?y<numPixY:y>=0); (yNat?y++:y--)) {
4465 for((xNat?x=0:x=(numPixX-1)); (xNat?x<numPixX:x>=0); (xNat?x++:x--)) {
4466 for(
int ci=0; ci<fileChans; ci++) {
4469 if (colorT::chanIsInt) {
4475 for(
int bi=0; bi<fileBytePerChan; bi++) {
4477 if (!(iStream.good()))
4479 if (iStream.gcount() != 1)
4489 getPxColorRefNC(x, y).setChan(ci,
static_cast<colorChanType>(pv));
4491 iStream.read(strBuf, fileBytePerChan);
4492 getPxColorRefNC(x, y).setChan(ci, *((
colorChanType*)strBuf));
4502 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4503 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4506#ifndef MRASTER_FOUND_TIFF
4507 std::cerr <<
"ERROR: libTIFF no supported: readTIFFfile can't read " << fileName << std::endl;
4511 uint32_t wTIFF, hTIFF;
4512 uint16_t pmTIFF, pcTIFF, sppTIFF, bpsTIFF, fmtTIFF;
4515 if( !(tif = TIFFOpen(fileName.c_str(),
"r")))
4519 if( 1 != TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &wTIFF))
4521 if( 1 != TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &hTIFF))
4523 if( 1 != TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &sppTIFF))
4525 if( 1 != TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &pcTIFF))
4527 if( 1 != TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &pmTIFF))
4529 if( 1 != TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bpsTIFF))
4533 if( 1 != TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &fmtTIFF))
4559 resizeCanvas(wTIFF, hTIFF);
4561 uint32_t wRC = getNumPixX();
4563 if ((pcTIFF != PLANARCONFIG_CONTIG) && (pcTIFF != PLANARCONFIG_SEPARATE))
4569 uint32_t hRC = getNumPixY();
4574 uint16_t sppRC = colorT::channelCount;
4576 if(sppTIFF != sppRC)
4579 uint16_t bpsRC = colorT::bitsPerPixel / sppRC;
4581 if(bpsTIFF != bpsRC)
4585 if ((fmtTIFF != SAMPLEFORMAT_UINT) && (fmtTIFF != SAMPLEFORMAT_IEEEFP))
4588 if (( colorType::chanIsInt && (SAMPLEFORMAT_UINT != 1)) ||
4589 (!(colorType::chanIsInt) && (SAMPLEFORMAT_IEEEFP != 3)))
4592 bool yNat = !(isIntAxOrientationNaturalY());
4593 bool xNat = isIntAxOrientationNaturalX();
4594 tsize_t scanlinesize = TIFFScanlineSize(tif);
4595 tdata_t scanLineBuffer = _TIFFmalloc(scanlinesize);
4597 if(scanLineBuffer == NULL)
4600 if (pcTIFF == PLANARCONFIG_CONTIG) {
4601 for(uint32_t row=0; row<hTIFF; row++) {
4602 if( !(TIFFReadScanline(tif, scanLineBuffer, row)))
4604 char* p = (
char*)(scanLineBuffer);
4605 for(uint32_t col=0; col<wTIFF; col++) {
4606 int x = (xNat ? col : wTIFF-col-1);
4607 int y = (yNat ? row : hTIFF-row-1);
4608 for(uint16_t samp=0; samp<sppTIFF; samp++) {
4609 getPxColorRefNC(x, y).setChan(samp,
static_cast<colorChanType>(*p));
4610 p = p + (bpsTIFF/8);
4614 }
else if (pcTIFF == PLANARCONFIG_SEPARATE) {
4615 for(uint16_t samp=0; samp<sppTIFF; samp++) {
4616 for(uint32_t row=0; row<hTIFF; row++) {
4617 if( !(TIFFReadScanline(tif, scanLineBuffer, row, samp)))
4619 char* p = (
char*)(scanLineBuffer);
4620 for(uint32_t col=0; col<wTIFF; col++) {
4621 int x = (xNat ? col : wTIFF-col-1);
4622 int y = (yNat ? row : hTIFF-row-1);
4623 getPxColorRefNC(x, y).setChan(samp,
static_cast<colorChanType>(*p));
4624 p = p + (bpsTIFF/8);
4630 _TIFFfree(scanLineBuffer);
4637 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4638 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4641#ifndef MRASTER_FOUND_TIFF
4649 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4650 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4659 for(intCrdT y=0; y<numPixY; y++) {
4660 for(intCrdT x=0; x<numPixX; x++) {
4664 double xS = fv.
x / oScale + Xo;
4665 double yS = fv.
y / oScale + Yo;
4666 if (isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4669 newRamCanvas.
drawPointNC(x, y, getPxColorInterpolate(xS, yS, interpMethod));
4673 return newRamCanvas;
4677 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4678 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4687 for(intCrdT y=0; y<numPixY; y++) {
4688 for(intCrdT x=0; x<numPixX; x++) {
4691 double xS = (HAMatrix[0] * xT + HAMatrix[1] * yT + HAMatrix[2]) / oScale + Xo;
4692 double yS = (HAMatrix[3] * xT + HAMatrix[4] * yT + HAMatrix[5]) / oScale + Yo;
4693 if (isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4696 newRamCanvas.
drawPointNC(x, y, getPxColorInterpolate(xS, yS, interpMethod));
4700 return newRamCanvas;
4704 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4705 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4715 for(intCrdT y=0; y<numPixY; y++) {
4716 for(intCrdT x=0; x<numPixX; x++) {
4717 double xT = (x - Xo);
4718 double yT = (y - Yo);
4719 double rT = std::hypot(xT, yT) / rScale;
4721 double rS = RPoly[0];
4722 for (
unsigned int i=1; i<RPoly.size(); i++)
4723 rS = rS*rT + RPoly[i];
4724 double xS = xT * rS / oScale + Xo;
4725 double yS = yT * rS / oScale + Yo;
4726 if (isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4729 newRamCanvas.
drawPointNC(x, y, getPxColorInterpolate(xS, yS, interpMethod));
4733 return newRamCanvas;
4737 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4738 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4741 std::vector<double>
const& BiPolyY,
4748 for(intCrdT y=0; y<numPixY; y++) {
4749 for(intCrdT x=0; x<numPixX; x++) {
4752 double xS = mjr::math::bply::eval(BiPolyX, xT, yT) / oScale + Xo;
4753 double yS = mjr::math::bply::eval(BiPolyY, xT, yT) / oScale + Yo;
4754 if (isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4757 newRamCanvas.
drawPointNC(x, y, getPxColorInterpolate(xS, yS, interpMethod));
4761 return newRamCanvas;
4766#define MJR_INCLUDE_ramCanvasTpl