34#ifndef MJR_INCLUDE_ramCanvasTpl
41#include "MRMathIVL.hpp"
42#include "MRMathFC.hpp"
43#include "MRMathODR.hpp"
44#include "MRMathBPLY.hpp"
47#ifdef MRASTER_FOUND_TIFF
143 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
144 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
153 template<
class inRamCanvasT>
160 inline typename inRamCanvasT::coordIntType
getNumPixX() {
return attachedRC.getNumPixX(); }
161 inline typename inRamCanvasT::coordIntType
getNumPixY() {
return attachedRC.getNumPixY(); }
164 template<
class inRamCanvasT>
172 template<
class inRamCanvasT>
176 typedef typename inRamCanvasT::colorType::colConRGBbyte
colorType;
180 template<
class inRamCanvasT>
184 typedef typename inRamCanvasT::colorType::colConRGBAbyte
colorType;
188 template<
class inRamCanvasT>
192 typedef typename inRamCanvasT::colorType::colConRGBdbl
colorType;
196 template<
class inRamCanvasT>
200 typedef typename inRamCanvasT::colorType::colConRGBAdbl
colorType;
205 template<
class inRamCanvasT,
class outColorT,
class colorScheme,
bool clamp,
int factor,
int chan>
213 csi = mjr::math::ivl::clamp(csi, colorScheme::numC-1);
214 return colorScheme::c(csi);
219 template<
class inRamCanvasT,
class outColorChanT>
311 const static intCrdT intCrdMax = (1ul << ((
sizeof(intCrdT)*CHAR_BIT-1)/2)) - 3;
330 const static intCrdT intCrdGrdMax = intCrdMax+1;
331 const static intCrdT intCrdGrdMin = -1;
402 void drawFillTriangleUtl(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorT c1, colorT c2, colorT c3,
bool solid);
414 void writeUIntToStream(std::ostream& oStream,
endianType endianness,
int numBytes, uint64_t data);
427 void updRealCoords();
436 void newIntCoordsNC(intCrdT numPixX_p, intCrdT numPixY_p);
448 void reallocCanvas(intCrdT numPixX_p, intCrdT numPixY_p);
454 void rePointPixels(colorT *new_pixels, intCrdT new_numPixX, intCrdT new_numPixY);
462 void triangleEdger(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT* pts,
bool findMin);
495 int exportRasterData(
void* &rasterData, intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2,
int redChan,
int greenChan,
int blueChan,
int alphaChan);
516 ramCanvasTpl(intCrdT numPixX_p, intCrdT numPixY_p, fltCrdT minRealX_p=-1, fltCrdT maxRealX_p=1, fltCrdT minRealY_p=-1, fltCrdT maxRealY_p=1);
547 intCrdT origNumPixX = getNumPixX();
548 expandCanvas(origNumPixX + theCanvas.
getNumPixX(), std::max(getNumPixY(), theCanvas.
getNumPixY()));
549 insertCanvas(theCanvas, origNumPixX);
558 intCrdT origNumPixX = getNumPixX();
559 expandCanvas(origNumPixX + theCanvas.
getNumPixX(), std::max(getNumPixY(), theCanvas.
getNumPixY()), origNumPixX);
560 insertCanvas(theCanvas);
569 intCrdT origNumPixY = getNumPixY();
570 expandCanvas(std::max(getNumPixX(), theCanvas.
getNumPixX()), origNumPixY + theCanvas.
getNumPixY(), 0, origNumPixY);
571 insertCanvas(theCanvas, 0, 0);
580 intCrdT origNumPixY = getNumPixY();
581 expandCanvas(std::max(getNumPixX(), theCanvas.
getNumPixX()), origNumPixY + theCanvas.
getNumPixY());
582 insertCanvas(theCanvas, 0, origNumPixY);
593 for(intCrdT y=0; y<theCanvas.
getNumPixY(); y++)
594 for(intCrdT x=0; x<theCanvas.
getNumPixX(); x++)
607 void resizeCanvas(intCrdT new_numPixX_p, intCrdT new_numPixY_p);
617 void expandCanvas(intCrdT new_numPixX_p, intCrdT new_numPixY_p, intCrdT x1 = 0, intCrdT y1 = 0, colorArgType color = colorT(colorT::minChanVal));
624 void cropCanvas(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2);
636 void newRealCoords(fltCrdT minRealX_p, fltCrdT maxRealX_p, fltCrdT minRealY_p, fltCrdT maxRealY_p);
661 if (isNotSameSize(inRC))
663 for(intCrdT y=0; y<numPixY; y++)
664 for(intCrdT x=0; x<numPixX; x++)
665 if ( !(getPxColorRefNC(x, y).isClose(inRC.
getPxColorRefNC(x, y), epsilon)))
672 if (isNotSameSize(inRC))
674 for(intCrdT y=0; y<numPixY; y++)
675 for(intCrdT x=0; x<numPixX; x++)
712 void flipTranspose();
723 void scaleUpProximal(
int xfactor);
729 void scaleDown1pt(
int xfactor);
734 void scaleDownMax(
int xfactor);
740 void scaleDownMean(
int xfactor);
762 ramCanvasTpl geomTfrmRevRPoly(std::vector<double>
const& RPoly,
767 colorArgType errorColor = colorCornerEnum::GREEN,
768 interpolationType interpMethod = interpolationType::BILINEAR);
781 ramCanvasTpl geomTfrmRevBiPoly(std::vector<double>
const& BiPolyX,
782 std::vector<double>
const& BiPolyY,
786 colorArgType errorColor = colorCornerEnum::GREEN,
787 interpolationType interpMethod = interpolationType::BILINEAR);
804 ramCanvasTpl geomTfrmRevAff(std::vector<double>
const& HAMatrix,
808 colorArgType errorColor = colorCornerEnum::GREEN,
809 interpolationType interpMethod = interpolationType::BILINEAR);
825 colorArgType errorColor = colorCornerEnum::GREEN,
826 interpolationType interpMethod = interpolationType::BILINEAR);
841 void convolution(
double *kernel,
int kWide,
int kTall,
double divisor);
842 void convolution(
double *kernel,
int kSize,
double divisor);
843 void convolution(
double *kernel,
int kSize);
854 void computeConvolutionMatrixGausian(
double *kernel,
int kSize,
double sd);
859 void computeConvolutionMatrixBox(
double *kernel,
int kSize);
866 colorT *
end() {
return pixelsE; }
879 void applyHomoPixTfrm(colorT& (colorT::*HPT)());
880 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double),
double);
881 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double),
double,
double);
882 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double,
double),
double,
double,
double);
883 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double,
double,
double),
double,
double,
double,
double);
884 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double,
double,
double,
double),
double,
double,
double,
double,
double);
885 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double,
double,
double,
double,
double),
double,
double,
double,
double,
double,
double);
886 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
int),
int);
887 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
int,
int),
int,
int);
888 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
int,
int,
int),
int,
int,
int);
889 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
int,
int,
int,
int),
int,
int,
int,
int);
890 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT), colorT);
891 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT), colorT, colorT);
892 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT, colorT), colorT, colorT, colorT);
893 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT, colorT, colorT), colorT, colorT, colorT, colorT);
903 void autoHistStrech();
908 void autoMaxHistStrechRGB();
924 void combineRamCanvasBinOp(colorT& (colorT::*HPT)(colorT),
926 intCrdT trgX = 0, intCrdT trgY = 0,
927 intCrdT wide = -1, intCrdT tall = -1,
928 intCrdT srcX = 0, intCrdT srcY = 0);
946 void clrCanvasToBlack();
949 void clrCanvasToWhite();
952 void clrCanvasChannelToMin(
int chan);
955 void clrCanvasChannelToMax(
int chan);
971 inline void moveTo(intCrdT x, intCrdT y) { dfltX = x; dfltY = y; }
972 inline void moveTo(fltCrdT x, fltCrdT y) {
moveTo(real2intX(x), real2intY(y)); }
983 inline void setDfltColor(std::string cornerColor) { dfltColor.setToCorner(cornerColor); }
984 inline void setDfltColor(
const char* cornerColor) { dfltColor.setToCorner(std::string(cornerColor)); }
999 drawPointNC(x, y, color);
1043 void drawLine(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, colorArgType color);
1053 inline void drawLine(fltCrdT x, fltCrdT y) {
drawLine( dfltX, dfltY, real2intX(x), real2intY(y), dfltColor); }
1056 inline void drawLine(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2) {
drawLine( x1, y1, x2, y2, dfltColor); }
1057 inline void drawLine(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2) {
drawLine( x1, y1, x2, y2, dfltColor); }
1058 inline void drawLine(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2,
colorArgType color) {
drawLine( real2intX(x1), real2intY(y1), real2intX(x2), real2intY(y2), color); }
1074 void drawTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorArgType color);
1077 real2intX(thePoints[1].x), real2intY(thePoints[1].y),
1078 real2intX(thePoints[2].x), real2intY(thePoints[2].y), dfltColor); }
1080 real2intX(thePoints[1].x), real2intY(thePoints[1].y),
1081 real2intX(thePoints[2].x), real2intY(thePoints[2].y), color); }
1085 real2intX(point2.
x), real2intY(point2.
y),
1086 real2intX(point3.
x), real2intY(point3.
y), dfltColor); }
1088 real2intX(point2.
x), real2intY(point2.
y),
1089 real2intX(point3.
x), real2intY(point3.
y), color); }
1091 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); }
1092 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); }
1093 inline void drawTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3) {
drawTriangle(x1, y1, x2, y2, x3, y3, dfltColor); }
1110 void drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorArgType color);
1113 real2intX(thePoints[1].x), real2intY(thePoints[1].y),
1114 real2intX(thePoints[2].x), real2intY(thePoints[2].y), dfltColor); }
1116 real2intX(thePoints[1].x), real2intY(thePoints[1].y),
1117 real2intX(thePoints[2].x), real2intY(thePoints[2].y), color); }
1119 thePoints[1].x, thePoints[1].y,
1120 thePoints[2].x, thePoints[2].y, dfltColor); }
1123 real2intX(point2.
x), real2intY(point2.
y),
1124 real2intX(point3.
x), real2intY(point3.
y), dfltColor); }
1126 real2intX(point2.
x), real2intY(point2.
y),
1127 real2intX(point3.
x), real2intY(point3.
y), color); }
1129 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); }
1130 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); }
1131 inline void drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3) {
drawFillTriangle(x1, y1, x2, y2, x3, y3, dfltColor); }
1151 void drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorArgType color1, colorArgType color2, colorArgType color3);
1166 void drawRectangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, colorArgType color);
1175 inline void drawRectangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2) {
drawRectangle(real2intX(x1), real2intY(y1), real2intX(x2), real2intY(y2), dfltColor); }
1192 void drawFillRectangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, colorArgType color);
1223 void drawCircle(intCrdT centerX, intCrdT centerY, intCrdT radiusX, colorArgType color);
1230 inline void drawCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX) {
drawCircle(real2intX(centerX), real2intY(centerY), realDelta2intX(radiusX), dfltColor); }
1231 inline void drawCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX,
colorArgType color) {
drawCircle(real2intX(centerX), real2intY(centerY), realDelta2intX(radiusX), color); }
1232 inline void drawCircle(intCrdT centerX, intCrdT centerY, intCrdT radiusX) {
drawCircle(centerX, centerY, radiusX, dfltColor); }
1250 void drawFillCircle(intCrdT centerX, intCrdT centerY, intCrdT radiusX, colorArgType color);
1257 inline void drawFillCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX) {
drawFillCircle(real2intX(centerX), real2intY(centerY), realDelta2intX(radiusX), dfltColor); }
1269 void drawPLCurve(
int numPoints, intCrdT *x, intCrdT *y, colorArgType color);
1270 void drawPLCurve(
int numPoints, intCrdT *x, intCrdT *y);
1271 void drawPLCurve(
int numPoints, fltCrdT *x, fltCrdT *y, colorArgType color);
1272 void drawPLCurve(
int numPoints, fltCrdT *x, fltCrdT *y);
1273 void drawPLCurve(
int numPoints, pointIntType *thePoints, colorArgType color);
1274 void drawPLCurve(
int numPoints, pointIntType *thePoints);
1275 void drawPLCurve(
int numPoints, pointFltType *thePoints, colorArgType color);
1276 void drawPLCurve(
int numPoints, pointFltType *thePoints);
1292 void drawHersheyGlyph(
int glyphNum, intCrdT x, intCrdT y,
double magX,
double magY, colorArgType aColor);
1293 void drawHersheyGlyph(
int glyphNum, fltCrdT x, fltCrdT y,
double magX,
double magY,
colorArgType aColor) {
drawHersheyGlyph(glyphNum, real2intX(x), real2intY(y), magX, magY, aColor); }
1310 void drawString(std::string aString,
mjr::hershey::font aFont, intCrdT x, intCrdT y, colorArgType aColor,
double cex, intCrdT spc);
1312 drawString(aString, aFont, real2intX(x), real2intY(y), aColor, cex, spc);
1324 void drawStringBox(std::string aString,
mjr::hershey::font aFont, intCrdT x, intCrdT y, colorArgType stringColor, colorArgType boxColor,
double cex, intCrdT spc);
1326 drawStringBox(aString, aFont, real2intX(x), real2intY(y), stringColor, boxColor, cex, spc);
1336 bool supportLibTIFF();
1377 int readTIFFfile(std::string fileName);
1414 template <
class rcConT>
int writeTIFFfile(std::string fileName, rcConT rcConverter,
bool markAlpha);
1417 int writeTIFFfile(std::string fileName,
bool markAlpha =
true);
1435 int writeTGAfile(std::string fileName);
1478 int readRAWfile(std::string fileName);
1529 template <
class rcConT>
int writeRAWfile(std::string fileName, rcConT rcConverter);
1532 int writeRAWfile(std::string fileName);
1543 inline int isCliped(fltCrdT x, fltCrdT y)
const {
return isCliped(real2intX(x), real2intY(y)); }
1544 inline int isCliped(intCrdT x, intCrdT y)
const {
return ((x < 0) || (y < 0) || (x >= numPixX) || (y >= numPixY)); }
1550 inline int isOnCanvas(fltCrdT x, fltCrdT y)
const {
return isCliped(real2intX(x), real2intY(y)); }
1551 inline int isOnCanvas(intCrdT x, intCrdT y)
const {
return ((x >= 0) && (y >= 0) && (x < numPixX) && (y < numPixY)); }
1561 intCrdT real2intX(fltCrdT x)
const;
1566 intCrdT real2intY(fltCrdT y)
const;
1571 fltCrdT int2realX(intCrdT x);
1576 fltCrdT int2realY(intCrdT y);
1604 inline fltCrdT
int2realSideX(intCrdT x,
int side) {
return int2realX(x)+pixWidX/(side ?
static_cast<fltCrdT
>(2.0) :
static_cast<fltCrdT
>(-2.0)); }
1609 inline fltCrdT
int2realSideY(intCrdT y,
int side) {
return int2realY(y)+pixWidY/(side ?
static_cast<fltCrdT
>(2.0) :
static_cast<fltCrdT
>(-2.0)); }
1632 inline intCrdT
realDelta2intX(fltCrdT x)
const {
return static_cast<intCrdT
>(
static_cast<fltCrdT
>(x)/pixWidX); }
1637 inline intCrdT
realDelta2intY(fltCrdT y)
const {
return static_cast<intCrdT
>(
static_cast<fltCrdT
>(y)/pixWidY); }
1642 inline fltCrdT
intDelta2realX(intCrdT x)
const {
return static_cast<fltCrdT
>(x)*pixWidX; }
1647 inline fltCrdT
intDelta2realY(intCrdT y)
const {
return static_cast<fltCrdT
>(y)*pixWidY; }
1741 colorT *clonePixels();
1764 colorT getPxColor(intCrdT x, intCrdT y)
const;
1776 inline colorT
getPxColorWrap(intCrdT x, intCrdT y)
const {
return getPxColorNC(mjr::math::ivl::wrapCO(x, numPixX), mjr::math::ivl::wrapCO(y, numPixY)); }
1793 template <
int chanNum>
1794 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1798 template <
int chanNum>
1799 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1803 template <
int chanNum>
1804 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1808 template <
int chanNum>
1809 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1822 colorT getPxColorInterpolate(
double x,
double y, interpolationType interpMethod = interpolationType::BILINEAR);
1828 colorT getPxColorInterpBLin(
double x,
double y);
1834 colorT getPxColorInterpTrunc(
double x,
double y);
1840 colorT getPxColorInterpNear(
double x,
double y);
1846 colorT getPxColorInterpAvg4(
double x,
double y);
1852 colorT getPxColorInterpAvg9(
double x,
double y);
1866 void drawPointNC(intCrdT x, intCrdT y, colorArgType color);
1871 inline colorT
getPxColorNC(intCrdT x, intCrdT y)
const {
return pixels[numPixX * y + x]; }
1877 inline colorT&
getPxColorRefNC(intCrdT x, intCrdT y)
const {
return pixels[numPixX * y + x]; }
1884 inline void drawHorzLineNC(intCrdT xMin, intCrdT xMax, intCrdT yConst,
colorArgType color) {
for(intCrdT x=xMin;x<=xMax;x++) drawPointNC(x, yConst, color); }
1891 inline void drawVertLineNC(intCrdT yMin, intCrdT yMax, intCrdT xConst,
colorArgType color) {
for(intCrdT y=yMin;y<=yMax;y++) drawPointNC(xConst, y, color); }
1918 void colorizeFltCanvas(std::function<colorT (fltCrdT, fltCrdT)> cFun);
1919 void colorizeFltCanvas(std::function<colorT (pointFltType)> cFun);
1921 void colorizeIntCanvas(std::function<colorT (intCrdT, intCrdT)> cFun);
1922 void colorizeIntCanvas(std::function<colorT (pointIntType)> cFun);
1931 intCrdT retCount = 0;
1932 if( !isCliped(x1, y1) && !isCliped(x2, y2) ) {
1937 for(intCrdT y=y1;y<=y2;y++)
1938 for(intCrdT x=x1;x<=x2;x++)
1940 if ( !(getPxColorRefNC(x, y).isBlack()))
1947 return statNumNonZeroPixels(0, 0, numPixX-1, numPixY-1);
1954 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1955 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1957 newIntCoordsNC(-1, -1);
1958 newRealCoords(0.0, 0.0, 0.0, 0.0);
1961 setRealAxisDefaultOrientation();
1962 setIntAxisDefaultOrientation();
1963 setDefaultDrawMode();
1968 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1969 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1980 for(intCrdT y=0; y<numPixY; y++)
1981 for(intCrdT x=0; x<numPixX; x++)
1987 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1988 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
1997 pixels = theCanvas.
pixels;
2003 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2004 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2007 if (
this != &theCanvas) {
2015 pixels = theCanvas.
pixels;
2023 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2024 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2026 newIntCoordsNC(numPixX_p, numPixY_p);
2027 newRealCoords(minRealX_p, maxRealX_p, minRealY_p, maxRealY_p);
2028 pixels =
new colorT[numPixX * numPixY];
2029 pixelsE = pixels + (numPixX * numPixY);
2030 setRealAxisDefaultOrientation();
2031 setIntAxisDefaultOrientation();
2032 setDefaultDrawMode();
2037 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2038 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2040 if(pixels != NULL) {
2047 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2048 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2051 if(numPixX_p > intCrdMax) {
2052 throw std::invalid_argument(
"newIntCoordsNC: numPixX_p argument too large.");
2053 }
else if (numPixY_p > intCrdMax) {
2054 throw std::invalid_argument(
"newIntCoordsNC: numPixY_p argument too large.");
2056 numPix = numPixX_p * numPixY_p;;
2057 numPixX = numPixX_p;
2058 numPixY = numPixY_p;
2063 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2064 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2067 if(minRealX_p > maxRealX_p) {
2068 throw std::invalid_argument(
"newRealCoords: minRealX_p > maxRealX_p.");
2069 }
else if (minRealY_p > maxRealY_p) {
2070 throw std::invalid_argument(
"newRealCoords: minRealY_p > maxRealY_p.");
2072 minRealX = minRealX_p;
2073 maxRealX = maxRealX_p;
2074 minRealY = minRealY_p;
2075 maxRealY = maxRealY_p;
2081 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2082 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2085 canvasWidX = maxRealX - minRealX;
2086 canvasWidY = maxRealY - minRealY;
2087 pixWidX = (numPixX == 0 ? 0 : canvasWidX / numPixX);
2088 pixWidY = (numPixY == 0 ? 0 : canvasWidY / numPixY);
2092 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2093 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2096 for(intCrdT y=0; y<numPixY; y++)
2097 for(intCrdT x=0; x<numPixX; x++)
2098 getPxColorRefNC(x, y).setChanToMin(chan);
2102 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2103 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2106 for(intCrdT y=0; y<numPixY; y++)
2107 for(intCrdT x=0; x<numPixX; x++)
2108 getPxColorRefNC(x, y).setChanToMax(chan);
2112 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2113 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2131 for(intCrdT y=0; y<numPixY; y++)
2132 for(intCrdT x=0; x<numPixX; x++)
2133 getPxColorRefNC(x, y).setToBlack();
2140 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2141 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2144 for(intCrdT y=0; y<numPixY; y++)
2145 for(intCrdT x=0; x<numPixX; x++)
2146 getPxColorRefNC(x, y).setToWhite();
2150 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2151 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2154 clrCanvas(dfltColor);
2158 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2159 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2162 for(intCrdT y=0; y<numPixY; y++)
2163 for(intCrdT x=0; x<numPixX; x++)
2164 drawPointS(x, y, color);
2168 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2169 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2174 for(intCrdT y=0;y<numPixY;y++) {
2175 for(intCrdT x=0;x<numPixX;x++) {
2176 colorT daColor = getPxColorNC(x, y);
2186 double c = 1.0 *
static_cast<double>(colorT::maxChanVal-colorT::minChanVal) /
static_cast<double>(cmax-cmin);
2187 double b =
static_cast<double>(colorT::maxChanVal) - 1.0 * c *
static_cast<double>(cmax);
2188 applyHomoPixTfrm(&colorT::tfrmLinearGreyLevelScale, c, b);
2193 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2194 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2197 colorT cmin; cmin.setChans(cmin.maxChanVal);
2198 colorT cmax; cmax.setChans(cmin.minChanVal);
2199 for(intCrdT y=0;y<numPixY;y++) {
2200 for(intCrdT x=0;x<numPixX;x++) {
2201 colorT daColor = getPxColorNC(x, y);
2202 cmin.tfrmMin(daColor);
2203 cmax.tfrmMax(daColor);
2208 if(absCompMax-absCompMin > 0) {
2209 double rc = 1.0*
static_cast<double>(cmin.maxChanVal-cmin.minChanVal)/
static_cast<double>(cmax.getRed()-cmin.getRed());
2210 double rb = cmin.maxChanVal - 1.0*rc*cmax.getRed();
2211 double gc = 1.0*
static_cast<double>(cmin.maxChanVal-cmin.minChanVal)/
static_cast<double>(cmax.getGreen()-cmin.getGreen());
2212 double gb = cmin.maxChanVal - 1.0*gc*cmax.getGreen();
2213 double bc = 1.0*
static_cast<double>(cmin.maxChanVal-cmin.minChanVal)/
static_cast<double>(cmax.getBlue()-cmin.getBlue());
2214 double bb = cmin.maxChanVal - 1.0*bc*cmax.getBlue();
2215 applyHomoPixTfrm(&colorT::tfrmLinearGreyLevelScaleRGB, rc, rb, gc, gb, bc, bb);
2220 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2221 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2224 for(intCrdT y=0; y<numPixY; y++)
2225 for(intCrdT x=0; x<numPixX; x++)
2226 (getPxColorRefNC(x, y).*HPT)();
2230 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2231 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2234 for(intCrdT y=0; y<numPixY; y++)
2235 for(intCrdT x=0; x<numPixX; x++)
2236 (getPxColorRefNC(x, y).*HPT)(arg1);
2240 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2241 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2244 for(intCrdT y=0; y<numPixY; y++)
2245 for(intCrdT x=0; x<numPixX; x++)
2246 (getPxColorRefNC(x, y).*HPT)(arg1, arg2);
2250 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2251 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2254 for(intCrdT y=0; y<numPixY; y++)
2255 for(intCrdT x=0; x<numPixX; x++)
2256 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3);
2260 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2261 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2263 ramCanvasTpl<colorT, intCrdT, fltCrdT, enableDrawModes>::applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT, colorT, colorT), colorT arg1, colorT arg2, colorT arg3, colorT arg4) {
2264 for(intCrdT y=0; y<numPixY; y++)
2265 for(intCrdT x=0; x<numPixX; x++)
2266 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4);
2270 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2271 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2274 for(intCrdT y=0; y<numPixY; y++)
2275 for(intCrdT x=0; x<numPixX; x++)
2276 (getPxColorRefNC(x, y).*HPT)(arg1);
2280 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2281 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2284 for(intCrdT y=0; y<numPixY; y++)
2285 for(intCrdT x=0; x<numPixX; x++)
2286 (getPxColorRefNC(x, y).*HPT)(arg1, arg2);
2290 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2291 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2294 for(intCrdT y=0; y<numPixY; y++)
2295 for(intCrdT x=0; x<numPixX; x++)
2296 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3);
2300 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2301 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2303 ramCanvasTpl<colorT, intCrdT, fltCrdT, enableDrawModes>::applyHomoPixTfrm(colorT& (colorT::*HPT)(
int,
int,
int,
int),
int arg1,
int arg2,
int arg3,
int arg4) {
2304 for(intCrdT y=0; y<numPixY; y++)
2305 for(intCrdT x=0; x<numPixX; x++)
2306 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4);
2310 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2311 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2314 for(intCrdT y=0; y<numPixY; y++)
2315 for(intCrdT x=0; x<numPixX; x++)
2316 (getPxColorRefNC(x, y).*HPT)(arg1);
2320 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2321 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2324 for(intCrdT y=0; y<numPixY; y++)
2325 for(intCrdT x=0; x<numPixX; x++)
2326 (getPxColorRefNC(x, y).*HPT)(arg1, arg2);
2330 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2331 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2334 for(intCrdT y=0; y<numPixY; y++)
2335 for(intCrdT x=0; x<numPixX; x++)
2336 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3);
2340 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2341 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2344 double arg1,
double arg2,
double arg3,
double arg4) {
2345 for(intCrdT y=0; y<numPixY; y++)
2346 for(intCrdT x=0; x<numPixX; x++)
2347 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4);
2351 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2352 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2355 double arg1,
double arg2,
double arg3,
double arg4,
double arg5) {
2356 for(intCrdT y=0; y<numPixY; y++)
2357 for(intCrdT x=0; x<numPixX; x++)
2358 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4, arg5);
2362 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2363 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2365 double arg1,
double arg2,
double arg3,
double arg4,
double arg5,
double arg6) {
2366 for(intCrdT y=0; y<numPixY; y++)
2367 for(intCrdT x=0; x<numPixX; x++)
2368 (getPxColorRefNC(x, y).*HPT)(arg1, arg2, arg3, arg4, arg5, arg6);
2372 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2373 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2376 intCrdT trgX, intCrdT trgY,
2377 intCrdT wide, intCrdT tall,
2378 intCrdT srcX, intCrdT srcY) {
2381 wide = numPixX-trgX;
2384 if(wide > (numPixX-srcX))
2393 tall = numPixY-srcY;
2396 if(tall > (numPixY-srcY))
2397 tall = numPixY-srcY;
2403 intCrdT xMax = trgX+wide;
2404 intCrdT yMax = trgY+tall;
2405 for(intCrdT y=trgY, ys=srcY; y<yMax; y++, ys++)
2406 for(intCrdT x=trgX, xs=srcX; x<xMax; x++, xs++)
2407 (getPxColorRefNC(x, y).*HPT)(theCanvas.
getPxColor(xs, ys));
2411 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2412 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2418 if( (y1 < 0) || (y1 >= numPixY) )
2426 drawHorzLineNC(x1, x2, y1, color);
2427 }
else if(x1 == x2) {
2428 if( (x1 < 0) || (x1 >= numPixX) )
2436 drawVertLineNC(y1, y2, x1, color);
2446 if( (y2 < 0) || (x2 < 0) || (x1 >= numPixX) || (y1 >= numPixY) )
2457 y2 = y2 - (x2 - numPixX) - 1;
2461 x2 = x2 - (y2 - numPixY) - 1;
2464 for(x=x1,y=y1;x<=x2;y++,x++)
2465 drawPointNC(x, y, color);
2466 }
else if(dx == -dy) {
2467 if( (x2 < 0) || (y2 >= numPixY) || (x1 >= numPixX) || (y1 < 0) )
2474 y2 = y2 + (x2 - (numPixX - 1));
2482 x1 = x1 + (y1 - (numPixY - 1));
2485 for(x=x1,y=y1;x<=x2;y--,x++)
2486 drawPointNC(x, y, color);
2492 if( (y2 < 0) || (x2 < 0) || (x1 >= numPixX) || (y1 >= numPixY) )
2495 y1 = (int)(1.0*y1-x1*dy/dx);
2499 x1 = (int)(1.0*x1-y1*dx/dy);
2503 y2 = (int)((1.0*dy*(numPixX-1)+y1*dx-x1*dy)/dx);
2507 x2 = (int)(((numPixY-1)*dx-y2*dx+x2*dy)/dy);
2516 drawPoint(x, y, color);
2530 drawPoint(x, y, color);
2541 if( (x2 < 0) || (y2 >= numPixY) || (x1 >= numPixX) || (y1 < 0) )
2544 y1 = (int)(1.0*y1-x1*dy/dx);
2548 x2 = (int)(1.0*x2-y2*dx/dy);
2552 y2 = (int)((1.0*dy*(numPixX-1)+y2*dx-x2*dy)/dx);
2556 x1 = (int)(((numPixY-1)*dx-y1*dx+x1*dy)/dy);
2564 drawPoint(x, y, color);
2578 drawPoint(x, y, color);
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 newIntCoordsNC(-1, -1);
2599 if(pixels != NULL) {
2607 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2608 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2612 newIntCoordsNC(new_numPixX, new_numPixY);
2614 if(new_pixels != NULL)
2615 pixels = new_pixels;
2619 pixelsE = pixels+(new_numPixX * new_numPixY);
2623 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2624 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2627 if((numPixX_p<=0) || (numPixY_p<=0)) {
2630 if( (numPixX_p!=numPixX) || (numPixY_p!=numPixY) ) {
2631 colorT *new_pixels =
new colorT[numPixX_p * numPixY_p];
2632 rePointPixels(new_pixels, numPixX_p, numPixY_p);
2640 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2641 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2644 reallocCanvas(new_numPixX_p, new_numPixY_p);
2648 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2649 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2652 if( (new_numPixX_p != numPixX) || (new_numPixY_p != numPixY) ) {
2654 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2657 for(intCrdT y=0;y<new_numPixY_p;y++)
2658 for(intCrdT x=0;x<new_numPixX_p;x++)
2659 new_pixels[new_numPixX_p * (y) + (x)] = color;
2661 intCrdT yMax = std::min(numPixY+y1, new_numPixY_p);
2662 intCrdT xMax = std::min(numPixX+x1, new_numPixX_p);
2665 if ((x1 < new_numPixX_p) && (y1 < new_numPixY_p))
2666 for(intCrdT y=y1;y<yMax;y++)
2667 for(intCrdT x=x1;x<xMax;x++)
2668 new_pixels[new_numPixX_p * (y) + (x)] = getPxColor(x-x1, y-y1);
2670 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2675 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2676 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2679 if( !isCliped(x1, y1) && !isCliped(x2, y2) ) {
2684 intCrdT xp, yp, x, y;
2685 intCrdT new_numPixX_p = x2-x1+1;
2686 intCrdT new_numPixY_p = y2-y1+1;
2687 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2690 for(y=y1,yp=0;y<=y2;y++,yp++)
2691 for(x=x1,xp=0;x<=x2;x++,xp++)
2692 new_pixels[new_numPixX_p * yp + xp] = getPxColor(x, y);
2694 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 for(intCrdT y=0; y<numPixY/2; y++)
2704 for(intCrdT x=0; x<numPixX; x++) {
2705 colorT aColor = getPxColor(x, numPixY-y-1);
2706 drawPointNC(x, numPixY-y-1, getPxColor(x, y));
2707 drawPointNC(x, y, aColor);
2712 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2713 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2716 for(intCrdT x=0; x<numPixX/2; x++)
2717 for(intCrdT y=0; y<numPixY; y++) {
2718 colorT aColor = getPxColor(numPixX-x-1, y);
2719 drawPointNC(numPixX-x-1, y, getPxColor(x, y));
2720 drawPointNC(x, y, aColor);
2725 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2726 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2729 intCrdT new_numPixX_p = numPixY;
2730 intCrdT new_numPixY_p = numPixX;
2731 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2732 for(intCrdT y=0; y<numPixY; y++)
2733 for(intCrdT x=0; x<numPixX; x++)
2734 new_pixels[new_numPixX_p * (x) + (y)] = getPxColor(x, y);
2735 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2739 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2740 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2743 intCrdT new_numPixX_p = numPixY;
2744 intCrdT new_numPixY_p = numPixX;
2745 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2746 for(intCrdT y=0; y<numPixY; y++)
2747 for(intCrdT x=0; x<numPixX; x++)
2748 new_pixels[new_numPixX_p * (numPixX-x-1) + (y)] = getPxColor(x, y);
2749 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2753 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2754 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2757 intCrdT new_numPixX_p = numPixY;
2758 intCrdT new_numPixY_p = numPixX;
2759 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2760 for(intCrdT y=0; y<numPixY; y++)
2761 for(intCrdT x=0; x<numPixX; x++)
2762 new_pixels[new_numPixX_p * (x) + (numPixY-y-1)] = getPxColor(x, y);
2763 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2767 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2768 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2771 intCrdT new_numPixX_p = numPixX;
2772 intCrdT new_numPixY_p = numPixY;
2773 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2774 for(intCrdT y=0; y<numPixY; y++)
2775 for(intCrdT x=0; x<numPixX; x++)
2776 new_pixels[new_numPixX_p * (numPixY-y-1) + (numPixX-x-1)] = getPxColor(x, y);
2777 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
2781 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2782 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2785 unsigned int endiannessProbe = 1;
2786 if(((
char *)&endiannessProbe)[0]) {
2787 return endianType::LITTLE;
2789 return endianType::BIG;
2794 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2795 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2802 if (numBytes == 1) {
2803 uint8_t tmp = (data & 0xff);
2804 oStream.write((
const char *)&tmp, 1);
2807 endianType endiannessToUse = (endianness == endianType::AUTO ? platformEndianness() : endianness);
2808 if(endiannessToUse == endianType::LITTLE) {
2809 for(
int curByte=0; curByte<numBytes; curByte++) {
2810 uint8_t tmp = ((data >> (8*curByte)) & 0xff);
2811 oStream.write((
const char *)&tmp, 1);
2814 for(
int curByte=(numBytes-1); curByte>=0; curByte--) {
2815 uint8_t tmp = ((data >> (8*curByte)) & 0xff);
2816 oStream.write((
const char *)&tmp, 1);
2825 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2826 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2829 for(intCrdT yi=0;yi<numPixY;yi++) {
2830 for(intCrdT xi=0;xi<numPixX;xi++) {
2831 fltCrdT xf = int2realX(xi);
2832 fltCrdT yf = int2realY(yi);
2833 colorT aColor = cFun(xf, yf);
2834 drawPoint(xi, yi, aColor);
2840 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2841 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2844 for(intCrdT yi=0;yi<numPixY;yi++) {
2845 for(intCrdT xi=0;xi<numPixX;xi++) {
2847 colorT aColor = cFun(xyPt);
2848 drawPoint(xi, yi, aColor);
2854 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2855 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2858 for(intCrdT yi=0;yi<numPixY;yi++) {
2859 for(intCrdT xi=0;xi<numPixX;xi++) {
2860 colorT aColor = cFun(xi, yi);
2861 drawPoint(xi, yi, aColor);
2867 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2868 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2871 for(intCrdT yi=0;yi<numPixY;yi++) {
2872 for(intCrdT xi=0;xi<numPixX;xi++) {
2874 colorT aColor = cFun(xyPt);
2875 drawPoint(xi, yi, aColor);
2881 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2882 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2886 std::ofstream outStream;
2887 outStream.open(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
2888 if (outStream.is_open())
2889 outStream.imbue(std::locale::classic());
2895 if(numPixX > 0xffff)
2899 if(numPixY > 0xffff)
2903 writeUIntToStream(outStream, endianType::LITTLE, 1, 0);
2904 writeUIntToStream(outStream, endianType::LITTLE, 1, 0);
2905 writeUIntToStream(outStream, endianType::LITTLE, 1, 2);
2906 writeUIntToStream(outStream, endianType::LITTLE, 2, 0);
2907 writeUIntToStream(outStream, endianType::LITTLE, 2, 0);
2908 writeUIntToStream(outStream, endianType::LITTLE, 1, 0);
2909 writeUIntToStream(outStream, endianType::LITTLE, 2, 0);
2910 writeUIntToStream(outStream, endianType::LITTLE, 2, 0);
2911 writeUIntToStream(outStream, endianType::LITTLE, 2, numPixX);
2912 writeUIntToStream(outStream, endianType::LITTLE, 2, numPixY);
2913 writeUIntToStream(outStream, endianType::LITTLE, 1, 24);
2914 writeUIntToStream(outStream, endianType::LITTLE, 1, 0);
2920 bool yNat = isIntAxOrientationNaturalY();
2921 bool xNat = isIntAxOrientationNaturalX();
2922 for((yNat?y=0:y=(numPixY-1)); (yNat?y<numPixY:y>=0); (yNat?y++:y--)) {
2923 for((xNat?x=0:x=(numPixX-1)); (xNat?x<numPixX:x>=0); (xNat?x++:x--)) {
2924 colorT aColor = getPxColorRefNC(x, y);
2925 writeUIntToStream(outStream, endianType::LITTLE, 1, aColor.getChan_byte(aColor.bestBlueChan()));
2926 writeUIntToStream(outStream, endianType::LITTLE, 1, aColor.getChan_byte(aColor.bestGreenChan()));
2927 writeUIntToStream(outStream, endianType::LITTLE, 1, aColor.getChan_byte(aColor.bestRedChan()));
2934 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2935 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2939 return writeRAWfile(fileName, tmp);
2943 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2944 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2945 template <class rcConT>
2949 std::ofstream outStream;
2950 outStream.open(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
2951 if (outStream.is_open())
2952 outStream.imbue(std::locale::classic());
2956 outStream <<
"MJRRAW\n";
2957 outStream << std::setw(19) << std::setfill(
'0') << rcConverter.getNumPixX() <<
"x";
2958 outStream << std::setw(19) << std::setfill(
'0') << rcConverter.getNumPixY() <<
"y";
2959 outStream << std::setw(27) << std::setfill(
'0') << rcConT::colorType::channelCount <<
"c";
2960 outStream << std::setw(11) << std::setfill(
'0') << rcConT::colorType::bitsPerChan <<
"b";
2961 outStream << (rcConT::colorType::chanIsUnsigned ?
"UNS" :
"SGN") <<
"s";
2962 outStream << (rcConT::colorType::chanIsInt ?
"INT" :
"FLT") <<
"t";
2963 outStream << (platformEndianness() == endianType::LITTLE ?
"LTL" :
"BIG") <<
"i";
2969 bool yNat = !(rcConverter.isIntAxOrientationNaturalY());
2970 bool xNat = rcConverter.isIntAxOrientationNaturalX();
2971 for((yNat?y=0:y=(rcConverter.getNumPixY()-1)); (yNat?y<rcConverter.getNumPixY():y>=0); (yNat?y++:y--)) {
2972 for((xNat?x=0:x=(rcConverter.getNumPixX()-1)); (xNat?x<rcConverter.getNumPixX():x>=0); (xNat?x++:x--)) {
2973 typename rcConT::colorType aColor = rcConverter.getPxColorNC(x, y);
2974 for(
int c=0; c<aColor.channelCount; c++) {
2975 typename rcConT::colorType::channelType aChanValue = aColor.getChan(c);
2976 outStream.write((
const char *)&aChanValue,
sizeof(
colorChanType));
2984 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2985 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2989 return writeTIFFfile(fileName, tmp, markAlpha);
2993 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2994 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2995 template <class rcConT>
2999 if(rcConT::colorType::bitsPerChan < 8)
3001 if(rcConT::colorType::bitsPerChan > 0xffff)
3003 if(rcConT::colorType::channelCount < 1)
3005 if(rcConT::colorType::channelCount > 0xffff)
3007 if(rcConverter.getNumPixX() < 1)
3009 if(rcConverter.getNumPixX() > 0x7fffffff)
3011 if(rcConverter.getNumPixY() < 1)
3013 if(rcConverter.getNumPixY() > 0x7fffffff)
3015 unsigned long bytesPerRow = rcConverter.getNumPixX() * rcConT::colorType::bitsPerChan / 8ul * rcConT::colorType::channelCount;
3016 if(bytesPerRow > 0xffffffff)
3018 if(bytesPerRow * rcConverter.getNumPixY() > 0xfffffffff)
3022 const uint16_t tcTIFF_BIGENDIAN = 0x4d4d;
3023 const uint16_t tcTIFF_LITTLEENDIAN = 0x4949;
3024 const uint16_t tcPHOTOMETRIC_MINISBLACK = 1;
3025 const uint16_t tcPHOTOMETRIC_RGB = 2;
3026 const uint16_t tcORIENTATION_TOPLEFT = 1;
3027 const uint16_t tcPLANARCONFIG_CONTIG = 1;
3028 const uint16_t tcRESUNIT_NONE = 1;
3029 const uint16_t tcSAMPLEFORMAT_UINT = 1;
3030 const uint16_t tcSAMPLEFORMAT_IEEEFP = 3;
3051 uint16_t endianNum = (fe == endianType::LITTLE ? tcTIFF_LITTLEENDIAN : tcTIFF_BIGENDIAN);
3052 uint32_t tifWidth = (uint32_t)rcConverter.getNumPixX();
3053 uint32_t tifLength = (uint32_t)rcConverter.getNumPixY();
3054 uint32_t tifSPP = (uint32_t)rcConT::colorType::channelCount;
3055 uint16_t tifBPS = (uint16_t)(rcConT::colorType::bitsPerChan);
3056 uint32_t bytePerSmp = tifBPS / 8;
3057 uint32_t tifSBC = tifLength * tifWidth * bytePerSmp * tifSPP;
3058 bool haveRGB = tifSPP>=3;
3059 uint16_t numImgSmp = (haveRGB ? 3 : 1);
3060 uint16_t tifPMI = (haveRGB ? tcPHOTOMETRIC_RGB : tcPHOTOMETRIC_MINISBLACK);
3061 uint16_t tifPC = tcPLANARCONFIG_CONTIG;
3062 uint16_t tifOri = tcORIENTATION_TOPLEFT;
3063 uint16_t tifResU = tcRESUNIT_NONE;
3064 bool haveXS = !((tifSPP==1) || (tifSPP==3));
3065 bool haveManyXS = tifSPP>4;
3066 uint16_t numTags = 1+14 + (haveXS ? 1 : 0);
3067 bool haveManyBPS = tifSPP>1;
3068 uint32_t numXS = tifSPP - numImgSmp;
3069 uint32_t xResOff = 14 + 12 * numTags;
3070 uint32_t yResOff = xResOff + 8;
3071 uint32_t bpsOff = yResOff + 8;
3072 uint32_t xsOff = bpsOff + (haveManyBPS ? 2 * tifSPP : 0);
3073 uint32_t imgOff = xsOff + (haveManyXS ? 2 * numXS : 0);
3074 uint16_t sampFmt = (rcConT::colorType::chanIsInt ? tcSAMPLEFORMAT_UINT : tcSAMPLEFORMAT_IEEEFP);
3076 std::ofstream outStream;
3077 outStream.open(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
3078 if (outStream.is_open())
3079 outStream.imbue(std::locale::classic());
3083 writeUIntToStream(outStream, fe, 2, endianNum);
3084 writeUIntToStream(outStream, fe, 2, 42);
3085 writeUIntToStream(outStream, fe, 4, 8);
3086 writeUIntToStream(outStream, fe, 2, numTags);
3087 writeUIntToStream(outStream, fe, 2, 0x100); writeUIntToStream(outStream, fe, 2, 4);
3088 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, tifWidth);
3089 writeUIntToStream(outStream, fe, 2, 0x101); writeUIntToStream(outStream, fe, 2, 4);
3090 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, tifLength);
3091 writeUIntToStream(outStream, fe, 2, 0x102); writeUIntToStream(outStream, fe, 2, 3);
3092 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifBPS); writeUIntToStream(outStream, fe, 2, 0);
3093 writeUIntToStream(outStream, fe, 2, 0x103); writeUIntToStream(outStream, fe, 2, 3);
3094 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, 1); writeUIntToStream(outStream, fe, 2, 0);
3095 writeUIntToStream(outStream, fe, 2, 0x106); writeUIntToStream(outStream, fe, 2, 3);
3096 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifPMI); writeUIntToStream(outStream, fe, 2, 0);
3097 writeUIntToStream(outStream, fe, 2, 0x111); writeUIntToStream(outStream, fe, 2, 4);
3098 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, imgOff);
3099 writeUIntToStream(outStream, fe, 2, 0x112); writeUIntToStream(outStream, fe, 2, 3);
3100 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifOri); writeUIntToStream(outStream, fe, 2, 0);
3101 writeUIntToStream(outStream, fe, 2, 0x115); writeUIntToStream(outStream, fe, 2, 3);
3102 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifSPP); writeUIntToStream(outStream, fe, 2, 0);
3103 writeUIntToStream(outStream, fe, 2, 0x116); writeUIntToStream(outStream, fe, 2, 4);
3104 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, tifLength);
3105 writeUIntToStream(outStream, fe, 2, 0x117); writeUIntToStream(outStream, fe, 2, 4);
3106 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, tifSBC);
3107 writeUIntToStream(outStream, fe, 2, 0x11A); writeUIntToStream(outStream, fe, 2, 5);
3108 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, xResOff);
3109 writeUIntToStream(outStream, fe, 2, 0x11B); writeUIntToStream(outStream, fe, 2, 5);
3110 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, yResOff);
3111 writeUIntToStream(outStream, fe, 2, 0x11C); writeUIntToStream(outStream, fe, 2, 3);
3112 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifPC); writeUIntToStream(outStream, fe, 2, 0);
3113 writeUIntToStream(outStream, fe, 2, 0x128); writeUIntToStream(outStream, fe, 2, 3);
3114 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 2, tifResU); writeUIntToStream(outStream, fe, 2, 0);
3117 writeUIntToStream(outStream, fe, 2, 0x152); writeUIntToStream(outStream, fe, 2, 3);
3118 writeUIntToStream(outStream, fe, 4, numXS); writeUIntToStream(outStream, fe, 4, xsOff);
3121 writeUIntToStream(outStream, fe, 2, 0x152); writeUIntToStream(outStream, fe, 2, 3);
3122 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, 1);
3124 writeUIntToStream(outStream, fe, 2, 0x152); writeUIntToStream(outStream, fe, 2, 3);
3125 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, 0);
3130 writeUIntToStream(outStream, fe, 2, 0x153);
3131 writeUIntToStream(outStream, fe, 2, 3); writeUIntToStream(outStream, fe, 4, 1);
3132 writeUIntToStream(outStream, fe, 2, sampFmt); writeUIntToStream(outStream, fe, 2, 0);
3134 writeUIntToStream(outStream, fe, 4, 0);
3135 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, 1);
3136 writeUIntToStream(outStream, fe, 4, 1); writeUIntToStream(outStream, fe, 4, 1);
3138 for(
unsigned int i=0; i<tifSPP; i++)
3139 writeUIntToStream(outStream, fe, 2, tifBPS);
3142 for(
unsigned int i=0; i<numXS; i++)
3143 writeUIntToStream(outStream, fe, 4, 0);
3146 bool yNat = !(rcConverter.isIntAxOrientationNaturalY());
3147 bool xNat = rcConverter.isIntAxOrientationNaturalX();
3148 for((yNat?y=0:y=(rcConverter.getNumPixY()-1)); (yNat?y<rcConverter.getNumPixY():y>=0); (yNat?y++:y--)) {
3149 for((xNat?x=0:x=(rcConverter.getNumPixX()-1)); (xNat?x<rcConverter.getNumPixX():x>=0); (xNat?x++:x--)) {
3150 typename rcConT::colorType aColor = rcConverter.getPxColorNC(x, y);
3151 for(
int c=0; c<aColor.channelCount; c++) {
3152 typename rcConT::colorType::channelType aChanValue = aColor.getChan(c);
3153 if (rcConT::colorType::chanIsInt)
3154 writeUIntToStream(outStream, fe, bytePerSmp, aChanValue);
3156 outStream.write((
const char *)&aChanValue, bytePerSmp);
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 intCrdT x1, intCrdT y1,
3170 intCrdT x2, intCrdT y2,
3171 int redChan,
int greenChan,
int blueChan,
int alphaChan) {
3177 if(x1 < 0)
return 1;
3178 if(x2 >= numPixX)
return 1;
3179 if(y1 < 0)
return 1;
3180 if(y2 >= numPixY)
return 1;
3181 if(x2 < x1)
return 2;
3182 if(y2 < y1)
return 3;
3184 int bytesPerPix = (redChan<0?0:1) + (greenChan<0?0:1) + (blueChan<0?0:1) + (alphaChan<0?0:1);
3185 if(bytesPerPix < 1)
return 4;
3188 rasterData = (uint8_t *)
new uint8_t[(y2-y1+1)*(x2-x1+1)*bytesPerPix];
3190 if(rasterData == 0)
return 5;
3192 uint8_t *curPixComp = (uint8_t *)rasterData;
3193 for(intCrdT y=y1; y<=y2; y++) {
3194 for(intCrdT x=x1; x<=x2; x++) {
3195 colorT aColor = getPxColorNC(x, y);
3196 if(redChan >= 0) curPixComp[redChan] = aColor.getChan_byte(aColor.bestRedChan());
3197 if(greenChan >= 0) curPixComp[greenChan] = aColor.getChan_byte(aColor.bestGreenChan());
3198 if(blueChan >= 0) curPixComp[blueChan] = aColor.getChan_byte(aColor.bestBlueChan());
3199 if(alphaChan >= 0) curPixComp[alphaChan] = aColor.getChan_byte(aColor.bestAlphaChan());
3200 curPixComp += bytesPerPix;
3208 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3209 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3212 if(realAxOrientationX == realAxisOrientation::NATURAL)
3213 return static_cast<intCrdT
>((
static_cast<fltCrdT
>(x) - minRealX) / pixWidX);
3215 return static_cast<intCrdT
>((maxRealX -
static_cast<fltCrdT
>(x)) / pixWidX);
3219 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3220 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3223 if(realAxOrientationY == realAxisOrientation::NATURAL)
3224 return static_cast<intCrdT
>((
static_cast<fltCrdT
>(y) - minRealY) / pixWidY);
3226 return static_cast<intCrdT
>((maxRealY -
static_cast<fltCrdT
>(y)) / pixWidY);
3230 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3231 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3234 if(realAxOrientationX == realAxisOrientation::NATURAL)
3235 return static_cast<fltCrdT
>(x) * pixWidX + minRealX;
3237 return maxRealX -
static_cast<fltCrdT
>(x) * pixWidX;
3241 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3242 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3245 if(realAxOrientationY == realAxisOrientation::NATURAL)
3246 return static_cast<fltCrdT
>(y) * pixWidY + minRealY;
3248 return maxRealY -
static_cast<fltCrdT
>(y) * pixWidY;
3252 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3253 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3256 colorT *pixelsCopy =
new colorT[numPixX * numPixY];
3257 for(intCrdT y=0; y<numPixY; y++)
3258 for(intCrdT x=0; x<numPixX; x++)
3259 pixelsCopy[numPixX * y + x] = getPxColorNC(x, y);
3263 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3264 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3267 if(isOnCanvas(x, y)) [[likely]]
3268 return pixels[numPixX * y + x];
3270 return colorT().setToBlack();
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 switch (interpMethod) {
3279 case interpolationType::BILINEAR :
return getPxColorInterpBLin(x, y);
3280 case interpolationType::TRUNCATE :
return getPxColorInterpBLin(x, y);
3281 case interpolationType::NEAREST :
return getPxColorInterpBLin(x, y);
3282 case interpolationType::AVERAGE4 :
return getPxColorInterpBLin(x, y);
3283 case interpolationType::AVERAGE9 :
return getPxColorInterpBLin(x, y);
3284 default :
return colorT(
"green");
3289 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3290 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3293 double x1 = std::floor(x);
3294 double y1 = std::floor(y);
3295 double x2 = std::ceil(x);
3296 double y2 = std::ceil(y);
3298 intCrdT x1i =
static_cast<intCrdT
>(x1);
3299 intCrdT y1i =
static_cast<intCrdT
>(y1);
3300 intCrdT x2i =
static_cast<intCrdT
>(x2);
3301 intCrdT y2i =
static_cast<intCrdT
>(y2);
3305 if ((x1i >= 0) && (y1i >= 0) && (x2i < numPixX) && (y2i < numPixY)) {
3306 double eps = 0.00001;
3307 double xD21 = x2 - x1;
3308 double yD21 = y2 - y1;
3310 if (mjr::math::fc::not_near_zero(xD21, eps))
3311 wH = (x - x1) / xD21;
3313 if (mjr::math::fc::not_near_zero(yD21, eps))
3314 wV = (y - y1) / yD21;
3318 c1.linearInterpolate(wH, getPxColorRefNC(x1i, y1i), getPxColorRefNC(x2i, y1i));
3319 c2.linearInterpolate(wH, getPxColorRefNC(x1i, y2i), getPxColorRefNC(x2i, y2i));
3320 cF.linearInterpolate(wV, c1, c2);
3328 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3329 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3332 return getPxColor(
static_cast<intCrdT
>(std::trunc(x)),
static_cast<intCrdT
>(std::trunc(y)));
3336 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3337 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3340 return getPxColor(
static_cast<intCrdT
>(std::round(x)),
static_cast<intCrdT
>(std::round(y)));
3344 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3345 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3348 intCrdT xi =
static_cast<intCrdT
>(std::round(x));
3349 intCrdT yi =
static_cast<intCrdT
>(std::round(y));
3351 for(
int chan=0; chan<colorT::channelCount; chan++) {
3353 for(intCrdT ydi=-1; ydi<=1; ydi++) {
3354 intCrdT icY = yi + ydi;
3355 for(intCrdT xdi=-1; xdi<=1; xdi++) {
3356 intCrdT icX = xi + xdi;
3357 if (!(isCliped(icX, icY))) {
3358 newChanValue += getPxColor(icX, icY).getChan(chan);
3362 newColor.setChan(chan,
static_cast<colorChanType>(newChanValue / 9));
3368 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3369 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3372 double x1 = std::floor(x);
3373 double y1 = std::floor(y);
3374 double x2 = std::ceil(x);
3375 double y2 = std::ceil(y);
3377 intCrdT x1i =
static_cast<intCrdT
>(x1);
3378 intCrdT y1i =
static_cast<intCrdT
>(y1);
3379 intCrdT x2i =
static_cast<intCrdT
>(x2);
3380 intCrdT y2i =
static_cast<intCrdT
>(y2);
3382 if ((x1i >= 0) && (y1i >= 0) && (x2i < numPixX) && (y2i < numPixY)) {
3384 colorT c1 = pixels[numPixX * y1i + x1i];
3385 c1.tfrmMean(pixels[numPixX * y1i + x2i]);
3387 colorT c2 = pixels[numPixX * y2i + x1i];
3388 c2.tfrmMean(pixels[numPixX * y2i + x2i]);
3394 return colorT().setToBlack();
3589 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3590 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3598 for(y=y1; y<=y2; y++)
3609 for(x=x1,y=y1;x<=x2;y++,x++)
3611 }
else if(dx == -dy) {
3612 for(x=x1,y=y1;x<=x2;y--,x++)
3722 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3723 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3726 drawFillTriangleUtl(x1, y1, x2, y2, x3, y3, color, color, color,
true);
3730 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3731 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3734 intCrdT x2, intCrdT y2,
3735 intCrdT x3, intCrdT y3,
3737 drawFillTriangleUtl(x1, y1, x2, y2, x3, y3, color1, color2, color3,
false);
3741 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3742 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3745 intCrdT x2, intCrdT y2,
3746 intCrdT x3, intCrdT y3,
3747 colorT c1, colorT c2, colorT c3,
bool solid) {
3748 static intCrdT *minPts, *maxPts;
3749 static intCrdT numPts;
3751 if( isCliped(x1, y1) || isCliped(x2, y2) || isCliped(x3, y3))
3756 if(minPts == NULL) {
3757 minPts =
new intCrdT[numPixY];
3758 maxPts =
new intCrdT[numPixY];
3761 if(numPts != numPixY) {
3764 minPts =
new intCrdT[numPixY];
3765 maxPts =
new intCrdT[numPixY];
3771 if (!(solid) && ((x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2)) == 0))
3841 minPts[y1] = mjr::math::odr::min3(x1, x2, x3);
3842 maxPts[y1] = mjr::math::odr::max3(x1, x2, x3);
3846 triangleEdger(x1, y1, x3, y3, minPts,
true);
3847 triangleEdger(x2, y2, x3, y3, maxPts,
false);
3849 triangleEdger(x1, y1, x3, y3, minPts,
true);
3850 triangleEdger(x2, y2, x3, y3, maxPts,
false);
3852 triangleEdger(x1, y1, x3, y3, maxPts,
false);
3853 triangleEdger(x2, y2, x3, y3, minPts,
true);
3857 triangleEdger(x1, y1, x3, y3, minPts,
true);
3858 triangleEdger(x2, y2, x1, y1, maxPts,
false);
3860 triangleEdger(x1, y1, x3, y3, maxPts,
false);
3861 triangleEdger(x2, y2, x1, y1, minPts,
true);
3863 triangleEdger(x1, y1, x3, y3, minPts,
true);
3864 triangleEdger(x2, y2, x1, y1, maxPts,
false);
3867 double xOt = (x1*y3+x3*y2-x1*y2-x3*y1);
3868 double xOb = (y3-y1);
3870 triangleEdger(x1, y1, x3, y3, minPts,
true);
3871 triangleEdger(x2, y2, x1, y1, maxPts,
false);
3872 triangleEdger(x2, y2, x3, y3, maxPts,
false);
3874 triangleEdger(x1, y1, x3, y3, maxPts,
false);
3875 triangleEdger(x2, y2, x1, y1, minPts,
true);
3876 triangleEdger(x2, y2, x3, y3, minPts,
true);
3884 for(intCrdT y=y3; y<=y1; y++)
3885 drawLine(minPts[y], y, maxPts[y], y, c1);
3887 for(intCrdT y=y3; y<=y1; y++)
3888 for(intCrdT x=minPts[y]; x<=maxPts[y]; x++) {
3899 drawPointNC(x, y, colorT().wMean(w1/(w1+w2+w3), w2/(w1+w2+w3), w3/(w1+w2+w3), c1, c2, c3));
3905 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3906 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3909 drawPLCurve(numPoints, x, y, dfltColor);
3913 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3914 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3917 for(
int i=0; i<numPoints-1; i++)
3918 drawLine(real2intX(x[i]), real2intY(y[i]), real2intX(x[i+1]), real2intY(y[i+1]), color);
3922 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3923 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3926 drawPLCurve(numPoints, x, y, dfltColor);
3930 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3931 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3934 for(
int i=0; i<numPoints-1; i++)
3935 drawLine(x[i], y[i], x[i+1], y[i+1], color);
3939 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3940 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3943 for(
int i=0; i<numPoints-1; i++)
3944 drawLine(thePoints[i].x, thePoints[i].y, thePoints[i+1].x, thePoints[i+1].y, color);
3948 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3949 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3952 for(
int i=0; i<numPoints-1; i++)
3953 drawLine(thePoints[i].x, thePoints[i].y, thePoints[i+1].x, thePoints[i+1].y, color);
3957 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3958 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3961 drawPLCurve(numPoints, thePoints, dfltColor);
3965 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3966 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3969 drawPLCurve(numPoints, thePoints, dfltColor);
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)
3977 drawLine(x1, y1, x2, y2, color);
3978 drawLine(x2, y2, x3, y3, color);
3979 drawLine(x3, y3, x1, y1, color);
3983 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3984 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3989 int d = 1 - radiusX;
3991 int deltaSE = -2 * radiusX + 5;
3993 drawPoint( x+centerX, y+centerY, color);
3994 drawPoint( x+centerX,-y+centerY, color);
3995 drawPoint(-x+centerX, y+centerY, color);
3996 drawPoint(-x+centerX,-y+centerY, color);
3997 drawPoint( y+centerX, x+centerY, color);
3998 drawPoint( y+centerX,-x+centerY, color);
3999 drawPoint(-y+centerX, x+centerY, color);
4000 drawPoint(-y+centerX,-x+centerY, color);
4014 drawPoint( x+centerX, y+centerY, color);
4015 drawPoint( x+centerX,-y+centerY, color);
4016 drawPoint(-x+centerX, y+centerY, color);
4017 drawPoint(-x+centerX,-y+centerY, color);
4018 drawPoint( y+centerX, x+centerY, color);
4019 drawPoint( y+centerX,-x+centerY, color);
4020 drawPoint(-y+centerX, x+centerY, color);
4021 drawPoint(-y+centerX,-x+centerY, color);
4027 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4028 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4034 int d = 1 - radiusX;
4036 int deltaSE = -2 * radiusX + 5;
4042 drawLine( x+centerX, y+centerY, x+centerX, minXY+centerY, color);
4043 drawLine( -x+centerX, y+centerY, -x+centerX, minXY+centerY, color);
4044 drawLine( x+centerX, -y+centerY, x+centerX, -minXY+centerY, color);
4045 drawLine( -x+centerX, -y+centerY, -x+centerX, -minXY+centerY, color);
4046 drawLine( y+centerX, x+centerY, minXY+centerX, x+centerY, color);
4047 drawLine( y+centerX, -x+centerY, minXY+centerX, -x+centerY, color);
4048 drawLine( -y+centerX, x+centerY, -minXY+centerX, x+centerY, color);
4049 drawLine( -y+centerX, -x+centerY, -minXY+centerX, -x+centerY, color);
4068 drawLine( x+centerX, y+centerY, x+centerX, minXY+centerY, color);
4069 drawLine( -x+centerX, y+centerY, -x+centerX, minXY+centerY, color);
4070 drawLine( x+centerX, -y+centerY, x+centerX, -minXY+centerY, color);
4071 drawLine( -x+centerX, -y+centerY, -x+centerX, -minXY+centerY, color);
4072 drawLine( y+centerX, x+centerY, minXY+centerX, x+centerY, color);
4073 drawLine( y+centerX, -x+centerY, minXY+centerX, -x+centerY, color);
4074 drawLine( -y+centerX, x+centerY, -minXY+centerX, x+centerY, color);
4075 drawLine( -y+centerX, -x+centerY, -minXY+centerX, -x+centerY, color);
4080 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4081 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4088 if( (y1 < numPixY) && (x1 < numPixX) && (y2 >= 0) && (x2 >= 0) ) {
4089 int noTop, noBottom, noLeft, noRight;
4090 if((noTop=(y1 < 0)))
4092 if((noLeft=(x1 < 0)))
4094 if((noBottom=(y2 >= numPixY)))
4096 if((noRight=(x2 >= numPixX)))
4100 drawVertLineNC(y1, y2, x1, color);
4102 drawVertLineNC(y1, y2, x2, color);
4104 drawHorzLineNC(x1, x2, y1, color);
4106 drawHorzLineNC(x1, x2, y2, color);
4111 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4112 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4120 if( (y1 >= numPixY) || (x1 >= numPixX) || (y2 < 0) || (x2 < 0) )
4130 for(intCrdT y=y1;y<=y2;y++)
4131 drawHorzLineNC(x1, x2, y, color);
4135 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4136 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4139 if constexpr (enableDrawModes)
4141 case drawModeType::SET: getPxColorRefNC(x, y).copy(color);
break;
4142 case drawModeType::XOR: getPxColorRefNC(x, y).tfrmXor(color);
break;
4143 case drawModeType::ADDCLAMP: getPxColorRefNC(x, y).tfrmAddClamp(color);
break;
4144 case drawModeType::AND: getPxColorRefNC(x, y).tfrmAnd(color);
break;
4145 case drawModeType::OR: getPxColorRefNC(x, y).tfrmOr(color);
break;
4146 case drawModeType::DIFFCLAMP: getPxColorRefNC(x, y).tfrmDiffClamp(color);
break;
4147 case drawModeType::MULTCLAMP: getPxColorRefNC(x, y).tfrmMultClamp(color);
break;
4150 getPxColorRefNC(x, y).copy(color);
4154 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4155 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4159 intCrdT new_numPixX_p = xfactor*numPixX;
4160 intCrdT new_numPixY_p = xfactor*numPixY;
4161 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4162 for(intCrdT y=0, y1=0; y<numPixY; y++) {
4163 for(intCrdT x=0, x1=0; x<numPixX; x++) {
4164 for(
int i=0; i<xfactor; i++) {
4165 for(
int j=0; j<xfactor; j++) {
4166 new_pixels[new_numPixX_p * y1 + x1] = getPxColor(x, y);
4177 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
4182 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4183 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4186 if ((xfactor > 1) && (xfactor <= numPixX) && (xfactor <= numPixY)) {
4187 intCrdT new_numPixX_p = numPixX/xfactor;
4188 intCrdT new_numPixY_p = numPixY/xfactor;
4189 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4190 for(intCrdT y=0, y1=0; y<new_numPixY_p; y++, y1+=xfactor)
4191 for(intCrdT x=0, x1=0; x<new_numPixX_p; x++, x1+=xfactor)
4192 new_pixels[new_numPixX_p * y + x] = getPxColor(x1, y1);
4193 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
4198 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4199 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4202 if ((xfactor > 1) && (xfactor <= numPixX) && (xfactor <= numPixY)) {
4203 intCrdT new_numPixX_p = numPixX/xfactor;
4204 intCrdT new_numPixY_p = numPixY/xfactor;
4205 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4206 for(intCrdT y=0, y1=0; y<new_numPixY_p; y++, y1+=xfactor)
4207 for(intCrdT x=0, x1=0; x<new_numPixX_p; x++, x1+=xfactor) {
4208 std::vector<colorChanArithSDPType> sums(colorT::channelCount,
static_cast<colorChanArithSDPType>(0));
4209 for(
int j=0; j<xfactor; j++)
4210 for(
int i=0; i<xfactor; i++)
4211 for(
int c=0; c<colorT::channelCount; c++)
4212 sums[c] += getPxColor(x1+i, y1+j).getChan(c);
4214 for(
int c=0; c<colorT::channelCount; c++)
4215 aColor.setChan(c,
static_cast<colorChanType>(sums[c] / (xfactor*xfactor)));
4216 new_pixels[new_numPixX_p * y + x] = aColor;
4218 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
4223 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4224 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4227 if ((xfactor > 1) && (xfactor <= numPixX) && (xfactor <= numPixY)) {
4228 intCrdT new_numPixX_p = numPixX/xfactor;
4229 intCrdT new_numPixY_p = numPixY/xfactor;
4230 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4231 for(intCrdT y=0, y1=0; y<new_numPixY_p; y++, y1+=xfactor)
4232 for(intCrdT x=0, x1=0; x<new_numPixX_p; x++, x1+=xfactor) {
4233 colorT maxColor = getPxColor(xfactor*x, xfactor*y);
4234 for(
int yi=0; yi<xfactor; yi++)
4235 for(
int xi=0; xi<xfactor; xi++)
4236 maxColor.tfrmMaxI(getPxColor(xfactor*x+xi, xfactor*y+yi));
4237 new_pixels[new_numPixX_p * y + x] = maxColor;
4239 rePointPixels(new_pixels, new_numPixX_p, new_numPixY_p);
4244 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4245 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4248 for(
int yi=0, yis=-(kSize/2); yi<kSize; yi++, yis++)
4249 for(
int xi=0,xis=-(kSize/2); xi<kSize; xi++, xis++)
4250 kernel[kSize * yi + xi] = exp(-(xis*xis+yis*yis)/(2*sd*sd))/(sd*sd*2*std::numbers::pi);
4252 for(
int i=0; i<(kSize*kSize); i++)
4253 divisor += kernel[i];
4254 for(
int i=0; i<(kSize*kSize); i++)
4255 kernel[i] /= divisor;
4259 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4260 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4263 for(
int yi=0, yis=-(kSize/2); yi<kSize; yi++, yis++)
4264 for(
int xi=0,xis=-(kSize/2); xi<kSize; xi++, xis++)
4265 kernel[kSize * yi + xi] = 1.0/(kSize*kSize);
4269 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4270 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4273 colorT *new_pixels =
new colorT[numPixX * numPixY];
4275 if (mjr::math::fc::near_zero(divisor, 0.0001)) {
4277 for(
int i=0; i<(kWide*kTall); i++)
4278 divisor += kernel[i];
4281 double tmp[colorT::channelCount];
4282 for(intCrdT y=0; y<numPixY; y++) {
4283 for(intCrdT x=0; x<numPixX; x++) {
4285 for(
int chan=0; chan<colorT::channelCount; chan++)
4287 for(
int yi=0, yis=-(kTall/2); yi<kTall; yi++, yis++) {
4288 intCrdT icY = y + yis;
4289 for(
int xi=0,xis=-(kWide/2); xi<kWide; xi++, xis++) {
4290 intCrdT icX = x + xis;
4291 if (!(isCliped(icX, icY))) {
4292 for(
int chan=0; chan<colorT::channelCount; chan++)
4293 tmp[chan] +=
static_cast<double>(getPxColor(icX, icY).getChan(chan)) * kernel[kWide * yi + xi];
4297 for(
int chan=0; chan<colorT::channelCount; chan++)
4298 new_pixels[numPixX * y + x].setChan(chan,
static_cast<colorChanType>(tmp[chan] / divisor));
4301 rePointPixels(new_pixels, numPixX, numPixY);
4305 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4306 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4309 convolution(kernel, kSize, kSize, divisor);
4312 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4313 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4316 convolution(kernel, kSize, kSize, 1.0);
4320 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4321 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4327 if( (glyphNum < 0) || (glyphNum > 3934) )
4335 if(isIntAxOrientationNaturalX())
4336 x1 =
static_cast<intCrdT
>(magX * ((
mjr::hershey::chars[glyphNum]).components[2*i] -
'R'));
4338 x1 =
static_cast<intCrdT
>(magX * (
'R' - (
mjr::hershey::chars[glyphNum]).components[2*i]));
4340 if(isIntAxOrientationNaturalY())
4341 y1 =
static_cast<intCrdT
>(magY * (
'R' - (
mjr::hershey::chars[glyphNum]).components[2*i+1]));
4343 y1 =
static_cast<intCrdT
>(magY * ((
mjr::hershey::chars[glyphNum]).components[2*i+1] -
'R'));
4345 if(actionIsMoveTo) {
4349 drawLine(x1+x, y1+y, aColor);
4356 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4357 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4360 for(
auto &c : aString) {
4362 if((c>=32) && (c<=126))
4364 drawHersheyGlyph(glyphNum, x, y, cex, cex, aColor);
4365 x+=
static_cast<intCrdT
>(spc*cex);
4370 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4371 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4375 intCrdT x, intCrdT y,
4377 double cex, intCrdT spc) {
4378 drawFillRectangle(
static_cast<intCrdT
>(x-spc*cex),
4379 static_cast<intCrdT
>(y-spc*cex),
4380 static_cast<intCrdT
>(x+spc*cex*
static_cast<int>(aString.length())),
4381 static_cast<intCrdT
>(y+spc*cex),
4383 drawString(aString, aFont, x, y, stringColor, cex, spc);
4387 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4388 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4393 std::ifstream iStream(fileName, std::ios_base::binary);
4395 if (!(iStream.good()))
4398 iStream.getline(strBuf, 10,
'\n');
4399 if (!(iStream.good()))
4401 if (iStream.gcount() != 7)
4403 if(std::string(strBuf) != std::string(
"MJRRAW"))
4409 int fileBitPerChan = -1;
4410 bool fileIsSGN =
true, fileHasS =
false;
4411 bool fileIsInt =
true, fileHasT =
false;
4412 bool fileIsLTL =
true, fileHasI =
false;
4414 iStream.getline(strBuf, 100,
'\n');
4415 if (!(iStream.good()))
4417 if (iStream.gcount() != 93)
4420 std::string::size_type tagIdx;
4421 std::string::size_type prcIdx = 0;
4422 std::string strBufS(strBuf);
4423 std::string delChrs(
"abcdefghijklmnopqrstuvwxyz");
4424 int stoiErrorCount = 0;
4427 tagIdx = strBufS.find_first_of(delChrs, prcIdx);
4428 if (tagIdx == std::string::npos)
4433 switch(strBufS[tagIdx]) {
4434 case 'x' : fileWide = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4435 case 'y' : fileTall = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4436 case 'c' : fileChans = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4437 case 'b' : fileBitPerChan = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4438 case 's' : fileIsSGN = (strBufS[prcIdx] ==
'S'); fileHasS =
true;
break;
4439 case 't' : fileIsInt = (strBufS[prcIdx] ==
'I'); fileHasT =
true;
break;
4440 case 'i' : fileIsLTL = (strBufS[prcIdx] ==
'L'); fileHasI =
true;
break;
4448 int fileBytePerChan = fileBitPerChan / 8;
4459 if (stoiErrorCount > 0)
4468 if (fileBitPerChan < 0)
4476 if (fileWide > intCrdMax)
4478 if (fileTall > intCrdMax)
4481 resizeCanvas(fileWide, fileTall);
4483 if (fileWide != numPixX)
4485 if (fileTall != numPixY)
4492 fileIsSGN = ( !(fileIsInt));
4494 if ((colorT::chanIsInt && fileIsSGN))
4497 if ((colorT::chanIsInt && !fileIsInt) ||
4498 (colorT::chanIsFloat && fileIsInt))
4501 if(fileChans != colorT::channelCount)
4504 if(fileBitPerChan != colorT::bitsPerChan)
4508 fileIsLTL = (platformEndianness() == endianType::LITTLE);
4510 bool reverseBits = (( fileIsLTL && (platformEndianness() == endianType::BIG)) ||
4511 (!(fileIsLTL) && (platformEndianness() == endianType::LITTLE)));
4514 bool yNat = !(isIntAxOrientationNaturalY());
4515 bool xNat = isIntAxOrientationNaturalX();
4516 for((yNat?y=0:y=(numPixY-1)); (yNat?y<numPixY:y>=0); (yNat?y++:y--)) {
4517 for((xNat?x=0:x=(numPixX-1)); (xNat?x<numPixX:x>=0); (xNat?x++:x--)) {
4518 for(
int ci=0; ci<fileChans; ci++) {
4519 if constexpr (colorT::chanIsInt) {
4525 for(
int bi=0; bi<fileBytePerChan; bi++) {
4527 if (!(iStream.good()))
4529 if (iStream.gcount() != 1)
4538 getPxColorRefNC(x, y).setChan(ci,
static_cast<colorChanType>(pv));
4540 iStream.read(strBuf, fileBytePerChan);
4541 getPxColorRefNC(x, y).setChan(ci, *((
colorChanType*)strBuf));
4551 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4552 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4555#ifndef MRASTER_FOUND_TIFF
4556 std::cerr <<
"ERROR: libTIFF no supported: readTIFFfile can't read " << fileName << std::endl;
4560 uint32_t wTIFF, hTIFF;
4561 uint16_t pmTIFF, pcTIFF, sppTIFF, bpsTIFF, fmtTIFF;
4564 if( !(tif = TIFFOpen(fileName.c_str(),
"r")))
4567 if(TIFFIsTiled(tif))
4571 if( 1 != TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &wTIFF))
4573 if( 1 != TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &hTIFF))
4575 if( 1 != TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &sppTIFF))
4577 if( 1 != TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &pcTIFF))
4579 if( 1 != TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &pmTIFF))
4581 if( 1 != TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bpsTIFF))
4585 if( 1 != TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &fmtTIFF))
4588 if (pmTIFF == PHOTOMETRIC_PALETTE)
4611 resizeCanvas(wTIFF, hTIFF);
4613 uint32_t wRC = getNumPixX();
4615 if ((pcTIFF != PLANARCONFIG_CONTIG) && (pcTIFF != PLANARCONFIG_SEPARATE))
4621 uint32_t hRC = getNumPixY();
4626 uint16_t sppRC = colorT::channelCount;
4629 if(sppTIFF != sppRC)
4632 uint16_t bpsRC = colorT::bitsPerPixel / sppRC;
4634 if(bpsTIFF != bpsRC)
4638 if ((fmtTIFF != SAMPLEFORMAT_UINT) && (fmtTIFF != SAMPLEFORMAT_IEEEFP))
4641 if (( colorType::chanIsInt && (SAMPLEFORMAT_UINT != 1)) ||
4642 (!(colorType::chanIsInt) && (SAMPLEFORMAT_IEEEFP != 3)))
4645 bool yNat = !(isIntAxOrientationNaturalY());
4646 bool xNat = isIntAxOrientationNaturalX();
4647 tsize_t scanlinesize = TIFFScanlineSize(tif);
4648 tdata_t scanLineBuffer = _TIFFmalloc(scanlinesize);
4650 if(scanLineBuffer == NULL)
4653 if (pcTIFF == PLANARCONFIG_CONTIG) {
4654 for(uint32_t row=0; row<hTIFF; row++) {
4655 if( !(TIFFReadScanline(tif, scanLineBuffer, row)))
4657 char* p = (
char*)(scanLineBuffer);
4658 for(uint32_t col=0; col<wTIFF; col++) {
4659 int x = (xNat ? col : wTIFF-col-1);
4660 int y = (yNat ? row : hTIFF-row-1);
4661 for(uint16_t samp=0; samp<sppTIFF; samp++) {
4662 getPxColorRefNC(x, y).setChan(samp,
static_cast<colorChanType>(*p));
4663 p = p + (bpsTIFF/8);
4667 }
else if (pcTIFF == PLANARCONFIG_SEPARATE) {
4668 for(uint16_t samp=0; samp<sppTIFF; samp++) {
4669 for(uint32_t row=0; row<hTIFF; row++) {
4670 if( !(TIFFReadScanline(tif, scanLineBuffer, row, samp)))
4672 char* p = (
char*)(scanLineBuffer);
4673 for(uint32_t col=0; col<wTIFF; col++) {
4674 int x = (xNat ? col : wTIFF-col-1);
4675 int y = (yNat ? row : hTIFF-row-1);
4676 getPxColorRefNC(x, y).setChan(samp,
static_cast<colorChanType>(*p));
4677 p = p + (bpsTIFF/8);
4683 _TIFFfree(scanLineBuffer);
4690 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4691 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4694#ifndef MRASTER_FOUND_TIFF
4702 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4703 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4712 for(intCrdT y=0; y<numPixY; y++) {
4713 for(intCrdT x=0; x<numPixX; x++) {
4717 double xS = fv.
x / oScale + Xo;
4718 double yS = fv.
y / oScale + Yo;
4719 if (isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4722 newRamCanvas.
drawPointNC(x, y, getPxColorInterpolate(xS, yS, interpMethod));
4726 return newRamCanvas;
4730 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4731 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4740 for(intCrdT y=0; y<numPixY; y++) {
4741 for(intCrdT x=0; x<numPixX; x++) {
4744 double xS = (HAMatrix[0] * xT + HAMatrix[1] * yT + HAMatrix[2]) / oScale + Xo;
4745 double yS = (HAMatrix[3] * xT + HAMatrix[4] * yT + HAMatrix[5]) / oScale + Yo;
4746 if (isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4749 newRamCanvas.
drawPointNC(x, y, getPxColorInterpolate(xS, yS, interpMethod));
4753 return newRamCanvas;
4757 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4758 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4768 for(intCrdT y=0; y<numPixY; y++) {
4769 for(intCrdT x=0; x<numPixX; x++) {
4770 double xT = (x - Xo);
4771 double yT = (y - Yo);
4772 double rT = std::hypot(xT, yT) / rScale;
4774 double rS = RPoly[0];
4775 for (
unsigned int i=1; i<RPoly.size(); i++)
4776 rS = rS*rT + RPoly[i];
4777 double xS = xT * rS / oScale + Xo;
4778 double yS = yT * rS / oScale + Yo;
4779 if (isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4782 newRamCanvas.
drawPointNC(x, y, getPxColorInterpolate(xS, yS, interpMethod));
4786 return newRamCanvas;
4790 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4791 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4794 std::vector<double>
const& BiPolyY,
4801 for(intCrdT y=0; y<numPixY; y++) {
4802 for(intCrdT x=0; x<numPixX; x++) {
4805 double xS = mjr::math::bply::eval(BiPolyX, xT, yT) / oScale + Xo;
4806 double yS = mjr::math::bply::eval(BiPolyY, xT, yT) / oScale + Yo;
4807 if (isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4810 newRamCanvas.
drawPointNC(x, y, getPxColorInterpolate(xS, yS, interpMethod));
4814 return newRamCanvas;
4819#define MJR_INCLUDE_ramCanvasTpl
User include file for color types.
Internal include file for ramCanvas types.
Template Class used to house colors for ramCanvas objects.
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)
Colorize a ramCanvasTpl with integer channels using a color scheme.
colorType getPxColorNC(typename inRamCanvasT::coordIntType x, typename inRamCanvasT::coordIntType y)
rcConverterColorScheme(inRamCanvasT &aRC)
This class is an incomplete rcConverter (no getPxColorNC method) that provides a nice base for homoge...
rcConverterHomoBase(inRamCanvasT &aRC)
bool isIntAxOrientationNaturalX()
inRamCanvasT::coordIntType getNumPixX()
inRamCanvasT & attachedRC
bool isIntAxOrientationNaturalY()
inRamCanvasT::coordIntType getNumPixY()
colorType getPxColorNC(typename inRamCanvasT::coordIntType x, typename inRamCanvasT::coordIntType y)
inRamCanvasT::colorType colorType
rcConverterIdentity(inRamCanvasT &aRC)
Convert a ramCanvasTpl to a greyscale image using colorT::intensity().
colorTpl< outColorChanT, 1 > colorType
rcConverterMonoIntensity(inRamCanvasT &aRC)
colorType getPxColorNC(typename inRamCanvasT::coordIntType x, typename inRamCanvasT::coordIntType y)
colorType getPxColorNC(typename inRamCanvasT::coordIntType x, typename inRamCanvasT::coordIntType y)
inRamCanvasT::colorType::colConRGBAbyte colorType
rcConverterRGBAbyte(inRamCanvasT &aRC)
rcConverterRGBAdbl(inRamCanvasT &aRC)
colorType getPxColorNC(typename inRamCanvasT::coordIntType x, typename inRamCanvasT::coordIntType y)
inRamCanvasT::colorType::colConRGBAdbl colorType
colorType getPxColorNC(typename inRamCanvasT::coordIntType x, typename inRamCanvasT::coordIntType y)
inRamCanvasT::colorType::colConRGBbyte colorType
rcConverterRGBbyte(inRamCanvasT &aRC)
rcConverterRGBdbl(inRamCanvasT &aRC)
colorType getPxColorNC(typename inRamCanvasT::coordIntType x, typename inRamCanvasT::coordIntType y)
inRamCanvasT::colorType::colConRGBdbl colorType
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)
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
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)
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.
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)