34#ifndef MJR_INCLUDE_ramCanvasTpl
42#include "MRMathIVL.hpp"
43#include "MRMathFC.hpp"
44#include "MRMathODR.hpp"
45#include "MRMathBPLY.hpp"
48#ifdef MRASTER_FOUND_TIFF
144 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
145 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
239 const static intCrdT intCrdMax = (1ul << ((
sizeof(intCrdT)*CHAR_BIT-1)/2)) - 3;
258 const static intCrdT intCrdGrdMax = intCrdMax+1;
259 const static intCrdT intCrdGrdMin = -1;
330 void drawFillTriangleUtl(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorT c1, colorT c2, colorT c3,
bool solid);
342 void writeUIntToStream(std::ostream& oStream,
endianType endianness,
int numBytes, uint64_t data);
355 void updRealCoords();
364 void newIntCoordsNC(intCrdT numPixX_p, intCrdT numPixY_p);
376 void reallocCanvas(intCrdT numPixX_p, intCrdT numPixY_p);
382 void rePointPixels(colorT *new_pixels, intCrdT new_numPixX, intCrdT new_numPixY);
390 void triangleEdger(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT* pts,
bool findMin);
423 int exportRasterData(
void* &rasterData, intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2,
int redChan,
int greenChan,
int blueChan,
int alphaChan);
444 ramCanvasTpl(intCrdT numPixX_p, intCrdT numPixY_p, fltCrdT minRealX_p=-1, fltCrdT maxRealX_p=1, fltCrdT minRealY_p=-1, fltCrdT maxRealY_p=1);
475 intCrdT origNumPixX = getNumPixX();
476 expandCanvas(origNumPixX + theCanvas.
getNumPixX(), std::max(getNumPixY(), theCanvas.
getNumPixY()));
477 insertCanvas(theCanvas, origNumPixX);
486 intCrdT origNumPixX = getNumPixX();
487 expandCanvas(origNumPixX + theCanvas.
getNumPixX(), std::max(getNumPixY(), theCanvas.
getNumPixY()), origNumPixX);
488 insertCanvas(theCanvas);
497 intCrdT origNumPixY = getNumPixY();
498 expandCanvas(std::max(getNumPixX(), theCanvas.
getNumPixX()), origNumPixY + theCanvas.
getNumPixY(), 0, origNumPixY);
499 insertCanvas(theCanvas, 0, 0);
508 intCrdT origNumPixY = getNumPixY();
509 expandCanvas(std::max(getNumPixX(), theCanvas.
getNumPixX()), origNumPixY + theCanvas.
getNumPixY());
510 insertCanvas(theCanvas, 0, origNumPixY);
521 for(intCrdT y=0; y<theCanvas.
getNumPixY(); y++)
522 for(intCrdT x=0; x<theCanvas.
getNumPixX(); x++)
535 void resizeCanvas(intCrdT new_numPixX_p, intCrdT new_numPixY_p);
545 void expandCanvas(intCrdT new_numPixX_p, intCrdT new_numPixY_p, intCrdT x1 = 0, intCrdT y1 = 0, colorArgType color = colorT(colorT::minChanVal));
552 void cropCanvas(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2);
564 void newRealCoords(fltCrdT minRealX_p, fltCrdT maxRealX_p, fltCrdT minRealY_p, fltCrdT maxRealY_p);
589 if (isNotSameSize(inRC))
591 for(intCrdT y=0; y<numPixY; y++)
592 for(intCrdT x=0; x<numPixX; x++)
593 if ( !(getPxColorRefNC(x, y).isClose(inRC.
getPxColorRefNC(x, y), epsilon)))
600 if (isNotSameSize(inRC))
602 for(intCrdT y=0; y<numPixY; y++)
603 for(intCrdT x=0; x<numPixX; x++)
640 void flipTranspose();
651 void scaleUpProximal(
int xfactor);
657 void scaleDown1pt(
int xfactor);
662 void scaleDownMax(
int xfactor);
668 void scaleDownMean(
int xfactor);
690 ramCanvasTpl geomTfrmRevRPoly(std::vector<double>
const& RPoly,
695 colorArgType errorColor = colorCornerEnum::GREEN,
696 interpolationType interpMethod = interpolationType::BILINEAR);
709 ramCanvasTpl geomTfrmRevBiPoly(std::vector<double>
const& BiPolyX,
710 std::vector<double>
const& BiPolyY,
714 colorArgType errorColor = colorCornerEnum::GREEN,
715 interpolationType interpMethod = interpolationType::BILINEAR);
732 ramCanvasTpl geomTfrmRevAff(std::vector<double>
const& HAMatrix,
736 colorArgType errorColor = colorCornerEnum::GREEN,
737 interpolationType interpMethod = interpolationType::BILINEAR);
753 colorArgType errorColor = colorCornerEnum::GREEN,
754 interpolationType interpMethod = interpolationType::BILINEAR);
769 void convolution(
double *kernel,
int kWide,
int kTall,
double divisor);
770 void convolution(
double *kernel,
int kSize,
double divisor);
771 void convolution(
double *kernel,
int kSize);
782 void computeConvolutionMatrixGausian(
double *kernel,
int kSize,
double sd);
787 void computeConvolutionMatrixBox(
double *kernel,
int kSize);
794 colorT *
end() {
return pixelsE; }
807 void applyHomoPixTfrm(colorT& (colorT::*HPT)());
808 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double),
double);
809 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double),
double,
double);
810 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double,
double),
double,
double,
double);
811 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double,
double,
double),
double,
double,
double,
double);
812 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double,
double,
double,
double),
double,
double,
double,
double,
double);
813 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double,
double,
double,
double,
double),
double,
double,
double,
double,
double,
double);
814 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
int),
int);
815 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
int,
int),
int,
int);
816 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
int,
int,
int),
int,
int,
int);
817 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
int,
int,
int,
int),
int,
int,
int,
int);
818 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT), colorT);
819 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT), colorT, colorT);
820 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT, colorT), colorT, colorT, colorT);
821 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT, colorT, colorT), colorT, colorT, colorT, colorT);
829 void applyPixelRefFun(colorT::cr2void_func_t f);
839 void autoHistStrech();
844 void autoMaxHistStrechRGB();
860 void combineRamCanvasBinOp(colorT& (colorT::*HPT)(colorT),
862 intCrdT trgX = 0, intCrdT trgY = 0,
863 intCrdT wide = -1, intCrdT tall = -1,
864 intCrdT srcX = 0, intCrdT srcY = 0);
882 void clrCanvasToBlack();
885 void clrCanvasToWhite();
888 void clrCanvasChannelToMin(
int chan);
891 void clrCanvasChannelToMax(
int chan);
907 inline void moveTo(intCrdT x, intCrdT y) { dfltX = x; dfltY = y; }
908 inline void moveTo(fltCrdT x, fltCrdT y) {
moveTo(real2intX(x), real2intY(y)); }
919 inline void setDfltColor(std::string cornerColor) { dfltColor.setToCorner(cornerColor); }
920 inline void setDfltColor(
const char* cornerColor) { dfltColor.setToCorner(std::string(cornerColor)); }
935 drawPointNC(x, y, color);
979 void drawLine(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, colorArgType color);
989 inline void drawLine(fltCrdT x, fltCrdT y) {
drawLine( dfltX, dfltY, real2intX(x), real2intY(y), dfltColor); }
992 inline void drawLine(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2) {
drawLine( x1, y1, x2, y2, dfltColor); }
993 inline void drawLine(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2) {
drawLine( x1, y1, x2, y2, dfltColor); }
994 inline void drawLine(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2,
colorArgType color) {
drawLine( real2intX(x1), real2intY(y1), real2intX(x2), real2intY(y2), color); }
1010 void drawTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorArgType color);
1013 real2intX(thePoints[1].x), real2intY(thePoints[1].y),
1014 real2intX(thePoints[2].x), real2intY(thePoints[2].y), dfltColor); }
1016 real2intX(thePoints[1].x), real2intY(thePoints[1].y),
1017 real2intX(thePoints[2].x), real2intY(thePoints[2].y), color); }
1021 real2intX(point2.
x), real2intY(point2.
y),
1022 real2intX(point3.
x), real2intY(point3.
y), dfltColor); }
1024 real2intX(point2.
x), real2intY(point2.
y),
1025 real2intX(point3.
x), real2intY(point3.
y), color); }
1027 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); }
1028 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); }
1029 inline void drawTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3) {
drawTriangle(x1, y1, x2, y2, x3, y3, dfltColor); }
1046 void drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorArgType color);
1049 real2intX(thePoints[1].x), real2intY(thePoints[1].y),
1050 real2intX(thePoints[2].x), real2intY(thePoints[2].y), dfltColor); }
1052 real2intX(thePoints[1].x), real2intY(thePoints[1].y),
1053 real2intX(thePoints[2].x), real2intY(thePoints[2].y), color); }
1055 thePoints[1].x, thePoints[1].y,
1056 thePoints[2].x, thePoints[2].y, dfltColor); }
1059 real2intX(point2.
x), real2intY(point2.
y),
1060 real2intX(point3.
x), real2intY(point3.
y), dfltColor); }
1062 real2intX(point2.
x), real2intY(point2.
y),
1063 real2intX(point3.
x), real2intY(point3.
y), color); }
1065 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); }
1066 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); }
1067 inline void drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3) {
drawFillTriangle(x1, y1, x2, y2, x3, y3, dfltColor); }
1087 void drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorArgType color1, colorArgType color2, colorArgType color3);
1102 void drawRectangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, colorArgType color);
1111 inline void drawRectangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2) {
drawRectangle(real2intX(x1), real2intY(y1), real2intX(x2), real2intY(y2), dfltColor); }
1128 void drawFillRectangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, colorArgType color);
1159 void drawCircle(intCrdT centerX, intCrdT centerY, intCrdT radiusX, colorArgType color);
1166 inline void drawCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX) {
drawCircle(real2intX(centerX), real2intY(centerY), realDelta2intX(radiusX), dfltColor); }
1167 inline void drawCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX,
colorArgType color) {
drawCircle(real2intX(centerX), real2intY(centerY), realDelta2intX(radiusX), color); }
1168 inline void drawCircle(intCrdT centerX, intCrdT centerY, intCrdT radiusX) {
drawCircle(centerX, centerY, radiusX, dfltColor); }
1186 void drawFillCircle(intCrdT centerX, intCrdT centerY, intCrdT radiusX, colorArgType color);
1193 inline void drawFillCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX) {
drawFillCircle(real2intX(centerX), real2intY(centerY), realDelta2intX(radiusX), dfltColor); }
1205 void drawPLCurve(
int numPoints, intCrdT *x, intCrdT *y, colorArgType color);
1206 void drawPLCurve(
int numPoints, intCrdT *x, intCrdT *y);
1207 void drawPLCurve(
int numPoints, fltCrdT *x, fltCrdT *y, colorArgType color);
1208 void drawPLCurve(
int numPoints, fltCrdT *x, fltCrdT *y);
1209 void drawPLCurve(
int numPoints, pointIntType *thePoints, colorArgType color);
1210 void drawPLCurve(
int numPoints, pointIntType *thePoints);
1211 void drawPLCurve(
int numPoints, pointFltType *thePoints, colorArgType color);
1212 void drawPLCurve(
int numPoints, pointFltType *thePoints);
1228 void drawHersheyGlyph(
int glyphNum, intCrdT x, intCrdT y,
double magX,
double magY, colorArgType aColor);
1229 void drawHersheyGlyph(
int glyphNum, fltCrdT x, fltCrdT y,
double magX,
double magY,
colorArgType aColor) {
drawHersheyGlyph(glyphNum, real2intX(x), real2intY(y), magX, magY, aColor); }
1246 void drawString(std::string aString,
mjr::hershey::font aFont, intCrdT x, intCrdT y, colorArgType aColor,
double cex, intCrdT spc);
1248 drawString(aString, aFont, real2intX(x), real2intY(y), aColor, cex, spc);
1260 void drawStringBox(std::string aString,
mjr::hershey::font aFont, intCrdT x, intCrdT y, colorArgType stringColor, colorArgType boxColor,
double cex, intCrdT spc);
1262 drawStringBox(aString, aFont, real2intX(x), real2intY(y), stringColor, boxColor, cex, spc);
1272 bool supportLibTIFF();
1313 int readTIFFfile(std::string fileName);
1350 template <
class rcConT>
int writeTIFFfile(std::string fileName, rcConT pxFilter,
bool markAlpha =
true);
1353 int writeTIFFfile(std::string fileName,
bool markAlpha =
true);
1371 int writeTGAfile(std::string fileName);
1414 int readRAWfile(std::string fileName);
1465 template <
class rcConT>
int writeRAWfile(std::string fileName, rcConT pxFilter);
1468 int writeRAWfile(std::string fileName);
1479 inline int isCliped(fltCrdT x, fltCrdT y)
const {
return isCliped(real2intX(x), real2intY(y)); }
1480 inline int isCliped(intCrdT x, intCrdT y)
const {
return ((x < 0) || (y < 0) || (x >= numPixX) || (y >= numPixY)); }
1486 inline int isOnCanvas(fltCrdT x, fltCrdT y)
const {
return isCliped(real2intX(x), real2intY(y)); }
1487 inline int isOnCanvas(intCrdT x, intCrdT y)
const {
return ((x >= 0) && (y >= 0) && (x < numPixX) && (y < numPixY)); }
1497 intCrdT real2intX(fltCrdT x)
const;
1502 intCrdT real2intY(fltCrdT y)
const;
1507 fltCrdT int2realX(intCrdT x);
1512 fltCrdT int2realY(intCrdT y);
1540 inline fltCrdT
int2realSideX(intCrdT x,
int side) {
return int2realX(x)+pixWidX/(side ?
static_cast<fltCrdT
>(2.0) :
static_cast<fltCrdT
>(-2.0)); }
1545 inline fltCrdT
int2realSideY(intCrdT y,
int side) {
return int2realY(y)+pixWidY/(side ?
static_cast<fltCrdT
>(2.0) :
static_cast<fltCrdT
>(-2.0)); }
1568 inline intCrdT
realDelta2intX(fltCrdT x)
const {
return static_cast<intCrdT
>(
static_cast<fltCrdT
>(x)/pixWidX); }
1573 inline intCrdT
realDelta2intY(fltCrdT y)
const {
return static_cast<intCrdT
>(
static_cast<fltCrdT
>(y)/pixWidY); }
1578 inline fltCrdT
intDelta2realX(intCrdT x)
const {
return static_cast<fltCrdT
>(x)*pixWidX; }
1583 inline fltCrdT
intDelta2realY(intCrdT y)
const {
return static_cast<fltCrdT
>(y)*pixWidY; }
1677 colorT *clonePixels();
1700 colorT getPxColor(intCrdT x, intCrdT y)
const;
1712 inline colorT
getPxColorWrap(intCrdT x, intCrdT y)
const {
return getPxColorNC(mjr::math::ivl::wrapCO(x, numPixX), mjr::math::ivl::wrapCO(y, numPixY)); }
1729 template <
int chanNum>
1730 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1734 template <
int chanNum>
1735 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1739 template <
int chanNum>
1740 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1744 template <
int chanNum>
1745 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1758 colorT getPxColorInterpolate(
double x,
double y, interpolationType interpMethod = interpolationType::BILINEAR);
1764 colorT getPxColorInterpBLin(
double x,
double y);
1770 colorT getPxColorInterpTrunc(
double x,
double y);
1776 colorT getPxColorInterpNear(
double x,
double y);
1782 colorT getPxColorInterpAvg4(
double x,
double y);
1788 colorT getPxColorInterpAvg9(
double x,
double y);
1802 void drawPointNC(intCrdT x, intCrdT y, colorArgType color);
1807 inline colorT
getPxColorNC(intCrdT x, intCrdT y)
const {
return pixels[numPixX * y + x]; }
1813 inline colorT&
getPxColorRefNC(intCrdT x, intCrdT y)
const {
return pixels[numPixX * y + x]; }
1820 inline void drawHorzLineNC(intCrdT xMin, intCrdT xMax, intCrdT yConst,
colorArgType color) {
for(intCrdT x=xMin;x<=xMax;x++) drawPointNC(x, yConst, color); }
1827 inline void drawVertLineNC(intCrdT yMin, intCrdT yMax, intCrdT xConst,
colorArgType color) {
for(intCrdT y=yMin;y<=yMax;y++) drawPointNC(xConst, y, color); }
1854 void colorizeFltCanvas(std::function<colorT (fltCrdT, fltCrdT)> cFun);
1855 void colorizeFltCanvas(std::function<colorT (pointFltType)> cFun);
1857 void colorizeIntCanvas(std::function<colorT (intCrdT, intCrdT)> cFun);
1858 void colorizeIntCanvas(std::function<colorT (pointIntType)> cFun);
1867 intCrdT retCount = 0;
1868 if( !isCliped(x1, y1) && !isCliped(x2, y2) ) {
1873 for(intCrdT y=y1;y<=y2;y++)
1874 for(intCrdT x=x1;x<=x2;x++)
1876 if ( !(getPxColorRefNC(x, y).isBlack()))
1883 return statNumNonZeroPixels(0, 0, numPixX-1, numPixY-1);
1890 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1891 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1893 newIntCoordsNC(-1, -1);
1894 newRealCoords(0.0, 0.0, 0.0, 0.0);
1897 setRealAxisDefaultOrientation();
1898 setIntAxisDefaultOrientation();
1899 setDefaultDrawMode();
1904 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1905 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1916 for(intCrdT y=0; y<numPixY; y++)
1917 for(intCrdT x=0; x<numPixX; x++)
1923 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1924 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1933 pixels = theCanvas.
pixels;
1939 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1940 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1943 if (
this != &theCanvas) {
1951 pixels = theCanvas.
pixels;
1959 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1960 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1962 newIntCoordsNC(numPixX_p, numPixY_p);
1963 newRealCoords(minRealX_p, maxRealX_p, minRealY_p, maxRealY_p);
1964 pixels =
new colorT[numPixX * numPixY];
1965 pixelsE = pixels + (numPixX * numPixY);
1966 setRealAxisDefaultOrientation();
1967 setIntAxisDefaultOrientation();
1968 setDefaultDrawMode();
1973 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1974 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1976 if(pixels != NULL) {
1983 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1984 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1987 if(numPixX_p > intCrdMax) {
1988 throw std::invalid_argument(
"newIntCoordsNC: numPixX_p argument too large.");
1989 }
else if (numPixY_p > intCrdMax) {
1990 throw std::invalid_argument(
"newIntCoordsNC: numPixY_p argument too large.");
1992 numPix = numPixX_p * numPixY_p;;
1993 numPixX = numPixX_p;
1994 numPixY = numPixY_p;
1999 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2000 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2003 if(minRealX_p > maxRealX_p) {
2004 throw std::invalid_argument(
"newRealCoords: minRealX_p > maxRealX_p.");
2005 }
else if (minRealY_p > maxRealY_p) {
2006 throw std::invalid_argument(
"newRealCoords: minRealY_p > maxRealY_p.");
2008 minRealX = minRealX_p;
2009 maxRealX = maxRealX_p;
2010 minRealY = minRealY_p;
2011 maxRealY = maxRealY_p;
2017 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2018 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2021 canvasWidX = maxRealX - minRealX;
2022 canvasWidY = maxRealY - minRealY;
2023 pixWidX = (numPixX == 0 ? 0 : canvasWidX / numPixX);
2024 pixWidY = (numPixY == 0 ? 0 : canvasWidY / numPixY);
2028 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2029 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2032 for(intCrdT y=0; y<numPixY; y++)
2033 for(intCrdT x=0; x<numPixX; x++)
2034 getPxColorRefNC(x, y).setChanToMin(chan);
2038 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2039 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2042 for(intCrdT y=0; y<numPixY; y++)
2043 for(intCrdT x=0; x<numPixX; x++)
2044 getPxColorRefNC(x, y).setChanToMax(chan);
2048 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2049 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2067 for(intCrdT y=0; y<numPixY; y++)
2068 for(intCrdT x=0; x<numPixX; x++)
2069 getPxColorRefNC(x, y).setToBlack();
2076 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2077 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2080 for(intCrdT y=0; y<numPixY; y++)
2081 for(intCrdT x=0; x<numPixX; x++)
2082 getPxColorRefNC(x, y).setToWhite();
2086 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2087 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2090 clrCanvas(dfltColor);
2094 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2095 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2098 for(intCrdT y=0; y<numPixY; y++)
2099 for(intCrdT x=0; x<numPixX; x++)
2100 drawPointS(x, y, color);
2104 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2105 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2110 for(intCrdT y=0;y<numPixY;y++) {
2111 for(intCrdT x=0;x<numPixX;x++) {
2112 colorT daColor = getPxColorNC(x, y);
2122 double c = 1.0 *
static_cast<double>(colorT::maxChanVal-colorT::minChanVal) /
static_cast<double>(cmax-cmin);
2123 double b =
static_cast<double>(colorT::maxChanVal) - 1.0 * c *
static_cast<double>(cmax);
2124 applyHomoPixTfrm(&colorT::tfrmLinearGreyLevelScale, c, b);
2129 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2130 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2133 colorT cmin; cmin.setChans(cmin.maxChanVal);
2134 colorT cmax; cmax.setChans(cmin.minChanVal);
2135 for(intCrdT y=0;y<numPixY;y++) {
2136 for(intCrdT x=0;x<numPixX;x++) {
2137 colorT daColor = getPxColorNC(x, y);
2138 cmin.tfrmMin(daColor);
2139 cmax.tfrmMax(daColor);
2144 if(absCompMax-absCompMin > 0) {
2145 double rc = 1.0*
static_cast<double>(cmin.maxChanVal-cmin.minChanVal)/
static_cast<double>(cmax.getRed()-cmin.getRed());
2146 double rb = cmin.maxChanVal - 1.0*rc*cmax.getRed();
2147 double gc = 1.0*
static_cast<double>(cmin.maxChanVal-cmin.minChanVal)/
static_cast<double>(cmax.getGreen()-cmin.getGreen());
2148 double gb = cmin.maxChanVal - 1.0*gc*cmax.getGreen();
2149 double bc = 1.0*
static_cast<double>(cmin.maxChanVal-cmin.minChanVal)/
static_cast<double>(cmax.getBlue()-cmin.getBlue());
2150 double bb = cmin.maxChanVal - 1.0*bc*cmax.getBlue();
2151 applyHomoPixTfrm(&colorT::tfrmLinearGreyLevelScaleRGB, rc, rb, gc, gb, bc, bb);
2156 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2157 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2160 for(intCrdT y=0; y<numPixY; y++)
2161 for(intCrdT x=0; x<numPixX; x++)
2162 f(getPxColorRefNC(x, y));
2166 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2167 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2170 for(intCrdT y=0; y<numPixY; y++)
2171 for(intCrdT x=0; x<numPixX; x++)
2172 (getPxColorRefNC(x, y).*HPT)();
2176 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2177 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2180 for(intCrdT y=0; y<numPixY; y++)
2181 for(intCrdT x=0; x<numPixX; x++)
2182 (getPxColorRefNC(x, y).*HPT)(arg1);
2186 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2187 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2190 for(intCrdT y=0; y<numPixY; y++)
2191 for(intCrdT x=0; x<numPixX; x++)
2192 (getPxColorRefNC(x, y).*HPT)(arg1, arg2);
2196 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2197 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2200 for(intCrdT y=0; y<numPixY; y++)
2201 for(intCrdT x=0; x<numPixX; x++)
2202 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3);
2206 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2207 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2209 ramCanvasTpl<colorT, intCrdT, fltCrdT, enableDrawModes>::applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT, colorT, colorT), colorT arg1, colorT arg2, colorT arg3, colorT arg4) {
2210 for(intCrdT y=0; y<numPixY; y++)
2211 for(intCrdT x=0; x<numPixX; x++)
2212 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4);
2209 ramCanvasTpl<colorT, intCrdT, fltCrdT, enableDrawModes>::applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT, colorT, colorT), colorT arg1, colorT arg2, colorT arg3, colorT arg4) {
…}
2216 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2217 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2220 for(intCrdT y=0; y<numPixY; y++)
2221 for(intCrdT x=0; x<numPixX; x++)
2222 (getPxColorRefNC(x, y).*HPT)(arg1);
2226 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2227 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2230 for(intCrdT y=0; y<numPixY; y++)
2231 for(intCrdT x=0; x<numPixX; x++)
2232 (getPxColorRefNC(x, y).*HPT)(arg1, arg2);
2236 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2237 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2240 for(intCrdT y=0; y<numPixY; y++)
2241 for(intCrdT x=0; x<numPixX; x++)
2242 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3);
2246 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2247 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2249 ramCanvasTpl<colorT, intCrdT, fltCrdT, enableDrawModes>::applyHomoPixTfrm(colorT& (colorT::*HPT)(
int,
int,
int,
int),
int arg1,
int arg2,
int arg3,
int arg4) {
2250 for(intCrdT y=0; y<numPixY; y++)
2251 for(intCrdT x=0; x<numPixX; x++)
2252 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4);
2249 ramCanvasTpl<colorT, intCrdT, fltCrdT, enableDrawModes>::applyHomoPixTfrm(colorT& (colorT::*HPT)(
int,
int,
int,
int),
int arg1,
int arg2,
int arg3,
int arg4) {
…}
2256 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2257 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2260 for(intCrdT y=0; y<numPixY; y++)
2261 for(intCrdT x=0; x<numPixX; x++)
2262 (getPxColorRefNC(x, y).*HPT)(arg1);
2266 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2267 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2270 for(intCrdT y=0; y<numPixY; y++)
2271 for(intCrdT x=0; x<numPixX; x++)
2272 (getPxColorRefNC(x, y).*HPT)(arg1, arg2);
2276 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2277 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2280 for(intCrdT y=0; y<numPixY; y++)
2281 for(intCrdT x=0; x<numPixX; x++)
2282 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3);
2286 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2287 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2290 double arg1,
double arg2,
double arg3,
double arg4) {
2291 for(intCrdT y=0; y<numPixY; y++)
2292 for(intCrdT x=0; x<numPixX; x++)
2293 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4);
2297 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2298 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2301 double arg1,
double arg2,
double arg3,
double arg4,
double arg5) {
2302 for(intCrdT y=0; y<numPixY; y++)
2303 for(intCrdT x=0; x<numPixX; x++)
2304 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4, arg5);
2308 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2309 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2311 double arg1,
double arg2,
double arg3,
double arg4,
double arg5,
double arg6) {
2312 for(intCrdT y=0; y<numPixY; y++)
2313 for(intCrdT x=0; x<numPixX; x++)
2314 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4, arg5, arg6);
2318 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2319 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2322 intCrdT trgX, intCrdT trgY,
2323 intCrdT wide, intCrdT tall,
2324 intCrdT srcX, intCrdT srcY) {
2327 wide = numPixX-trgX;
2330 if(wide > (numPixX-srcX))
2339 tall = numPixY-srcY;
2342 if(tall > (numPixY-srcY))
2343 tall = numPixY-srcY;
2349 intCrdT xMax = trgX+wide;
2350 intCrdT yMax = trgY+tall;
2351 for(intCrdT y=trgY, ys=srcY; y<yMax; y++, ys++)
2352 for(intCrdT x=trgX, xs=srcX; x<xMax; x++, xs++)
2353 (getPxColorRefNC(x, y).*HPT)(theCanvas.
getPxColor(xs, ys));
2357 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2358 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2364 if( (y1 < 0) || (y1 >= numPixY) )
2372 drawHorzLineNC(x1, x2, y1, color);
2373 }
else if(x1 == x2) {
2374 if( (x1 < 0) || (x1 >= numPixX) )
2382 drawVertLineNC(y1, y2, x1, color);
2392 if( (y2 < 0) || (x2 < 0) || (x1 >= numPixX) || (y1 >= numPixY) )
2403 y2 = y2 - (x2 - numPixX) - 1;
2407 x2 = x2 - (y2 - numPixY) - 1;
2410 for(x=x1,y=y1;x<=x2;y++,x++)
2411 drawPointNC(x, y, color);
2412 }
else if(dx == -dy) {
2413 if( (x2 < 0) || (y2 >= numPixY) || (x1 >= numPixX) || (y1 < 0) )
2420 y2 = y2 + (x2 - (numPixX - 1));
2428 x1 = x1 + (y1 - (numPixY - 1));
2431 for(x=x1,y=y1;x<=x2;y--,x++)
2432 drawPointNC(x, y, color);
2438 if( (y2 < 0) || (x2 < 0) || (x1 >= numPixX) || (y1 >= numPixY) )
2441 y1 = (int)(1.0*y1-x1*dy/dx);
2445 x1 = (int)(1.0*x1-y1*dx/dy);
2449 y2 = (int)((1.0*dy*(numPixX-1)+y1*dx-x1*dy)/dx);
2453 x2 = (int)(((numPixY-1)*dx-y2*dx+x2*dy)/dy);
2462 drawPoint(x, y, color);
2476 drawPoint(x, y, color);
2487 if( (x2 < 0) || (y2 >= numPixY) || (x1 >= numPixX) || (y1 < 0) )
2490 y1 = (int)(1.0*y1-x1*dy/dx);
2494 x2 = (int)(1.0*x2-y2*dx/dy);
2498 y2 = (int)((1.0*dy*(numPixX-1)+y2*dx-x2*dy)/dx);
2502 x1 = (int)(((numPixY-1)*dx-y1*dx+x1*dy)/dy);
2510 drawPoint(x, y, color);
2524 drawPoint(x, y, color);
2540 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2541 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2544 newIntCoordsNC(-1, -1);
2545 if(pixels != NULL) {
2553 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2554 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2558 newIntCoordsNC(new_numPixX, new_numPixY);
2560 if(new_pixels != NULL)
2561 pixels = new_pixels;
2565 pixelsE = pixels+(new_numPixX * new_numPixY);
2569 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2570 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2573 if((numPixX_p<=0) || (numPixY_p<=0)) {
2576 if( (numPixX_p!=numPixX) || (numPixY_p!=numPixY) ) {
2577 colorT *new_pixels =
new colorT[numPixX_p * numPixY_p];
2578 rePointPixels(new_pixels, numPixX_p, numPixY_p);
2586 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2587 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2590 reallocCanvas(new_numPixX_p, new_numPixY_p);
2594 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2595 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2598 if( (new_numPixX_p != numPixX) || (new_numPixY_p != numPixY) ) {
2600 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2603 for(intCrdT y=0;y<new_numPixY_p;y++)
2604 for(intCrdT x=0;x<new_numPixX_p;x++)
2605 new_pixels[new_numPixX_p * (y) + (x)] = color;
2607 intCrdT yMax = std::min(numPixY+y1, new_numPixY_p);
2608 intCrdT xMax = std::min(numPixX+x1, new_numPixX_p);
2611 if ((x1 < new_numPixX_p) && (y1 < new_numPixY_p))
2612 for(intCrdT y=y1;y<yMax;y++)
2613 for(intCrdT x=x1;x<xMax;x++)
2614 new_pixels[new_numPixX_p * (y) + (x)] = getPxColor(x-x1, y-y1);
2616 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2621 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2622 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2625 if( !isCliped(x1, y1) && !isCliped(x2, y2) ) {
2630 intCrdT xp, yp, x, y;
2631 intCrdT new_numPixX_p = x2-x1+1;
2632 intCrdT new_numPixY_p = y2-y1+1;
2633 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2636 for(y=y1,yp=0;y<=y2;y++,yp++)
2637 for(x=x1,xp=0;x<=x2;x++,xp++)
2638 new_pixels[new_numPixX_p * yp + xp] = getPxColor(x, y);
2640 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2645 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2646 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2649 for(intCrdT y=0; y<numPixY/2; y++)
2650 for(intCrdT x=0; x<numPixX; x++) {
2651 colorT aColor = getPxColor(x, numPixY-y-1);
2652 drawPointNC(x, numPixY-y-1, getPxColor(x, y));
2653 drawPointNC(x, y, aColor);
2658 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2659 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2662 for(intCrdT x=0; x<numPixX/2; x++)
2663 for(intCrdT y=0; y<numPixY; y++) {
2664 colorT aColor = getPxColor(numPixX-x-1, y);
2665 drawPointNC(numPixX-x-1, y, getPxColor(x, y));
2666 drawPointNC(x, y, aColor);
2671 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2672 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2675 intCrdT new_numPixX_p = numPixY;
2676 intCrdT new_numPixY_p = numPixX;
2677 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2678 for(intCrdT y=0; y<numPixY; y++)
2679 for(intCrdT x=0; x<numPixX; x++)
2680 new_pixels[new_numPixX_p * (x) + (y)] = getPxColor(x, y);
2681 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2685 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2686 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2689 intCrdT new_numPixX_p = numPixY;
2690 intCrdT new_numPixY_p = numPixX;
2691 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2692 for(intCrdT y=0; y<numPixY; y++)
2693 for(intCrdT x=0; x<numPixX; x++)
2694 new_pixels[new_numPixX_p * (numPixX-x-1) + (y)] = getPxColor(x, y);
2695 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2699 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2700 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2703 intCrdT new_numPixX_p = numPixY;
2704 intCrdT new_numPixY_p = numPixX;
2705 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2706 for(intCrdT y=0; y<numPixY; y++)
2707 for(intCrdT x=0; x<numPixX; x++)
2708 new_pixels[new_numPixX_p * (x) + (numPixY-y-1)] = getPxColor(x, y);
2709 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2713 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2714 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2717 intCrdT new_numPixX_p = numPixX;
2718 intCrdT new_numPixY_p = numPixY;
2719 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2720 for(intCrdT y=0; y<numPixY; y++)
2721 for(intCrdT x=0; x<numPixX; x++)
2722 new_pixels[new_numPixX_p * (numPixY-y-1) + (numPixX-x-1)] = getPxColor(x, y);
2723 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2727 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2728 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2731 unsigned int endiannessProbe = 1;
2732 if(((
char *)&endiannessProbe)[0]) {
2733 return endianType::LITTLE;
2735 return endianType::BIG;
2740 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2741 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2748 if (numBytes == 1) {
2749 uint8_t tmp = (data & 0xff);
2750 oStream.write((
const char *)&tmp, 1);
2753 endianType endiannessToUse = (endianness == endianType::AUTO ? platformEndianness() : endianness);
2754 if(endiannessToUse == endianType::LITTLE) {
2755 for(
int curByte=0; curByte<numBytes; curByte++) {
2756 uint8_t tmp = ((data >> (8*curByte)) & 0xff);
2757 oStream.write((
const char *)&tmp, 1);
2760 for(
int curByte=(numBytes-1); curByte>=0; curByte--) {
2761 uint8_t tmp = ((data >> (8*curByte)) & 0xff);
2762 oStream.write((
const char *)&tmp, 1);
2771 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2772 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2775 for(intCrdT yi=0;yi<numPixY;yi++) {
2776 for(intCrdT xi=0;xi<numPixX;xi++) {
2777 fltCrdT xf = int2realX(xi);
2778 fltCrdT yf = int2realY(yi);
2779 colorT aColor = cFun(xf, yf);
2780 drawPoint(xi, yi, aColor);
2786 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2787 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2790 for(intCrdT yi=0;yi<numPixY;yi++) {
2791 for(intCrdT xi=0;xi<numPixX;xi++) {
2793 colorT aColor = cFun(xyPt);
2794 drawPoint(xi, yi, aColor);
2800 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2801 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2804 for(intCrdT yi=0;yi<numPixY;yi++) {
2805 for(intCrdT xi=0;xi<numPixX;xi++) {
2806 colorT aColor = cFun(xi, yi);
2807 drawPoint(xi, yi, aColor);
2813 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2814 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2817 for(intCrdT yi=0;yi<numPixY;yi++) {
2818 for(intCrdT xi=0;xi<numPixX;xi++) {
2820 colorT aColor = cFun(xyPt);
2821 drawPoint(xi, yi, aColor);
2827 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2828 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2832 std::ofstream outStream;
2833 outStream.open(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
2834 if (outStream.is_open())
2835 outStream.imbue(std::locale::classic());
2841 if(numPixX > 0xffff)
2845 if(numPixY > 0xffff)
2849 writeUIntToStream(outStream, endianType::LITTLE, 1, 0);
2850 writeUIntToStream(outStream, endianType::LITTLE, 1, 0);
2851 writeUIntToStream(outStream, endianType::LITTLE, 1, 2);
2852 writeUIntToStream(outStream, endianType::LITTLE, 2, 0);
2853 writeUIntToStream(outStream, endianType::LITTLE, 2, 0);
2854 writeUIntToStream(outStream, endianType::LITTLE, 1, 0);
2855 writeUIntToStream(outStream, endianType::LITTLE, 2, 0);
2856 writeUIntToStream(outStream, endianType::LITTLE, 2, 0);
2857 writeUIntToStream(outStream, endianType::LITTLE, 2, numPixX);
2858 writeUIntToStream(outStream, endianType::LITTLE, 2, numPixY);
2859 writeUIntToStream(outStream, endianType::LITTLE, 1, 24);
2860 writeUIntToStream(outStream, endianType::LITTLE, 1, 0);
2866 bool yNat = isIntAxOrientationNaturalY();
2867 bool xNat = isIntAxOrientationNaturalX();
2868 for((yNat?y=0:y=(numPixY-1)); (yNat?y<numPixY:y>=0); (yNat?y++:y--)) {
2869 for((xNat?x=0:x=(numPixX-1)); (xNat?x<numPixX:x>=0); (xNat?x++:x--)) {
2870 colorT aColor = getPxColorRefNC(x, y);
2871 writeUIntToStream(outStream, endianType::LITTLE, 1, aColor.getChan_byte(aColor.bestBlueChan()));
2872 writeUIntToStream(outStream, endianType::LITTLE, 1, aColor.getChan_byte(aColor.bestGreenChan()));
2873 writeUIntToStream(outStream, endianType::LITTLE, 1, aColor.getChan_byte(aColor.bestRedChan()));
2880 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2881 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2885 return writeRAWfile(fileName, tmp);
2889 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2890 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2891 template <class rcConT>
2895 std::ofstream outStream;
2896 outStream.open(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
2897 if (outStream.is_open())
2898 outStream.imbue(std::locale::classic());
2902 outStream <<
"MJRRAW\n";
2903 outStream << std::setw(19) << std::setfill(
'0') << pxFilter.getNumPixX() <<
"x";
2904 outStream << std::setw(19) << std::setfill(
'0') << pxFilter.getNumPixY() <<
"y";
2905 outStream << std::setw(27) << std::setfill(
'0') << rcConT::colorType::channelCount <<
"c";
2906 outStream << std::setw(11) << std::setfill(
'0') << rcConT::colorType::bitsPerChan <<
"b";
2907 outStream << (rcConT::colorType::chanIsUnsigned ?
"UNS" :
"SGN") <<
"s";
2908 outStream << (rcConT::colorType::chanIsInt ?
"INT" :
"FLT") <<
"t";
2909 outStream << (platformEndianness() == endianType::LITTLE ?
"LTL" :
"BIG") <<
"i";
2915 bool yNat = !(pxFilter.isIntAxOrientationNaturalY());
2916 bool xNat = pxFilter.isIntAxOrientationNaturalX();
2917 for((yNat?y=0:y=(pxFilter.getNumPixY()-1)); (yNat?y<pxFilter.getNumPixY():y>=0); (yNat?y++:y--)) {
2918 for((xNat?x=0:x=(pxFilter.getNumPixX()-1)); (xNat?x<pxFilter.getNumPixX():x>=0); (xNat?x++:x--)) {
2919 typename rcConT::colorType aColor = pxFilter.getPxColorNC(x, y);
2920 for(
int c=0; c<aColor.channelCount; c++) {
2921 typename rcConT::colorType::channelType aChanValue = aColor.getChan(c);
2922 outStream.write((
const char *)&aChanValue,
sizeof(
colorChanType));
2930 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2931 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2935 return writeTIFFfile(fileName, tmp, markAlpha);
2939 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2940 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2941 template <class rcConT>
2945 if(rcConT::colorType::bitsPerChan < 8)
2947 if(rcConT::colorType::bitsPerChan > 0xffff)
2949 if(rcConT::colorType::channelCount < 1)
2951 if(rcConT::colorType::channelCount > 0xffff)
2953 if(pxFilter.getNumPixX() < 1)
2955 if(pxFilter.getNumPixX() > 0x7fffffff)
2957 if(pxFilter.getNumPixY() < 1)
2959 if(pxFilter.getNumPixY() > 0x7fffffff)
2961 unsigned long bytesPerRow = pxFilter.getNumPixX() * rcConT::colorType::bitsPerChan / 8ul * rcConT::colorType::channelCount;
2962 if(bytesPerRow > 0xffffffff)
2964 if(bytesPerRow * pxFilter.getNumPixY() > 0xfffffffff)
2968 const uint16_t tcTIFF_BIGENDIAN = 0x4d4d;
2969 const uint16_t tcTIFF_LITTLEENDIAN = 0x4949;
2970 const uint16_t tcPHOTOMETRIC_MINISBLACK = 1;
2971 const uint16_t tcPHOTOMETRIC_RGB = 2;
2972 const uint16_t tcORIENTATION_TOPLEFT = 1;
2973 const uint16_t tcPLANARCONFIG_CONTIG = 1;
2974 const uint16_t tcRESUNIT_NONE = 1;
2975 const uint16_t tcSAMPLEFORMAT_UINT = 1;
2976 const uint16_t tcSAMPLEFORMAT_IEEEFP = 3;
2997 uint16_t endianNum = (fe == endianType::LITTLE ? tcTIFF_LITTLEENDIAN : tcTIFF_BIGENDIAN);
2998 uint32_t tifWidth = (uint32_t)pxFilter.getNumPixX();
2999 uint32_t tifLength = (uint32_t)pxFilter.getNumPixY();
3000 uint32_t tifSPP = (uint32_t)rcConT::colorType::channelCount;
3001 uint16_t tifBPS = (uint16_t)(rcConT::colorType::bitsPerChan);
3002 uint32_t bytePerSmp = tifBPS / 8;
3003 uint32_t tifSBC = tifLength * tifWidth * bytePerSmp * tifSPP;
3004 bool haveRGB = tifSPP>=3;
3005 uint16_t numImgSmp = (haveRGB ? 3 : 1);
3006 uint16_t tifPMI = (haveRGB ? tcPHOTOMETRIC_RGB : tcPHOTOMETRIC_MINISBLACK);
3007 uint16_t tifPC = tcPLANARCONFIG_CONTIG;
3008 uint16_t tifOri = tcORIENTATION_TOPLEFT;
3009 uint16_t tifResU = tcRESUNIT_NONE;
3010 bool haveXS = !((tifSPP==1) || (tifSPP==3));
3011 bool haveManyXS = tifSPP>4;
3012 uint16_t numTags = 1+14 + (haveXS ? 1 : 0);
3013 bool haveManyBPS = tifSPP>1;
3014 uint32_t numXS = tifSPP - numImgSmp;
3015 uint32_t xResOff = 14 + 12 * numTags;
3016 uint32_t yResOff = xResOff + 8;
3017 uint32_t bpsOff = yResOff + 8;
3018 uint32_t xsOff = bpsOff + (haveManyBPS ? 2 * tifSPP : 0);
3019 uint32_t imgOff = xsOff + (haveManyXS ? 2 * numXS : 0);
3020 uint16_t sampFmt = (rcConT::colorType::chanIsInt ? tcSAMPLEFORMAT_UINT : tcSAMPLEFORMAT_IEEEFP);
3022 std::ofstream outStream;
3023 outStream.open(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
3024 if (outStream.is_open())
3025 outStream.imbue(std::locale::classic());
3029 writeUIntToStream(outStream, fe, 2, endianNum);
3030 writeUIntToStream(outStream, fe, 2, 42);
3031 writeUIntToStream(outStream, fe, 4, 8);
3032 writeUIntToStream(outStream, fe, 2, numTags);
3033 writeUIntToStream(outStream, fe, 2, 0x100); writeUIntToStream(outStream, fe, 2, 4);
3034 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, tifWidth);
3035 writeUIntToStream(outStream, fe, 2, 0x101); writeUIntToStream(outStream, fe, 2, 4);
3036 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, tifLength);
3037 writeUIntToStream(outStream, fe, 2, 0x102); writeUIntToStream(outStream, fe, 2, 3);
3038 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifBPS); writeUIntToStream(outStream, fe, 2, 0);
3039 writeUIntToStream(outStream, fe, 2, 0x103); writeUIntToStream(outStream, fe, 2, 3);
3040 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, 1); writeUIntToStream(outStream, fe, 2, 0);
3041 writeUIntToStream(outStream, fe, 2, 0x106); writeUIntToStream(outStream, fe, 2, 3);
3042 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifPMI); writeUIntToStream(outStream, fe, 2, 0);
3043 writeUIntToStream(outStream, fe, 2, 0x111); writeUIntToStream(outStream, fe, 2, 4);
3044 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, imgOff);
3045 writeUIntToStream(outStream, fe, 2, 0x112); writeUIntToStream(outStream, fe, 2, 3);
3046 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifOri); writeUIntToStream(outStream, fe, 2, 0);
3047 writeUIntToStream(outStream, fe, 2, 0x115); writeUIntToStream(outStream, fe, 2, 3);
3048 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifSPP); writeUIntToStream(outStream, fe, 2, 0);
3049 writeUIntToStream(outStream, fe, 2, 0x116); writeUIntToStream(outStream, fe, 2, 4);
3050 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, tifLength);
3051 writeUIntToStream(outStream, fe, 2, 0x117); writeUIntToStream(outStream, fe, 2, 4);
3052 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, tifSBC);
3053 writeUIntToStream(outStream, fe, 2, 0x11A); writeUIntToStream(outStream, fe, 2, 5);
3054 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, xResOff);
3055 writeUIntToStream(outStream, fe, 2, 0x11B); writeUIntToStream(outStream, fe, 2, 5);
3056 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, yResOff);
3057 writeUIntToStream(outStream, fe, 2, 0x11C); writeUIntToStream(outStream, fe, 2, 3);
3058 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifPC); writeUIntToStream(outStream, fe, 2, 0);
3059 writeUIntToStream(outStream, fe, 2, 0x128); writeUIntToStream(outStream, fe, 2, 3);
3060 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifResU); writeUIntToStream(outStream, fe, 2, 0);
3063 writeUIntToStream(outStream, fe, 2, 0x152); writeUIntToStream(outStream, fe, 2, 3);
3064 writeUIntToStream(outStream, fe, 4, numXS); writeUIntToStream(outStream, fe, 4, xsOff);
3067 writeUIntToStream(outStream, fe, 2, 0x152); writeUIntToStream(outStream, fe, 2, 3);
3068 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, 1);
3070 writeUIntToStream(outStream, fe, 2, 0x152); writeUIntToStream(outStream, fe, 2, 3);
3071 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, 0);
3076 writeUIntToStream(outStream, fe, 2, 0x153);
3077 writeUIntToStream(outStream, fe, 2, 3); writeUIntToStream(outStream, fe, 4, 1);
3078 writeUIntToStream(outStream, fe, 2, sampFmt); writeUIntToStream(outStream, fe, 2, 0);
3080 writeUIntToStream(outStream, fe, 4, 0);
3081 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, 1);
3082 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, 1);
3084 for(
unsigned int i=0; i<tifSPP; i++)
3085 writeUIntToStream(outStream, fe, 2, tifBPS);
3088 for(
unsigned int i=0; i<numXS; i++)
3089 writeUIntToStream(outStream, fe, 4, 0);
3092 bool yNat = !(pxFilter.isIntAxOrientationNaturalY());
3093 bool xNat = pxFilter.isIntAxOrientationNaturalX();
3094 for((yNat?y=0:y=(pxFilter.getNumPixY()-1)); (yNat?y<pxFilter.getNumPixY():y>=0); (yNat?y++:y--)) {
3095 for((xNat?x=0:x=(pxFilter.getNumPixX()-1)); (xNat?x<pxFilter.getNumPixX():x>=0); (xNat?x++:x--)) {
3096 typename rcConT::colorType aColor = pxFilter.getPxColorNC(x, y);
3097 for(
int c=0; c<aColor.channelCount; c++) {
3098 typename rcConT::colorType::channelType aChanValue = aColor.getChan(c);
3099 if (rcConT::colorType::chanIsInt)
3100 writeUIntToStream(outStream, fe, bytePerSmp, aChanValue);
3102 outStream.write((
const char *)&aChanValue, bytePerSmp);
3111 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3112 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3115 intCrdT x1, intCrdT y1,
3116 intCrdT x2, intCrdT y2,
3117 int redChan,
int greenChan,
int blueChan,
int alphaChan) {
3123 if(x1 < 0)
return 1;
3124 if(x2 >= numPixX)
return 1;
3125 if(y1 < 0)
return 1;
3126 if(y2 >= numPixY)
return 1;
3127 if(x2 < x1)
return 2;
3128 if(y2 < y1)
return 3;
3130 int bytesPerPix = (redChan<0?0:1) + (greenChan<0?0:1) + (blueChan<0?0:1) + (alphaChan<0?0:1);
3131 if(bytesPerPix < 1)
return 4;
3134 rasterData = (uint8_t *)
new uint8_t[(y2-y1+1)*(x2-x1+1)*bytesPerPix];
3136 if(rasterData == 0)
return 5;
3138 uint8_t *curPixComp = (uint8_t *)rasterData;
3139 for(intCrdT y=y1; y<=y2; y++) {
3140 for(intCrdT x=x1; x<=x2; x++) {
3141 colorT aColor = getPxColorNC(x, y);
3142 if(redChan >= 0) curPixComp[redChan] = aColor.getChan_byte(aColor.bestRedChan());
3143 if(greenChan >= 0) curPixComp[greenChan] = aColor.getChan_byte(aColor.bestGreenChan());
3144 if(blueChan >= 0) curPixComp[blueChan] = aColor.getChan_byte(aColor.bestBlueChan());
3145 if(alphaChan >= 0) curPixComp[alphaChan] = aColor.getChan_byte(aColor.bestAlphaChan());
3146 curPixComp += bytesPerPix;
3154 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3155 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3158 if(realAxOrientationX == realAxisOrientation::NATURAL)
3159 return static_cast<intCrdT
>((
static_cast<fltCrdT
>(x) - minRealX) / pixWidX);
3161 return static_cast<intCrdT
>((maxRealX -
static_cast<fltCrdT
>(x)) / pixWidX);
3165 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3166 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3169 if(realAxOrientationY == realAxisOrientation::NATURAL)
3170 return static_cast<intCrdT
>((
static_cast<fltCrdT
>(y) - minRealY) / pixWidY);
3172 return static_cast<intCrdT
>((maxRealY -
static_cast<fltCrdT
>(y)) / pixWidY);
3176 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3177 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3180 if(realAxOrientationX == realAxisOrientation::NATURAL)
3181 return static_cast<fltCrdT
>(x) * pixWidX + minRealX;
3183 return maxRealX -
static_cast<fltCrdT
>(x) * pixWidX;
3187 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3188 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3191 if(realAxOrientationY == realAxisOrientation::NATURAL)
3192 return static_cast<fltCrdT
>(y) * pixWidY + minRealY;
3194 return maxRealY -
static_cast<fltCrdT
>(y) * pixWidY;
3198 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3199 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3202 colorT *pixelsCopy =
new colorT[numPixX * numPixY];
3203 for(intCrdT y=0; y<numPixY; y++)
3204 for(intCrdT x=0; x<numPixX; x++)
3205 pixelsCopy[numPixX * y + x] = getPxColorNC(x, y);
3209 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3210 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3213 if(isOnCanvas(x, y)) [[likely]]
3214 return pixels[numPixX * y + x];
3216 return colorT().setToBlack();
3220 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3221 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3224 switch (interpMethod) {
3225 case interpolationType::BILINEAR :
return getPxColorInterpBLin(x, y);
3226 case interpolationType::TRUNCATE :
return getPxColorInterpBLin(x, y);
3227 case interpolationType::NEAREST :
return getPxColorInterpBLin(x, y);
3228 case interpolationType::AVERAGE4 :
return getPxColorInterpBLin(x, y);
3229 case interpolationType::AVERAGE9 :
return getPxColorInterpBLin(x, y);
3230 default :
return colorT(
"green");
3235 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3236 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3239 double x1 = std::floor(x);
3240 double y1 = std::floor(y);
3241 double x2 = std::ceil(x);
3242 double y2 = std::ceil(y);
3244 intCrdT x1i =
static_cast<intCrdT
>(x1);
3245 intCrdT y1i =
static_cast<intCrdT
>(y1);
3246 intCrdT x2i =
static_cast<intCrdT
>(x2);
3247 intCrdT y2i =
static_cast<intCrdT
>(y2);
3251 if ((x1i >= 0) && (y1i >= 0) && (x2i < numPixX) && (y2i < numPixY)) {
3252 double eps = 0.00001;
3253 double xD21 = x2 - x1;
3254 double yD21 = y2 - y1;
3256 if (mjr::math::fc::not_near_zero(xD21, eps))
3257 wH = (x - x1) / xD21;
3259 if (mjr::math::fc::not_near_zero(yD21, eps))
3260 wV = (y - y1) / yD21;
3264 c1.linearInterpolate(wH, getPxColorRefNC(x1i, y1i), getPxColorRefNC(x2i, y1i));
3265 c2.linearInterpolate(wH, getPxColorRefNC(x1i, y2i), getPxColorRefNC(x2i, y2i));
3266 cF.linearInterpolate(wV, c1, c2);
3274 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3275 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3278 return getPxColor(
static_cast<intCrdT
>(std::trunc(x)),
static_cast<intCrdT
>(std::trunc(y)));
3282 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3283 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3286 return getPxColor(
static_cast<intCrdT
>(std::round(x)),
static_cast<intCrdT
>(std::round(y)));
3290 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3291 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3294 intCrdT xi =
static_cast<intCrdT
>(std::round(x));
3295 intCrdT yi =
static_cast<intCrdT
>(std::round(y));
3297 for(
int chan=0; chan<colorT::channelCount; chan++) {
3299 for(intCrdT ydi=-1; ydi<=1; ydi++) {
3300 intCrdT icY = yi + ydi;
3301 for(intCrdT xdi=-1; xdi<=1; xdi++) {
3302 intCrdT icX = xi + xdi;
3303 if (!(isCliped(icX, icY))) {
3304 newChanValue += getPxColor(icX, icY).getChan(chan);
3308 newColor.setChan(chan,
static_cast<colorChanType>(newChanValue / 9));
3314 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3315 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3318 double x1 = std::floor(x);
3319 double y1 = std::floor(y);
3320 double x2 = std::ceil(x);
3321 double y2 = std::ceil(y);
3323 intCrdT x1i =
static_cast<intCrdT
>(x1);
3324 intCrdT y1i =
static_cast<intCrdT
>(y1);
3325 intCrdT x2i =
static_cast<intCrdT
>(x2);
3326 intCrdT y2i =
static_cast<intCrdT
>(y2);
3328 if ((x1i >= 0) && (y1i >= 0) && (x2i < numPixX) && (y2i < numPixY)) {
3330 colorT c1 = pixels[numPixX * y1i + x1i];
3331 c1.tfrmMean(pixels[numPixX * y1i + x2i]);
3333 colorT c2 = pixels[numPixX * y2i + x1i];
3334 c2.tfrmMean(pixels[numPixX * y2i + x2i]);
3340 return colorT().setToBlack();
3535 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3536 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3544 for(y=y1; y<=y2; y++)
3555 for(x=x1,y=y1;x<=x2;y++,x++)
3557 }
else if(dx == -dy) {
3558 for(x=x1,y=y1;x<=x2;y--,x++)
3668 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3669 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3672 drawFillTriangleUtl(x1, y1, x2, y2, x3, y3, color, color, color,
true);
3676 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3677 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3680 intCrdT x2, intCrdT y2,
3681 intCrdT x3, intCrdT y3,
3683 drawFillTriangleUtl(x1, y1, x2, y2, x3, y3, color1, color2, color3,
false);
3687 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3688 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3691 intCrdT x2, intCrdT y2,
3692 intCrdT x3, intCrdT y3,
3693 colorT c1, colorT c2, colorT c3,
bool solid) {
3694 static intCrdT *minPts, *maxPts;
3695 static intCrdT numPts;
3697 if( isCliped(x1, y1) || isCliped(x2, y2) || isCliped(x3, y3))
3702 if(minPts == NULL) {
3703 minPts =
new intCrdT[numPixY];
3704 maxPts =
new intCrdT[numPixY];
3707 if(numPts != numPixY) {
3710 minPts =
new intCrdT[numPixY];
3711 maxPts =
new intCrdT[numPixY];
3717 if (!(solid) && ((x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2)) == 0))
3787 minPts[y1] = mjr::math::odr::min3(x1, x2, x3);
3788 maxPts[y1] = mjr::math::odr::max3(x1, x2, x3);
3792 triangleEdger(x1, y1, x3, y3, minPts,
true);
3793 triangleEdger(x2, y2, x3, y3, maxPts,
false);
3795 triangleEdger(x1, y1, x3, y3, minPts,
true);
3796 triangleEdger(x2, y2, x3, y3, maxPts,
false);
3798 triangleEdger(x1, y1, x3, y3, maxPts,
false);
3799 triangleEdger(x2, y2, x3, y3, minPts,
true);
3803 triangleEdger(x1, y1, x3, y3, minPts,
true);
3804 triangleEdger(x2, y2, x1, y1, maxPts,
false);
3806 triangleEdger(x1, y1, x3, y3, maxPts,
false);
3807 triangleEdger(x2, y2, x1, y1, minPts,
true);
3809 triangleEdger(x1, y1, x3, y3, minPts,
true);
3810 triangleEdger(x2, y2, x1, y1, maxPts,
false);
3813 double xOt = (x1*y3+x3*y2-x1*y2-x3*y1);
3814 double xOb = (y3-y1);
3816 triangleEdger(x1, y1, x3, y3, minPts,
true);
3817 triangleEdger(x2, y2, x1, y1, maxPts,
false);
3818 triangleEdger(x2, y2, x3, y3, maxPts,
false);
3820 triangleEdger(x1, y1, x3, y3, maxPts,
false);
3821 triangleEdger(x2, y2, x1, y1, minPts,
true);
3822 triangleEdger(x2, y2, x3, y3, minPts,
true);
3830 for(intCrdT y=y3; y<=y1; y++)
3831 drawLine(minPts[y], y, maxPts[y], y, c1);
3833 for(intCrdT y=y3; y<=y1; y++)
3834 for(intCrdT x=minPts[y]; x<=maxPts[y]; x++) {
3845 drawPointNC(x, y, colorT().wMean(w1/(w1+w2+w3), w2/(w1+w2+w3), w3/(w1+w2+w3), c1, c2, c3));
3851 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3852 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3855 drawPLCurve(numPoints, x, y, dfltColor);
3859 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3860 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3863 for(
int i=0; i<numPoints-1; i++)
3864 drawLine(real2intX(x[i]), real2intY(y[i]), real2intX(x[i+1]), real2intY(y[i+1]), color);
3868 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3869 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3872 drawPLCurve(numPoints, x, y, dfltColor);
3876 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3877 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3880 for(
int i=0; i<numPoints-1; i++)
3881 drawLine(x[i], y[i], x[i+1], y[i+1], color);
3885 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3886 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3889 for(
int i=0; i<numPoints-1; i++)
3890 drawLine(thePoints[i].x, thePoints[i].y, thePoints[i+1].x, thePoints[i+1].y, color);
3894 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3895 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3898 for(
int i=0; i<numPoints-1; i++)
3899 drawLine(thePoints[i].x, thePoints[i].y, thePoints[i+1].x, thePoints[i+1].y, color);
3903 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3904 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3907 drawPLCurve(numPoints, thePoints, dfltColor);
3911 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3912 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3915 drawPLCurve(numPoints, thePoints, dfltColor);
3919 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3920 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3923 drawLine(x1, y1, x2, y2, color);
3924 drawLine(x2, y2, x3, y3, color);
3925 drawLine(x3, y3, x1, y1, color);
3929 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3930 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3935 int d = 1 - radiusX;
3937 int deltaSE = -2 * radiusX + 5;
3939 drawPoint( x+centerX, y+centerY, color);
3940 drawPoint( x+centerX,-y+centerY, color);
3941 drawPoint(-x+centerX, y+centerY, color);
3942 drawPoint(-x+centerX,-y+centerY, color);
3943 drawPoint( y+centerX, x+centerY, color);
3944 drawPoint( y+centerX,-x+centerY, color);
3945 drawPoint(-y+centerX, x+centerY, color);
3946 drawPoint(-y+centerX,-x+centerY, color);
3960 drawPoint( x+centerX, y+centerY, color);
3961 drawPoint( x+centerX,-y+centerY, color);
3962 drawPoint(-x+centerX, y+centerY, color);
3963 drawPoint(-x+centerX,-y+centerY, color);
3964 drawPoint( y+centerX, x+centerY, color);
3965 drawPoint( y+centerX,-x+centerY, color);
3966 drawPoint(-y+centerX, x+centerY, color);
3967 drawPoint(-y+centerX,-x+centerY, color);
3973 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3974 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3980 int d = 1 - radiusX;
3982 int deltaSE = -2 * radiusX + 5;
3988 drawLine( x+centerX, y+centerY, x+centerX, minXY+centerY, color);
3989 drawLine( -x+centerX, y+centerY, -x+centerX, minXY+centerY, color);
3990 drawLine( x+centerX, -y+centerY, x+centerX, -minXY+centerY, color);
3991 drawLine( -x+centerX, -y+centerY, -x+centerX, -minXY+centerY, color);
3992 drawLine( y+centerX, x+centerY, minXY+centerX, x+centerY, color);
3993 drawLine( y+centerX, -x+centerY, minXY+centerX, -x+centerY, color);
3994 drawLine( -y+centerX, x+centerY, -minXY+centerX, x+centerY, color);
3995 drawLine( -y+centerX, -x+centerY, -minXY+centerX, -x+centerY, color);
4014 drawLine( x+centerX, y+centerY, x+centerX, minXY+centerY, color);
4015 drawLine( -x+centerX, y+centerY, -x+centerX, minXY+centerY, color);
4016 drawLine( x+centerX, -y+centerY, x+centerX, -minXY+centerY, color);
4017 drawLine( -x+centerX, -y+centerY, -x+centerX, -minXY+centerY, color);
4018 drawLine( y+centerX, x+centerY, minXY+centerX, x+centerY, color);
4019 drawLine( y+centerX, -x+centerY, minXY+centerX, -x+centerY, color);
4020 drawLine( -y+centerX, x+centerY, -minXY+centerX, x+centerY, color);
4021 drawLine( -y+centerX, -x+centerY, -minXY+centerX, -x+centerY, color);
4026 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4027 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4034 if( (y1 < numPixY) && (x1 < numPixX) && (y2 >= 0) && (x2 >= 0) ) {
4035 int noTop, noBottom, noLeft, noRight;
4036 if((noTop=(y1 < 0)))
4038 if((noLeft=(x1 < 0)))
4040 if((noBottom=(y2 >= numPixY)))
4042 if((noRight=(x2 >= numPixX)))
4046 drawVertLineNC(y1, y2, x1, color);
4048 drawVertLineNC(y1, y2, x2, color);
4050 drawHorzLineNC(x1, x2, y1, color);
4052 drawHorzLineNC(x1, x2, y2, color);
4057 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4058 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4066 if( (y1 >= numPixY) || (x1 >= numPixX) || (y2 < 0) || (x2 < 0) )
4076 for(intCrdT y=y1;y<=y2;y++)
4077 drawHorzLineNC(x1, x2, y, color);
4081 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4082 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4085 if constexpr (enableDrawModes)
4087 case drawModeType::SET: getPxColorRefNC(x, y).copy(color);
break;
4088 case drawModeType::XOR: getPxColorRefNC(x, y).tfrmXor(color);
break;
4089 case drawModeType::ADDCLAMP: getPxColorRefNC(x, y).tfrmAddClamp(color);
break;
4090 case drawModeType::AND: getPxColorRefNC(x, y).tfrmAnd(color);
break;
4091 case drawModeType::OR: getPxColorRefNC(x, y).tfrmOr(color);
break;
4092 case drawModeType::DIFFCLAMP: getPxColorRefNC(x, y).tfrmDiffClamp(color);
break;
4093 case drawModeType::MULTCLAMP: getPxColorRefNC(x, y).tfrmMultClamp(color);
break;
4096 getPxColorRefNC(x, y).copy(color);
4100 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4101 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4105 intCrdT new_numPixX_p = xfactor*numPixX;
4106 intCrdT new_numPixY_p = xfactor*numPixY;
4107 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4108 for(intCrdT y=0, y1=0; y<numPixY; y++) {
4109 for(intCrdT x=0, x1=0; x<numPixX; x++) {
4110 for(
int i=0; i<xfactor; i++) {
4111 for(
int j=0; j<xfactor; j++) {
4112 new_pixels[new_numPixX_p * y1 + x1] = getPxColor(x, y);
4123 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
4128 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4129 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4132 if ((xfactor > 1) && (xfactor <= numPixX) && (xfactor <= numPixY)) {
4133 intCrdT new_numPixX_p = numPixX/xfactor;
4134 intCrdT new_numPixY_p = numPixY/xfactor;
4135 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4136 for(intCrdT y=0, y1=0; y<new_numPixY_p; y++, y1+=xfactor)
4137 for(intCrdT x=0, x1=0; x<new_numPixX_p; x++, x1+=xfactor)
4138 new_pixels[new_numPixX_p * y + x] = getPxColor(x1, y1);
4139 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
4144 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4145 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4148 if ((xfactor > 1) && (xfactor <= numPixX) && (xfactor <= numPixY)) {
4149 intCrdT new_numPixX_p = numPixX/xfactor;
4150 intCrdT new_numPixY_p = numPixY/xfactor;
4151 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4152 for(intCrdT y=0, y1=0; y<new_numPixY_p; y++, y1+=xfactor)
4153 for(intCrdT x=0, x1=0; x<new_numPixX_p; x++, x1+=xfactor) {
4154 std::vector<colorChanArithSDPType> sums(colorT::channelCount,
static_cast<colorChanArithSDPType>(0));
4155 for(
int j=0; j<xfactor; j++)
4156 for(
int i=0; i<xfactor; i++)
4157 for(
int c=0; c<colorT::channelCount; c++)
4158 sums[c] += getPxColor(x1+i, y1+j).getChan(c);
4160 for(
int c=0; c<colorT::channelCount; c++)
4161 aColor.setChan(c,
static_cast<colorChanType>(sums[c] / (xfactor*xfactor)));
4162 new_pixels[new_numPixX_p * y + x] = aColor;
4164 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
4169 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4170 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4173 if ((xfactor > 1) && (xfactor <= numPixX) && (xfactor <= numPixY)) {
4174 intCrdT new_numPixX_p = numPixX/xfactor;
4175 intCrdT new_numPixY_p = numPixY/xfactor;
4176 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4177 for(intCrdT y=0, y1=0; y<new_numPixY_p; y++, y1+=xfactor)
4178 for(intCrdT x=0, x1=0; x<new_numPixX_p; x++, x1+=xfactor) {
4179 colorT maxColor = getPxColor(xfactor*x, xfactor*y);
4180 for(
int yi=0; yi<xfactor; yi++)
4181 for(
int xi=0; xi<xfactor; xi++)
4182 maxColor.tfrmMaxI(getPxColor(xfactor*x+xi, xfactor*y+yi));
4183 new_pixels[new_numPixX_p * y + x] = maxColor;
4185 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
4190 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4191 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4194 for(
int yi=0, yis=-(kSize/2); yi<kSize; yi++, yis++)
4195 for(
int xi=0,xis=-(kSize/2); xi<kSize; xi++, xis++)
4196 kernel[kSize * yi + xi] = exp(-(xis*xis+yis*yis)/(2*sd*sd))/(sd*sd*2*std::numbers::pi);
4198 for(
int i=0; i<(kSize*kSize); i++)
4199 divisor += kernel[i];
4200 for(
int i=0; i<(kSize*kSize); i++)
4201 kernel[i] /= divisor;
4205 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4206 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4209 for(
int yi=0, yis=-(kSize/2); yi<kSize; yi++, yis++)
4210 for(
int xi=0,xis=-(kSize/2); xi<kSize; xi++, xis++)
4211 kernel[kSize * yi + xi] = 1.0/(kSize*kSize);
4215 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4216 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4219 colorT *new_pixels =
new colorT[numPixX * numPixY];
4221 if (mjr::math::fc::near_zero(divisor, 0.0001)) {
4223 for(
int i=0; i<(kWide*kTall); i++)
4224 divisor += kernel[i];
4227 double tmp[colorT::channelCount];
4228 for(intCrdT y=0; y<numPixY; y++) {
4229 for(intCrdT x=0; x<numPixX; x++) {
4231 for(
int chan=0; chan<colorT::channelCount; chan++)
4233 for(
int yi=0, yis=-(kTall/2); yi<kTall; yi++, yis++) {
4234 intCrdT icY = y + yis;
4235 for(
int xi=0,xis=-(kWide/2); xi<kWide; xi++, xis++) {
4236 intCrdT icX = x + xis;
4237 if (!(isCliped(icX, icY))) {
4238 for(
int chan=0; chan<colorT::channelCount; chan++)
4239 tmp[chan] +=
static_cast<double>(getPxColor(icX, icY).getChan(chan)) * kernel[kWide * yi + xi];
4243 for(
int chan=0; chan<colorT::channelCount; chan++)
4244 new_pixels[numPixX * y + x].setChan(chan,
static_cast<colorChanType>(tmp[chan] / divisor));
4247 rePointPixels(new_pixels, numPixX, numPixY);
4251 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4252 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4255 convolution(kernel, kSize, kSize, divisor);
4258 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4259 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4262 convolution(kernel, kSize, kSize, 1.0);
4266 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4267 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4273 if( (glyphNum < 0) || (glyphNum > 3934) )
4281 if(isIntAxOrientationNaturalX())
4282 x1 =
static_cast<intCrdT
>(magX * ((
mjr::hershey::chars[glyphNum]).components[2*i] -
'R'));
4284 x1 =
static_cast<intCrdT
>(magX * (
'R' - (
mjr::hershey::chars[glyphNum]).components[2*i]));
4286 if(isIntAxOrientationNaturalY())
4287 y1 =
static_cast<intCrdT
>(magY * (
'R' - (
mjr::hershey::chars[glyphNum]).components[2*i+1]));
4289 y1 =
static_cast<intCrdT
>(magY * ((
mjr::hershey::chars[glyphNum]).components[2*i+1] -
'R'));
4291 if(actionIsMoveTo) {
4295 drawLine(x1+x, y1+y, aColor);
4302 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4303 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4306 for(
auto &c : aString) {
4308 if((c>=32) && (c<=126))
4310 drawHersheyGlyph(glyphNum, x, y, cex, cex, aColor);
4311 x+=
static_cast<intCrdT
>(spc*cex);
4316 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4317 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4321 intCrdT x, intCrdT y,
4323 double cex, intCrdT spc) {
4324 drawFillRectangle(
static_cast<intCrdT
>(x-spc*cex),
4325 static_cast<intCrdT
>(y-spc*cex),
4326 static_cast<intCrdT
>(x+spc*cex*
static_cast<int>(aString.length())),
4327 static_cast<intCrdT
>(y+spc*cex),
4329 drawString(aString, aFont, x, y, stringColor, cex, spc);
4333 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4334 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4339 std::ifstream iStream(fileName, std::ios_base::binary);
4341 if (!(iStream.good()))
4344 iStream.getline(strBuf, 10,
'\n');
4345 if (!(iStream.good()))
4347 if (iStream.gcount() != 7)
4349 if(std::string(strBuf) != std::string(
"MJRRAW"))
4355 int fileBitPerChan = -1;
4356 bool fileIsSGN =
true, fileHasS =
false;
4357 bool fileIsInt =
true, fileHasT =
false;
4358 bool fileIsLTL =
true, fileHasI =
false;
4360 iStream.getline(strBuf, 100,
'\n');
4361 if (!(iStream.good()))
4363 if (iStream.gcount() != 93)
4366 std::string::size_type tagIdx;
4367 std::string::size_type prcIdx = 0;
4368 std::string strBufS(strBuf);
4369 std::string delChrs(
"abcdefghijklmnopqrstuvwxyz");
4370 int stoiErrorCount = 0;
4373 tagIdx = strBufS.find_first_of(delChrs, prcIdx);
4374 if (tagIdx == std::string::npos)
4379 switch(strBufS[tagIdx]) {
4380 case 'x' : fileWide = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4381 case 'y' : fileTall = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4382 case 'c' : fileChans = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4383 case 'b' : fileBitPerChan = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4384 case 's' : fileIsSGN = (strBufS[prcIdx] ==
'S'); fileHasS =
true;
break;
4385 case 't' : fileIsInt = (strBufS[prcIdx] ==
'I'); fileHasT =
true;
break;
4386 case 'i' : fileIsLTL = (strBufS[prcIdx] ==
'L'); fileHasI =
true;
break;
4394 int fileBytePerChan = fileBitPerChan / 8;
4405 if (stoiErrorCount > 0)
4414 if (fileBitPerChan < 0)
4422 if (fileWide > intCrdMax)
4424 if (fileTall > intCrdMax)
4427 resizeCanvas(fileWide, fileTall);
4429 if (fileWide != numPixX)
4431 if (fileTall != numPixY)
4438 fileIsSGN = ( !(fileIsInt));
4440 if ((colorT::chanIsInt && fileIsSGN))
4443 if ((colorT::chanIsInt && !fileIsInt) ||
4444 (colorT::chanIsFloat && fileIsInt))
4447 if(fileChans != colorT::channelCount)
4450 if(fileBitPerChan != colorT::bitsPerChan)
4454 fileIsLTL = (platformEndianness() == endianType::LITTLE);
4456 bool reverseBits = (( fileIsLTL && (platformEndianness() == endianType::BIG)) ||
4457 (!(fileIsLTL) && (platformEndianness() == endianType::LITTLE)));
4460 bool yNat = !(isIntAxOrientationNaturalY());
4461 bool xNat = isIntAxOrientationNaturalX();
4462 for((yNat?y=0:y=(numPixY-1)); (yNat?y<numPixY:y>=0); (yNat?y++:y--)) {
4463 for((xNat?x=0:x=(numPixX-1)); (xNat?x<numPixX:x>=0); (xNat?x++:x--)) {
4464 for(
int ci=0; ci<fileChans; ci++) {
4465 if constexpr (colorT::chanIsInt) {
4471 for(
int bi=0; bi<fileBytePerChan; bi++) {
4473 if (!(iStream.good()))
4475 if (iStream.gcount() != 1)
4484 getPxColorRefNC(x, y).setChan(ci,
static_cast<colorChanType>(pv));
4486 iStream.read(strBuf, fileBytePerChan);
4487 getPxColorRefNC(x, y).setChan(ci, *((
colorChanType*)strBuf));
4497 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4498 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4501#ifndef MRASTER_FOUND_TIFF
4502 std::cerr <<
"ERROR: libTIFF no supported: readTIFFfile can't read " << fileName << std::endl;
4506 uint32_t wTIFF, hTIFF;
4507 uint16_t pmTIFF, pcTIFF, sppTIFF, bpsTIFF, fmtTIFF;
4510 if( !(tif = TIFFOpen(fileName.c_str(),
"r")))
4513 if(TIFFIsTiled(tif))
4517 if( 1 != TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &wTIFF))
4519 if( 1 != TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &hTIFF))
4521 if( 1 != TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &sppTIFF))
4523 if( 1 != TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &pcTIFF))
4525 if( 1 != TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &pmTIFF))
4527 if( 1 != TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bpsTIFF))
4531 if( 1 != TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &fmtTIFF))
4534 if (pmTIFF == PHOTOMETRIC_PALETTE)
4557 resizeCanvas(wTIFF, hTIFF);
4559 uint32_t wRC = getNumPixX();
4561 if ((pcTIFF != PLANARCONFIG_CONTIG) && (pcTIFF != PLANARCONFIG_SEPARATE))
4567 uint32_t hRC = getNumPixY();
4572 uint16_t sppRC = colorT::channelCount;
4575 if(sppTIFF != sppRC)
4578 uint16_t bpsRC = colorT::bitsPerPixel / sppRC;
4580 if(bpsTIFF != bpsRC)
4584 if ((fmtTIFF != SAMPLEFORMAT_UINT) && (fmtTIFF != SAMPLEFORMAT_IEEEFP))
4587 if (( colorType::chanIsInt && (SAMPLEFORMAT_UINT != 1)) ||
4588 (!(colorType::chanIsInt) && (SAMPLEFORMAT_IEEEFP != 3)))
4591 bool yNat = !(isIntAxOrientationNaturalY());
4592 bool xNat = isIntAxOrientationNaturalX();
4593 tsize_t scanlinesize = TIFFScanlineSize(tif);
4594 tdata_t scanLineBuffer = _TIFFmalloc(scanlinesize);
4596 if(scanLineBuffer == NULL)
4599 if (pcTIFF == PLANARCONFIG_CONTIG) {
4600 for(uint32_t row=0; row<hTIFF; row++) {
4601 if( !(TIFFReadScanline(tif, scanLineBuffer, row)))
4603 char* p = (
char*)(scanLineBuffer);
4604 for(uint32_t col=0; col<wTIFF; col++) {
4605 int x = (xNat ? col : wTIFF-col-1);
4606 int y = (yNat ? row : hTIFF-row-1);
4607 for(uint16_t samp=0; samp<sppTIFF; samp++) {
4608 getPxColorRefNC(x, y).setChan(samp,
static_cast<colorChanType>(*p));
4609 p = p + (bpsTIFF/8);
4613 }
else if (pcTIFF == PLANARCONFIG_SEPARATE) {
4614 for(uint16_t samp=0; samp<sppTIFF; samp++) {
4615 for(uint32_t row=0; row<hTIFF; row++) {
4616 if( !(TIFFReadScanline(tif, scanLineBuffer, row, samp)))
4618 char* p = (
char*)(scanLineBuffer);
4619 for(uint32_t col=0; col<wTIFF; col++) {
4620 int x = (xNat ? col : wTIFF-col-1);
4621 int y = (yNat ? row : hTIFF-row-1);
4622 getPxColorRefNC(x, y).setChan(samp,
static_cast<colorChanType>(*p));
4623 p = p + (bpsTIFF/8);
4629 _TIFFfree(scanLineBuffer);
4636 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4637 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4640#ifndef MRASTER_FOUND_TIFF
4648 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4649 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4658 for(intCrdT y=0; y<numPixY; y++) {
4659 for(intCrdT x=0; x<numPixX; x++) {
4663 double xS = fv.
x / oScale + Xo;
4664 double yS = fv.
y / oScale + Yo;
4665 if (isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4668 newRamCanvas.
drawPointNC(x, y, getPxColorInterpolate(xS, yS, interpMethod));
4672 return newRamCanvas;
4676 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4677 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4686 for(intCrdT y=0; y<numPixY; y++) {
4687 for(intCrdT x=0; x<numPixX; x++) {
4690 double xS = (HAMatrix[0] * xT + HAMatrix[1] * yT + HAMatrix[2]) / oScale + Xo;
4691 double yS = (HAMatrix[3] * xT + HAMatrix[4] * yT + HAMatrix[5]) / oScale + Yo;
4692 if (isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4695 newRamCanvas.
drawPointNC(x, y, getPxColorInterpolate(xS, yS, interpMethod));
4699 return newRamCanvas;
4703 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4704 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4714 for(intCrdT y=0; y<numPixY; y++) {
4715 for(intCrdT x=0; x<numPixX; x++) {
4716 double xT = (x - Xo);
4717 double yT = (y - Yo);
4718 double rT = std::hypot(xT, yT) / rScale;
4720 double rS = RPoly[0];
4721 for (
unsigned int i=1; i<RPoly.size(); i++)
4722 rS = rS*rT + RPoly[i];
4723 double xS = xT * rS / oScale + Xo;
4724 double yS = yT * rS / oScale + Yo;
4725 if (isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4728 newRamCanvas.
drawPointNC(x, y, getPxColorInterpolate(xS, yS, interpMethod));
4732 return newRamCanvas;
4736 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4737 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4740 std::vector<double>
const& BiPolyY,
4747 for(intCrdT y=0; y<numPixY; y++) {
4748 for(intCrdT x=0; x<numPixX; x++) {
4751 double xS = mjr::math::bply::eval(BiPolyX, xT, yT) / oScale + Xo;
4752 double yS = mjr::math::bply::eval(BiPolyY, xT, yT) / oScale + Yo;
4753 if (isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4756 newRamCanvas.
drawPointNC(x, y, getPxColorInterpolate(xS, yS, interpMethod));
4760 return newRamCanvas;
4765#define MJR_INCLUDE_ramCanvasTpl
User include file for color types.
Internal include file for ramCanvas types.
static constexpr herChar chars[3935]
Data for each hershey font
font
Enum for hershey font names.
static constexpr int ascii2hershey[5][95]
ASCII to Hershey Character Number mapping array.
Handy class to hold a point in 2D (integer or real)
Class providing off-screen drawing functionality.
pointFltType int2realCorner(intCrdT x, intCrdT y, int cornerIndex)
Given integer x & y coordinates and a corner index, produce real x & y coordinates for one of the pix...
void drawRectangle(pointFltType *thePoints)
interpolationType
Enum for drawing Mode.
void setRealAxOrientationY(realAxisOrientation orientation)
Set the real Y axis orientation.
void drawPoint(fltCrdT x, fltCrdT y)
pointIntType real2int(intCrdT x, intCrdT y)
Convert integer x & y coordinates to real x & y coordinates.
void drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3)
void drawLine(pointFltType point1)
void drawLine(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, colorArgType color)
intAxisOrientation getIntAxOrientationY()
Is the integer Y axis orientation NATURAL?
fltCrdT getCanvasWidY()
height of the display(real coord)
void drawFillRectangle(pointIntType *thePoints, colorArgType color)
std::complex< fltCrdT > cplxFltType
Real coordinate complex type (Provided for convince – not used in ramCanvasTpl)
std::function< colorT(fltCrdT, fltCrdT)> fltCrd2Col
std::function type floating point coordinates to a color
colorT::colorPtrType colorPtrType
colorT: Pointer to color
void drawFillRectangle(pointFltType point1, pointFltType point2, colorArgType color)
pointFltType int2realCorner(intCrdT x, intCrdT y, int sideX, int sideY)
Given integer x & y coordinates, produce real x & y coordinates for one of the pixel's corners.
void drawFillCircle(pointIntType centerPoint, intCrdT radiusX)
std::vector< pointIntType > pointIntVecType
Integer coordinate pair type.
void drawFillRectangle(pointIntType *thePoints)
pointFltType int2real(intCrdT x, intCrdT y)
Convert real x & y coordinates to integer x & y coordinates.
void drawLine(pointFltType point1, pointFltType point2, colorArgType color)
intCrdT statNumNonZeroPixels()
void moveTo(pointIntType thePoint)
void drawHersheyGlyph(int glyphNum, fltCrdT x, fltCrdT y, double magX, double magY, colorArgType aColor)
void adjoinCanvasRight(const ramCanvasTpl &theCanvas)
Adjoin the canvas to the side of the current canvas.
endianType
Endianness Identifiers.
drawModeType drawMode
Drawing mode.
int isOnCanvas(fltCrdT x, fltCrdT y) const
Determine if the given point is within the bounds of the ramCanvasTpl.
void drawFillCircle(pointIntType centerPoint, intCrdT radiusX, colorArgType color)
realAxisOrientation
Enum for real axis orientation.
void drawFillTriangle(pointFltType *thePoints)
void drawPoint(fltCrdT x, fltCrdT y, colorArgType color)
void drawFillTriangle(pointIntType *thePoints)
colorT::maskType colorMaskType
colorT: Mask type
colorChanType getPxColorChanWrap(fltCrdT x, fltCrdT y) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
colorChanType getPxColorChanWrap(intCrdT x, intCrdT y) const
Returns a copy of the color channel value at the given coordinates wrapping x & y if out of range.
void drawTriangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, fltCrdT x3, fltCrdT y3)
void drawCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX)
colorT::colorArgType colorArgType
colorT: Argument passing type
void drawFillTriangle(pointFltType *thePoints, colorArgType color)
colorT::csNatType csNatType
colorT: Color Scheme Natural Type
colorChanType getPxColorChanWrap(pointIntType thePoint) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
intCrdT statNumNonZeroPixels(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2)
colorT::colorCRefType colorCRefType
colorT: Const Ref to a color
void drawRectangle(pointFltType point1, pointFltType point2, colorArgType color)
void drawLine(pointFltType point1, pointFltType point2)
intAxisOrientation intAxOrientationX
Flip horizontally.
void drawPoint(intCrdT x, intCrdT y)
void drawTriangle(pointIntType point1, pointIntType point2, pointIntType point3)
void drawLine(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2)
drawModeType
Enum for drawing Mode.
void setDefaultDrawMode()
Set the default draw mode.
fltCrdT canvasWidY
height of the canvas (real coord)
void drawFillTriangle(pointIntType point1, pointIntType point2, pointIntType point3)
void drawFillTriangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, fltCrdT x3, fltCrdT y3, colorArgType color)
colorT dfltColor
Default color.
void drawString(std::string aString, mjr::hershey::font aFont, fltCrdT x, fltCrdT y, colorArgType aColor, double cex, intCrdT spc)
void drawTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3)
fltCrdT canvasWidX
Width of the canvas (real coord)
colorT::channelType colorChanType
colorT: Channel type
colorT::channelArithLogType colorChanArithLogType
colorT: Channel arithmatic (Int: ^|&~)
void drawLine(pointIntType point1)
void drawTriangle(pointIntType *thePoints, colorArgType color)
void drawFillRectangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2)
colorT getPxColor(intCrdT x, intCrdT y) const
Returns a copy of the color at the given coordinates.
void drawFillTriangle(pointIntType *thePoints, colorArgType color)
colorT::channelArithDType colorChanArithDType
colorT: Channel arithmatic (Int: -)
intCrdT dfltY
y coordinate used by default.
colorT * pixels
Array to hold the color values.
colorT::channelArithSDPType colorChanArithSDPType
colorT: Channel arithmatic (Int: +-*)
fltCrdT minRealX
x coord of min (real coord)
intCrdT realDelta2intX(fltCrdT x) const
Convert real distance on the x coordinate axis to an integral distance.
fltCrdT getCanvasWidD()
Width of the display (real coord)
void setDfltColor(std::string cornerColor)
void setDrawMode(drawModeType newDrawMode)
Set the current drawing mode NOOP if enableDrawModes is false.
void setDfltColor(const char *cornerColor)
void drawFillTriangle(pointIntType point1, pointIntType point2, pointIntType point3, colorArgType color)
void drawRectangle(pointIntType *thePoints, colorArgType color)
void drawTriangle(pointFltType point1, pointFltType point2, pointFltType point3, colorArgType color)
intAxisOrientation getIntAxOrientationX()
Get the integer X axis orientation.
colorChanType getPxColorChanWrap(pointFltType thePoint) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawPointS(intCrdT x, intCrdT y, colorArgType color)
Draw a point without any special drawing options.
void drawPoint(pointIntType thePoint)
colorT * iterator
pixel store iterators
void drawLine(pointIntType point1, pointIntType point2)
void setRealAxOrientationX(realAxisOrientation orientation)
Set the real X axis orientation.
void moveTo(pointFltType thePoint)
fltCrdT maxRealX
x coord of max (real coord)
bool isNotSameSize(ramCanvasTpl const &inRC) const
Return true if given canvas and current canvas are NOT the same size.
fltCrdT getMaxRealY()
y coord of max (real coord)
realAxisOrientation getRealAxOrientationX()
Get the real X axis orientation.
void drawCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX, colorArgType color)
void drawHorzLineNC(intCrdT xMin, intCrdT xMax, intCrdT yConst, colorArgType color)
Draw a horizontal line with no clipping or bounds checking.
fltCrdT minRealY
y coord of min (real coord)
void setDfltColor(colorArgType color)
Set the default color.
void moveTo(intCrdT x, intCrdT y)
Set the current default point to the given coordinates.
void drawCircle(pointFltType centerPoint, fltCrdT radiusX)
colorT * pixelsE
Point one beyond end of pixels array.
void drawTriangle(pointFltType *thePoints, colorArgType color)
fltCrdT getMaxRealX()
x coord of max (real coord)
realAxisOrientation realAxOrientationX
Orientation of x axis.
point2d< fltCrdT > pointFltType
Real coordinate pair type.
void drawFillCircle(pointFltType centerPoint, fltCrdT radiusX, colorArgType color)
void drawCircle(pointFltType centerPoint, fltCrdT radiusX, colorArgType color)
fltCrdT maxRealY
y coord of max (real coord)
bool isIntAxOrientationNaturalY()
Get the integer Y axis orientation.
colorT getPxColorWrap(pointFltType thePoint) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawFillCircle(fltCrdT radiusX)
int isCliped(intCrdT x, intCrdT y) const
void drawPointNC(intCrdT x, intCrdT y, colorArgType color)
The functions here work in a similar way to the non-NC functions, but with no clipping or bounds chec...
fltCrdT pixWidY
Height of a pixel (real coord)
void drawRectangle(pointFltType *thePoints, colorArgType color)
void setRealAxisDefaultOrientation()
Set the real axis orientation to default (NATURAL for both X and Y axes)
void drawStringBox(std::string aString, mjr::hershey::font aFont, fltCrdT x, fltCrdT y, colorArgType stringColor, colorArgType boxColor, double cex, intCrdT spc)
colorT getPxColor(fltCrdT x, fltCrdT y) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
colorT::cmfInterpolationEnum cmfInterpolationEnum
colorT: Interpolation for color match functions
colorT::cornerColorEnum colorCornerEnum
colorT: RGB Color Corners
void drawFillTriangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, fltCrdT x3, fltCrdT y3)
void drawFillRectangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, colorArgType color)
fltCrdT getPixWidX()
Width of a pixel (real coord)
void drawFillRectangle(pointFltType point1, pointFltType point2)
void drawRectangle(pointFltType point1, pointFltType point2)
void drawTriangle(pointFltType *thePoints)
void drawCircle(pointIntType centerPoint, intCrdT radiusX)
void setDfltColor(colorChanType r, colorChanType g, colorChanType b)
void drawLine(pointIntType point1, pointIntType point2, colorArgType color)
point2d< intCrdT > pointIntType
Integer coordinate pair type.
void drawPoint(pointFltType thePoint)
intCrdT coordIntType
Integer type for coordinates.
intCrdT numPixX
Number of x pixels.
fltCrdT int2realSideY(intCrdT y, int side)
Given integer y coordinate, produce real y coordinate for one of the pixel's edge.
realAxisOrientation realAxOrientationY
Orientation of y axis.
colorT::csFltType csFltType
colorT: Color Scheme Float Type
int isCliped(fltCrdT x, fltCrdT y) const
Determine if the given point is within the bounds of the ramCanvasTpl.
void drawRectangle(pointIntType point1, pointIntType point2, colorArgType color)
void drawCircle(intCrdT centerX, intCrdT centerY, intCrdT radiusX)
intAxisOrientation intAxOrientationY
Flip vertically.
void combineRamCanvasMean(ramCanvasTpl *theCanvasList, const int N)
Take a list of ramCanvasTpl objects and combine them with the current ramCanvasTpl using mean.
void moveTo(fltCrdT x, fltCrdT y)
void setIntAxOrientationX(intAxisOrientation orientation)
Set the integer X axis orientation.
intCrdT realDelta2intY(fltCrdT y) const
Convert real distance on the y coordinate axis to an integral distance.
intCrdT numPixY
Number of y pixels.
colorT getPxColorWrap(intCrdT x, intCrdT y) const
Returns a copy of the color at the given coordinates wrapping x & y if out of range.
void newIntCoordsNC(intCrdT numPixX_p, intCrdT numPixY_p)
Change the logical coordinate sizes.
void drawLine(fltCrdT x, fltCrdT y, colorArgType color)
fltCrdT getCanvasWidX()
Width of the display (real coord)
void drawRectangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, colorArgType color)
void drawFillTriangle(pointFltType point1, pointFltType point2, pointFltType point3)
void insertCanvas(const ramCanvasTpl &theCanvas, intCrdT x1=0, intCrdT y1=0)
Draw the given canvas at the indicated point.
void drawCircle(fltCrdT radiusX)
colorT::channelArithFltType colorChanArithFltType
colorT: Channel arithmatic (Flt: +-*)
colorT getPxColorNC(intCrdT x, intCrdT y) const
Get the default point to the specified coordinates with no clipping or bounds checking.
colorT::colorRefType colorRefType
colorT: Ref to a color
void drawFillRectangle(pointFltType *thePoints, colorArgType color)
void drawLine(pointFltType point1, colorArgType color)
void adjoinCanvasLeft(const ramCanvasTpl &theCanvas)
Adjoin the canvas to the side of the current canvas.
bool isIntAxOrientationNaturalX()
Is the integer X axis NATURAL?
colorT getPxColor(pointIntType thePoint) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
fltCrdT pixWidX
Width of a pixel (real coord)
colorT getPxColor(pointFltType thePoint) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawRectangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2)
void drawRectangle(pointIntType *thePoints)
bool isSameSize(ramCanvasTpl const &inRC) const
Return true if given canvas and current canvas are the same size.
colorT getPxColorWrap(pointIntType thePoint) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawLine(intCrdT x, intCrdT y)
void drawFillCircle(intCrdT centerX, intCrdT centerY, intCrdT radiusX)
void drawFillCircle(pointFltType centerPoint, fltCrdT radiusX)
void drawVertLineNC(intCrdT yMin, intCrdT yMax, intCrdT xConst, colorArgType color)
Draw a vertical line with no clipping or bounds checking.
void drawFillRectangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2)
void drawFillRectangle(pointFltType *thePoints)
void drawLine(fltCrdT x, fltCrdT y)
fltCrdT intDelta2realY(intCrdT y) const
Convert integral distance on the y coordinate to a real distance.
void drawTriangle(pointFltType point1, pointFltType point2, pointFltType point3)
void drawPoint(pointFltType thePoint, colorArgType color)
colorT * pixelIterator
pixel store iterators
void drawFillRectangle(pointIntType point1, pointIntType point2, colorArgType color)
void drawRectangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2)
void drawFillCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX)
int isOnCanvas(intCrdT x, intCrdT y) const
std::function< colorT(pointIntType)> intPnt2Col
std::function type int point point to a color
void drawPoint(colorArgType color)
colorT colorType
Color type for pixels.
void drawCircle(pointIntType centerPoint, intCrdT radiusX, colorArgType color)
intCrdT dfltX
x coordinate used by default.
fltCrdT coordFltType
Real type for coordinates.
fltCrdT getPixWidY()
Height of a pixel (real coord)
void drawFillCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX, colorArgType color)
realAxisOrientation getRealAxOrientationY()
Get the real Y axis orientation.
bool isClose(ramCanvasTpl const &inRC, colorChanType epsilon) const
Return true if corresponding pixels in each canvas are "close" as defined by colorTpl::isClose().
void drawCircle(intCrdT radiusX)
void drawTriangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, fltCrdT x3, fltCrdT y3, colorArgType color)
intCrdT getNumPixX() const
intCrdT getNumPixY() const
fltCrdT getMinRealX()
x coord of min (real coord)
void drawRectangle(pointIntType point1, pointIntType point2)
void drawTriangle(pointIntType *thePoints)
void drawPoint(intCrdT x, intCrdT y, colorArgType color)
Draw a point at the specified coordinates with the specified color.
void setIntAxOrientationY(intAxisOrientation orientation)
Set the integer Y axis orientation.
std::complex< intCrdT > cplxIntType
Integer coordinate complex type (Provided for convince – not used in ramCanvasTpl)
std::function< colorT(pointFltType)> fltPnt2Col
std::function type floating point point to a color
void drawLine(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2)
drawModeType getDrawMode()
Get the current drawing mode.
colorT getPxColorWrap(fltCrdT x, fltCrdT y) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawFillCircle(intCrdT radiusX)
void adjoinCanvasBottom(const ramCanvasTpl &theCanvas)
Adjoin the canvas to the side of the current canvas.
colorT::csIntType csIntType
colorT: Color Scheme Integer Type
intCrdT numPix
Number of pixels.
void drawFillTriangle(pointFltType point1, pointFltType point2, pointFltType point3, colorArgType color)
void drawPoint(pointIntType thePoint, colorArgType color)
void drawFillRectangle(pointIntType point1, pointIntType point2)
intAxisOrientation
Enum for integer axis orientation.
colorT * getPixels()
Returns a pointer to the raw pixel store.
colorT::colorSpaceEnum colorSpaceEnum
colorT: Color spaces
fltCrdT intDelta2realX(intCrdT x) const
Convert integral distance on the x coordinate to a real distance.
void adjoinCanvasTop(const ramCanvasTpl &theCanvas)
Adjoin the canvas to the side of the current canvas.
bool isEqual(ramCanvasTpl const &inRC) const
Return true if corresponding pixels in each canvas are "equal" as defined by colorTpl::isEqual().
fltCrdT int2realSideX(intCrdT x, int side)
Given integer x coordinate, produce real x coordinate for one of the pixel's edge.
std::function< colorT(intCrdT, intCrdT)> intCrd2Col
std::function type int point coordinates to a color
void drawTriangle(pointIntType point1, pointIntType point2, pointIntType point3, colorArgType color)
void drawLine(intCrdT x, intCrdT y, colorArgType color)
colorT & getPxColorRefNC(intCrdT x, intCrdT y) const
Returns a reference to the color object for the given pixel with no clipping or bounds checking.
void setIntAxisDefaultOrientation()
Set the integer axis orientation to default (NATURAL for both X and Y axes)
colorT::channelArithSPType colorChanArithSPType
colorT: Channel arithmatic (Int: +*)
fltCrdT getMinRealY()
y coord of min (real coord)
void drawLine(pointIntType point1, colorArgType color)