34#ifndef MJR_INCLUDE_ramCanvasTpl
42#include "MRMathIVL.hpp"
43#include "MRMathFC.hpp"
44#include "MRMathODR.hpp"
45#include "MRMathBPLY.hpp"
48#ifdef MRASTER_FOUND_TIFF
144 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
145 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
239 const static intCrdT
intCrdMax = (1ul << ((
sizeof(intCrdT)*CHAR_BIT-1)/2)) - 3;
330 void drawFillTriangleUtl(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorT c1, colorT c2, colorT c3,
bool solid);
382 void rePointPixels(colorT *new_pixels, intCrdT new_numPixX, intCrdT new_numPixY);
390 void triangleEdger(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT* pts,
bool findMin);
423 int exportRasterData(
void* &rasterData, intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2,
int redChan,
int greenChan,
int blueChan,
int alphaChan);
444 ramCanvasTpl(intCrdT numPixX_p, intCrdT numPixY_p, fltCrdT minRealX_p=-1, fltCrdT maxRealX_p=1, fltCrdT minRealY_p=-1, fltCrdT maxRealY_p=1);
521 for(intCrdT y=0; y<theCanvas.
getNumPixY(); y++)
522 for(intCrdT x=0; x<theCanvas.
getNumPixX(); x++)
545 void expandCanvas(intCrdT new_numPixX_p, intCrdT new_numPixY_p, intCrdT x1 = 0, intCrdT y1 = 0,
colorArgType color = colorT(colorT::minChanVal));
552 void cropCanvas(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2);
564 void newRealCoords(fltCrdT minRealX_p, fltCrdT maxRealX_p, fltCrdT minRealY_p, fltCrdT maxRealY_p);
591 for(intCrdT y=0; y<
numPixY; y++)
592 for(intCrdT x=0; x<
numPixX; x++)
602 for(intCrdT y=0; y<
numPixY; y++)
603 for(intCrdT x=0; x<
numPixX; x++)
710 std::vector<double>
const& BiPolyY,
769 void convolution(
double *kernel,
int kWide,
int kTall,
double divisor);
810 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double,
double),
double,
double,
double);
811 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double,
double,
double),
double,
double,
double,
double);
812 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double,
double,
double,
double),
double,
double,
double,
double,
double);
813 void applyHomoPixTfrm(colorT& (colorT::*HPT)(
double,
double,
double,
double,
double,
double),
double,
double,
double,
double,
double,
double);
820 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT, colorT), colorT, colorT, colorT);
821 void applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT, colorT, colorT), colorT, colorT, colorT, colorT);
862 intCrdT trgX = 0, intCrdT trgY = 0,
863 intCrdT wide = -1, intCrdT tall = -1,
864 intCrdT srcX = 0, intCrdT srcY = 0);
987 template <
int chanNum = 0>
988 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
994 template <
int chanNum = 0>
995 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1002 template <
int chanNum = 0>
1003 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1006 template <
int chanNum = 0>
1007 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1090 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); }
1091 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); }
1092 inline void drawTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3) {
drawTriangle(x1, y1, x2, y2, x3, y3,
dfltColor); }
1118 thePoints[1].x, thePoints[1].y,
1119 thePoints[2].x, thePoints[2].y,
dfltColor); }
1128 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); }
1129 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); }
1130 inline void drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3) {
drawFillTriangle(x1, y1, x2, y2, x3, y3,
dfltColor); }
1292 void drawHersheyGlyph(
int glyphNum, fltCrdT x, fltCrdT y,
double magX,
double magY,
colorArgType aColor) {
drawHersheyGlyph(glyphNum,
real2intX(x),
real2intY(y), magX, magY, aColor); }
1413 template <
class rcConT>
int writeTIFFfile(std::string fileName, rcConT pxFilter,
bool markAlpha =
true);
1528 template <
class rcConT>
int writeRAWfile(std::string fileName, rcConT pxFilter);
1792 template <
int chanNum>
1793 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1797 template <
int chanNum>
1798 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1802 template <
int chanNum>
1803 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1807 template <
int chanNum>
1808 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1812 template <
int chanNum>
1813 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1817 template <
int chanNum>
1818 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1822 template <
int chanNum>
1823 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1827 template <
int chanNum>
1828 requires((chanNum >= 0) && (chanNum < colorT::channelCount))
1950 intCrdT retCount = 0;
1956 for(intCrdT y=y1;y<=y2;y++)
1957 for(intCrdT x=x1;x<=x2;x++)
1973 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
1974 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
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)
1999 for(intCrdT y=0; y<
numPixY; y++)
2000 for(intCrdT x=0; x<
numPixX; x++)
2006 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2007 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2022 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2023 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2026 if (
this != &theCanvas) {
2042 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2043 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2046 newRealCoords(minRealX_p, maxRealX_p, minRealY_p, maxRealY_p);
2056 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2057 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2066 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2067 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2071 throw std::invalid_argument(
"newIntCoordsNC: numPixX_p argument too large.");
2073 throw std::invalid_argument(
"newIntCoordsNC: numPixY_p argument too large.");
2075 numPix = numPixX_p * numPixY_p;;
2082 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2083 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2086 if(minRealX_p > maxRealX_p) {
2087 throw std::invalid_argument(
"newRealCoords: minRealX_p > maxRealX_p.");
2088 }
else if (minRealY_p > maxRealY_p) {
2089 throw std::invalid_argument(
"newRealCoords: minRealY_p > maxRealY_p.");
2100 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2101 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2111 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2112 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2115 for(intCrdT y=0; y<
numPixY; y++)
2116 for(intCrdT x=0; x<
numPixX; x++)
2121 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2122 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2125 for(intCrdT y=0; y<
numPixY; y++)
2126 for(intCrdT x=0; x<
numPixX; x++)
2131 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2132 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2150 for(intCrdT y=0; y<
numPixY; y++)
2151 for(intCrdT x=0; x<
numPixX; x++)
2159 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2160 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2163 for(intCrdT y=0; y<
numPixY; y++)
2164 for(intCrdT x=0; x<
numPixX; x++)
2169 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2170 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2177 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2178 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2181 for(intCrdT y=0; y<
numPixY; y++)
2182 for(intCrdT x=0; x<
numPixX; x++)
2187 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2188 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2193 for(intCrdT y=0;y<
numPixY;y++) {
2194 for(intCrdT x=0;x<
numPixX;x++) {
2205 double c = 1.0 *
static_cast<double>(colorT::maxChanVal-colorT::minChanVal) /
static_cast<double>(cmax-cmin);
2206 double b =
static_cast<double>(colorT::maxChanVal) - 1.0 * c *
static_cast<double>(cmax);
2212 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2213 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2216 colorT cmin; cmin.setChans(cmin.maxChanVal);
2217 colorT cmax; cmax.setChans(cmin.minChanVal);
2218 for(intCrdT y=0;y<
numPixY;y++) {
2219 for(intCrdT x=0;x<
numPixX;x++) {
2221 cmin.tfrmMin(daColor);
2222 cmax.tfrmMax(daColor);
2227 if(absCompMax-absCompMin > 0) {
2228 double rc = 1.0*
static_cast<double>(cmin.maxChanVal-cmin.minChanVal)/
static_cast<double>(cmax.getRed()-cmin.getRed());
2229 double rb = cmin.maxChanVal - 1.0*rc*cmax.getRed();
2230 double gc = 1.0*
static_cast<double>(cmin.maxChanVal-cmin.minChanVal)/
static_cast<double>(cmax.getGreen()-cmin.getGreen());
2231 double gb = cmin.maxChanVal - 1.0*gc*cmax.getGreen();
2232 double bc = 1.0*
static_cast<double>(cmin.maxChanVal-cmin.minChanVal)/
static_cast<double>(cmax.getBlue()-cmin.getBlue());
2233 double bb = cmin.maxChanVal - 1.0*bc*cmax.getBlue();
2234 applyHomoPixTfrm(&colorT::tfrmLinearGreyLevelScaleRGB, rc, rb, gc, gb, bc, bb);
2239 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2240 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2243 for(intCrdT y=0; y<
numPixY; y++)
2244 for(intCrdT x=0; x<
numPixX; x++)
2249 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2250 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2253 for(intCrdT y=0; y<
numPixY; y++)
2254 for(intCrdT x=0; x<
numPixX; x++)
2259 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2260 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2263 for(intCrdT y=0; y<
numPixY; y++)
2264 for(intCrdT x=0; x<
numPixX; x++)
2269 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2270 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2273 for(intCrdT y=0; y<
numPixY; y++)
2274 for(intCrdT x=0; x<
numPixX; x++)
2279 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2280 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2283 for(intCrdT y=0; y<
numPixY; y++)
2284 for(intCrdT x=0; x<
numPixX; x++)
2289 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2290 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2292 ramCanvasTpl<colorT, intCrdT, fltCrdT, enableDrawModes>::applyHomoPixTfrm(colorT& (colorT::*HPT)(colorT, colorT, colorT, colorT), colorT arg1, colorT arg2, colorT arg3, colorT arg4) {
2293 for(intCrdT y=0; y<
numPixY; y++)
2294 for(intCrdT x=0; x<
numPixX; x++)
2299 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2300 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2303 for(intCrdT y=0; y<
numPixY; y++)
2304 for(intCrdT x=0; x<
numPixX; x++)
2309 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2310 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2313 for(intCrdT y=0; y<
numPixY; y++)
2314 for(intCrdT x=0; x<
numPixX; x++)
2319 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2320 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2323 for(intCrdT y=0; y<
numPixY; y++)
2324 for(intCrdT x=0; x<
numPixX; x++)
2329 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2330 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2332 ramCanvasTpl<colorT, intCrdT, fltCrdT, enableDrawModes>::applyHomoPixTfrm(colorT& (colorT::*HPT)(
int,
int,
int,
int),
int arg1,
int arg2,
int arg3,
int arg4) {
2333 for(intCrdT y=0; y<
numPixY; y++)
2334 for(intCrdT x=0; x<
numPixX; x++)
2339 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2340 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2343 for(intCrdT y=0; y<
numPixY; y++)
2344 for(intCrdT x=0; x<
numPixX; x++)
2349 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2350 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2353 for(intCrdT y=0; y<
numPixY; y++)
2354 for(intCrdT x=0; x<
numPixX; x++)
2359 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2360 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2363 for(intCrdT y=0; y<
numPixY; y++)
2364 for(intCrdT x=0; x<
numPixX; x++)
2369 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2370 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2373 double arg1,
double arg2,
double arg3,
double arg4) {
2374 for(intCrdT y=0; y<
numPixY; y++)
2375 for(intCrdT x=0; x<
numPixX; x++)
2380 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2381 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2384 double arg1,
double arg2,
double arg3,
double arg4,
double arg5) {
2385 for(intCrdT y=0; y<
numPixY; y++)
2386 for(intCrdT x=0; x<
numPixX; x++)
2391 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2392 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2394 double arg1,
double arg2,
double arg3,
double arg4,
double arg5,
double arg6) {
2395 for(intCrdT y=0; y<
numPixY; y++)
2396 for(intCrdT x=0; x<
numPixX; x++)
2401 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2402 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2405 intCrdT trgX, intCrdT trgY,
2406 intCrdT wide, intCrdT tall,
2407 intCrdT srcX, intCrdT srcY) {
2432 intCrdT xMax = trgX+wide;
2433 intCrdT yMax = trgY+tall;
2434 for(intCrdT y=trgY, ys=srcY; y<yMax; y++, ys++)
2435 for(intCrdT x=trgX, xs=srcX; x<xMax; x++, xs++)
2440 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2441 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2447 if( (y1 < 0) || (y1 >=
numPixY) )
2456 }
else if(x1 == x2) {
2457 if( (x1 < 0) || (x1 >=
numPixX) )
2493 for(x=x1,y=y1;x<=x2;y++,x++)
2495 }
else if(dx == -dy) {
2503 y2 = y2 + (x2 - (
numPixX - 1));
2511 x1 = x1 + (y1 - (
numPixY - 1));
2514 for(x=x1,y=y1;x<=x2;y--,x++)
2524 y1 = (int)(1.0*y1-x1*dy/dx);
2528 x1 = (int)(1.0*x1-y1*dx/dy);
2532 y2 = (int)((1.0*dy*(
numPixX-1)+y1*dx-x1*dy)/dx);
2536 x2 = (int)(((
numPixY-1)*dx-y2*dx+x2*dy)/dy);
2573 y1 = (int)(1.0*y1-x1*dy/dx);
2577 x2 = (int)(1.0*x2-y2*dx/dy);
2581 y2 = (int)((1.0*dy*(
numPixX-1)+y2*dx-x2*dy)/dx);
2585 x1 = (int)(((
numPixY-1)*dx-y1*dx+x1*dy)/dy);
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)
2636 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2637 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2643 if(new_pixels != NULL)
2652 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2653 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2656 if((numPixX_p<=0) || (numPixY_p<=0)) {
2660 colorT *new_pixels =
new colorT[numPixX_p * numPixY_p];
2669 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2670 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2677 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2678 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2683 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2686 for(intCrdT y=0;y<new_numPixY_p;y++)
2687 for(intCrdT x=0;x<new_numPixX_p;x++)
2688 new_pixels[new_numPixX_p * (y) + (x)] = color;
2690 intCrdT yMax = std::min(
numPixY+y1, new_numPixY_p);
2691 intCrdT xMax = std::min(
numPixX+x1, new_numPixX_p);
2694 if ((x1 < new_numPixX_p) && (y1 < new_numPixY_p))
2695 for(intCrdT y=y1;y<yMax;y++)
2696 for(intCrdT x=x1;x<xMax;x++)
2697 new_pixels[new_numPixX_p * (y) + (x)] =
getPxColor(x-x1, y-y1);
2704 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2705 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2713 intCrdT xp, yp, x, y;
2714 intCrdT new_numPixX_p = x2-x1+1;
2715 intCrdT new_numPixY_p = y2-y1+1;
2716 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2719 for(y=y1,yp=0;y<=y2;y++,yp++)
2720 for(x=x1,xp=0;x<=x2;x++,xp++)
2721 new_pixels[new_numPixX_p * yp + xp] =
getPxColor(x, y);
2728 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2729 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2732 for(intCrdT y=0; y<
numPixY/2; y++)
2733 for(intCrdT x=0; x<
numPixX; x++) {
2741 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2742 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2745 for(intCrdT x=0; x<
numPixX/2; x++)
2746 for(intCrdT y=0; y<
numPixY; y++) {
2754 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2755 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2758 intCrdT new_numPixX_p =
numPixY;
2759 intCrdT new_numPixY_p =
numPixX;
2760 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2761 for(intCrdT y=0; y<
numPixY; y++)
2762 for(intCrdT x=0; x<
numPixX; x++)
2763 new_pixels[new_numPixX_p * (x) + (y)] =
getPxColor(x, y);
2768 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2769 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2772 intCrdT new_numPixX_p =
numPixY;
2773 intCrdT new_numPixY_p =
numPixX;
2774 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2775 for(intCrdT y=0; y<
numPixY; y++)
2776 for(intCrdT x=0; x<
numPixX; x++)
2782 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2783 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2786 intCrdT new_numPixX_p =
numPixY;
2787 intCrdT new_numPixY_p =
numPixX;
2788 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2789 for(intCrdT y=0; y<
numPixY; y++)
2790 for(intCrdT x=0; x<
numPixX; x++)
2796 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2797 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2800 intCrdT new_numPixX_p =
numPixX;
2801 intCrdT new_numPixY_p =
numPixY;
2802 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
2803 for(intCrdT y=0; y<
numPixY; y++)
2804 for(intCrdT x=0; x<
numPixX; x++)
2810 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2811 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2814 unsigned int endiannessProbe = 1;
2815 if(((
char *)&endiannessProbe)[0]) {
2823 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2824 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2831 if (numBytes == 1) {
2832 uint8_t tmp = (data & 0xff);
2833 oStream.write((
const char *)&tmp, 1);
2838 for(
int curByte=0; curByte<numBytes; curByte++) {
2839 uint8_t tmp = ((data >> (8*curByte)) & 0xff);
2840 oStream.write((
const char *)&tmp, 1);
2843 for(
int curByte=(numBytes-1); curByte>=0; curByte--) {
2844 uint8_t tmp = ((data >> (8*curByte)) & 0xff);
2845 oStream.write((
const char *)&tmp, 1);
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++) {
2862 colorT aColor = cFun(xf, yf);
2869 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2870 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2873 for(intCrdT yi=0;yi<
numPixY;yi++) {
2874 for(intCrdT xi=0;xi<
numPixX;xi++) {
2876 colorT aColor = cFun(xyPt);
2883 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2884 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2887 for(intCrdT yi=0;yi<
numPixY;yi++) {
2888 for(intCrdT xi=0;xi<
numPixX;xi++) {
2889 colorT aColor = cFun(xi, yi);
2896 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2897 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2900 for(intCrdT yi=0;yi<
numPixY;yi++) {
2901 for(intCrdT xi=0;xi<
numPixX;xi++) {
2903 colorT aColor = cFun(xyPt);
2910 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2911 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2915 std::ofstream outStream;
2916 outStream.open(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
2917 if (outStream.is_open())
2918 outStream.imbue(std::locale::classic());
2951 for((yNat?y=0:y=(
numPixY-1)); (yNat?y<numPixY:y>=0); (yNat?y++:y--)) {
2952 for((xNat?x=0:x=(
numPixX-1)); (xNat?x<numPixX:x>=0); (xNat?x++:x--)) {
2963 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2964 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2972 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
2973 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
2974 template <class rcConT>
2978 std::ofstream outStream;
2979 outStream.open(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
2980 if (outStream.is_open())
2981 outStream.imbue(std::locale::classic());
2985 outStream <<
"MJRRAW\n";
2986 outStream << std::setw(19) << std::setfill(
'0') << pxFilter.getNumPixX() <<
"x";
2987 outStream << std::setw(19) << std::setfill(
'0') << pxFilter.getNumPixY() <<
"y";
2988 outStream << std::setw(27) << std::setfill(
'0') << rcConT::colorType::channelCount <<
"c";
2989 outStream << std::setw(11) << std::setfill(
'0') << rcConT::colorType::bitsPerChan <<
"b";
2990 outStream << (rcConT::colorType::chanIsUnsigned ?
"UNS" :
"SGN") <<
"s";
2991 outStream << (rcConT::colorType::chanIsInt ?
"INT" :
"FLT") <<
"t";
2998 bool yNat = !(pxFilter.isIntAxOrientationNaturalY());
2999 bool xNat = pxFilter.isIntAxOrientationNaturalX();
3000 for((yNat?y=0:y=(pxFilter.getNumPixY()-1)); (yNat?y<pxFilter.getNumPixY():y>=0); (yNat?y++:y--)) {
3001 for((xNat?x=0:x=(pxFilter.getNumPixX()-1)); (xNat?x<pxFilter.getNumPixX():x>=0); (xNat?x++:x--)) {
3002 typename rcConT::colorType aColor = pxFilter.getPxColorNC(x, y);
3003 for(
int c=0; c<aColor.channelCount; c++) {
3004 typename rcConT::colorType::channelType aChanValue = aColor.getChan(c);
3005 outStream.write((
const char *)&aChanValue,
sizeof(
colorChanType));
3013 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3014 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3022 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3023 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3024 template <class rcConT>
3028 if(rcConT::colorType::bitsPerChan < 8)
3030 if(rcConT::colorType::bitsPerChan > 0xffff)
3032 if(rcConT::colorType::channelCount < 1)
3034 if(rcConT::colorType::channelCount > 0xffff)
3036 if(pxFilter.getNumPixX() < 1)
3038 if(pxFilter.getNumPixX() > 0x7fffffff)
3040 if(pxFilter.getNumPixY() < 1)
3042 if(pxFilter.getNumPixY() > 0x7fffffff)
3044 unsigned long bytesPerRow = pxFilter.getNumPixX() * rcConT::colorType::bitsPerChan / 8ul * rcConT::colorType::channelCount;
3045 if(bytesPerRow > 0xffffffff)
3047 if(bytesPerRow * pxFilter.getNumPixY() > 0xfffffffff)
3051 const uint16_t tcTIFF_BIGENDIAN = 0x4d4d;
3052 const uint16_t tcTIFF_LITTLEENDIAN = 0x4949;
3053 const uint16_t tcPHOTOMETRIC_MINISBLACK = 1;
3054 const uint16_t tcPHOTOMETRIC_RGB = 2;
3055 const uint16_t tcORIENTATION_TOPLEFT = 1;
3056 const uint16_t tcPLANARCONFIG_CONTIG = 1;
3057 const uint16_t tcRESUNIT_NONE = 1;
3058 const uint16_t tcSAMPLEFORMAT_UINT = 1;
3059 const uint16_t tcSAMPLEFORMAT_IEEEFP = 3;
3080 uint16_t endianNum = (fe ==
endianType::LITTLE ? tcTIFF_LITTLEENDIAN : tcTIFF_BIGENDIAN);
3081 uint32_t tifWidth = (uint32_t)pxFilter.getNumPixX();
3082 uint32_t tifLength = (uint32_t)pxFilter.getNumPixY();
3083 uint32_t tifSPP = (uint32_t)rcConT::colorType::channelCount;
3084 uint16_t tifBPS = (uint16_t)(rcConT::colorType::bitsPerChan);
3085 uint32_t bytePerSmp = tifBPS / 8;
3086 uint32_t tifSBC = tifLength * tifWidth * bytePerSmp * tifSPP;
3087 bool haveRGB = tifSPP>=3;
3088 uint16_t numImgSmp = (haveRGB ? 3 : 1);
3089 uint16_t tifPMI = (haveRGB ? tcPHOTOMETRIC_RGB : tcPHOTOMETRIC_MINISBLACK);
3090 uint16_t tifPC = tcPLANARCONFIG_CONTIG;
3091 uint16_t tifOri = tcORIENTATION_TOPLEFT;
3092 uint16_t tifResU = tcRESUNIT_NONE;
3093 bool haveXS = !((tifSPP==1) || (tifSPP==3));
3094 bool haveManyXS = tifSPP>4;
3095 uint16_t numTags = 1+14 + (haveXS ? 1 : 0);
3096 bool haveManyBPS = tifSPP>1;
3097 uint32_t numXS = tifSPP - numImgSmp;
3098 uint32_t xResOff = 14 + 12 * numTags;
3099 uint32_t yResOff = xResOff + 8;
3100 uint32_t bpsOff = yResOff + 8;
3101 uint32_t xsOff = bpsOff + (haveManyBPS ? 2 * tifSPP : 0);
3102 uint32_t imgOff = xsOff + (haveManyXS ? 2 * numXS : 0);
3103 uint16_t sampFmt = (rcConT::colorType::chanIsInt ? tcSAMPLEFORMAT_UINT : tcSAMPLEFORMAT_IEEEFP);
3105 std::ofstream outStream;
3106 outStream.open(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
3107 if (outStream.is_open())
3108 outStream.imbue(std::locale::classic());
3167 for(
unsigned int i=0; i<tifSPP; i++)
3171 for(
unsigned int i=0; i<numXS; i++)
3175 bool yNat = !(pxFilter.isIntAxOrientationNaturalY());
3176 bool xNat = pxFilter.isIntAxOrientationNaturalX();
3177 for((yNat?y=0:y=(pxFilter.getNumPixY()-1)); (yNat?y<pxFilter.getNumPixY():y>=0); (yNat?y++:y--)) {
3178 for((xNat?x=0:x=(pxFilter.getNumPixX()-1)); (xNat?x<pxFilter.getNumPixX():x>=0); (xNat?x++:x--)) {
3179 typename rcConT::colorType aColor = pxFilter.getPxColorNC(x, y);
3180 for(
int c=0; c<aColor.channelCount; c++) {
3181 typename rcConT::colorType::channelType aChanValue = aColor.getChan(c);
3182 if (rcConT::colorType::chanIsInt)
3185 outStream.write((
const char *)&aChanValue, bytePerSmp);
3194 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3195 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3198 intCrdT x1, intCrdT y1,
3199 intCrdT x2, intCrdT y2,
3200 int redChan,
int greenChan,
int blueChan,
int alphaChan) {
3206 if(x1 < 0)
return 1;
3208 if(y1 < 0)
return 1;
3210 if(x2 < x1)
return 2;
3211 if(y2 < y1)
return 3;
3213 int bytesPerPix = (redChan<0?0:1) + (greenChan<0?0:1) + (blueChan<0?0:1) + (alphaChan<0?0:1);
3214 if(bytesPerPix < 1)
return 4;
3217 rasterData = (uint8_t *)
new uint8_t[(y2-y1+1)*(x2-x1+1)*bytesPerPix];
3219 if(rasterData == 0)
return 5;
3221 uint8_t *curPixComp = (uint8_t *)rasterData;
3222 for(intCrdT y=y1; y<=y2; y++) {
3223 for(intCrdT x=x1; x<=x2; x++) {
3225 if(redChan >= 0) curPixComp[redChan] = aColor.getChan_byte(aColor.bestRedChan());
3226 if(greenChan >= 0) curPixComp[greenChan] = aColor.getChan_byte(aColor.bestGreenChan());
3227 if(blueChan >= 0) curPixComp[blueChan] = aColor.getChan_byte(aColor.bestBlueChan());
3228 if(alphaChan >= 0) curPixComp[alphaChan] = aColor.getChan_byte(aColor.bestAlphaChan());
3229 curPixComp += bytesPerPix;
3237 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3238 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3242 return static_cast<intCrdT
>((
static_cast<fltCrdT
>(x) -
minRealX) /
pixWidX);
3244 return static_cast<intCrdT
>((
maxRealX -
static_cast<fltCrdT
>(x)) /
pixWidX);
3248 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3249 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3253 return static_cast<intCrdT
>((
static_cast<fltCrdT
>(y) -
minRealY) /
pixWidY);
3255 return static_cast<intCrdT
>((
maxRealY -
static_cast<fltCrdT
>(y)) /
pixWidY);
3259 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3260 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3270 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3271 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3281 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3282 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3286 for(intCrdT y=0; y<
numPixY; y++)
3287 for(intCrdT x=0; x<
numPixX; x++)
3292 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3293 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3299 return colorT().setToBlack();
3303 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3304 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3307 switch (interpMethod) {
3313 default :
return colorT(
"green");
3318 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3319 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3322 double x1 = std::floor(x);
3323 double y1 = std::floor(y);
3324 double x2 = std::ceil(x);
3325 double y2 = std::ceil(y);
3327 intCrdT x1i =
static_cast<intCrdT
>(x1);
3328 intCrdT y1i =
static_cast<intCrdT
>(y1);
3329 intCrdT x2i =
static_cast<intCrdT
>(x2);
3330 intCrdT y2i =
static_cast<intCrdT
>(y2);
3334 if ((x1i >= 0) && (y1i >= 0) && (x2i <
numPixX) && (y2i <
numPixY)) {
3335 double eps = 0.00001;
3336 double xD21 = x2 - x1;
3337 double yD21 = y2 - y1;
3339 if (mjr::math::fc::not_near_zero(xD21, eps))
3340 wH = (x - x1) / xD21;
3342 if (mjr::math::fc::not_near_zero(yD21, eps))
3343 wV = (y - y1) / yD21;
3349 cF.linearInterpolate(wV, c1, c2);
3357 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3358 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3361 return getPxColor(
static_cast<intCrdT
>(std::trunc(x)),
static_cast<intCrdT
>(std::trunc(y)));
3365 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3366 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3369 return getPxColor(
static_cast<intCrdT
>(std::round(x)),
static_cast<intCrdT
>(std::round(y)));
3373 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3374 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3377 intCrdT xi =
static_cast<intCrdT
>(std::round(x));
3378 intCrdT yi =
static_cast<intCrdT
>(std::round(y));
3380 for(
int chan=0; chan<colorT::channelCount; chan++) {
3382 for(intCrdT ydi=-1; ydi<=1; ydi++) {
3383 intCrdT icY = yi + ydi;
3384 for(intCrdT xdi=-1; xdi<=1; xdi++) {
3385 intCrdT icX = xi + xdi;
3387 newChanValue +=
getPxColor(icX, icY).getChan(chan);
3391 newColor.setChan(chan,
static_cast<colorChanType>(newChanValue / 9));
3397 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3398 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3401 double x1 = std::floor(x);
3402 double y1 = std::floor(y);
3403 double x2 = std::ceil(x);
3404 double y2 = std::ceil(y);
3406 intCrdT x1i =
static_cast<intCrdT
>(x1);
3407 intCrdT y1i =
static_cast<intCrdT
>(y1);
3408 intCrdT x2i =
static_cast<intCrdT
>(x2);
3409 intCrdT y2i =
static_cast<intCrdT
>(y2);
3411 if ((x1i >= 0) && (y1i >= 0) && (x2i <
numPixX) && (y2i <
numPixY)) {
3423 return colorT().setToBlack();
3618 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3619 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3627 for(y=y1; y<=y2; y++)
3638 for(x=x1,y=y1;x<=x2;y++,x++)
3640 }
else if(dx == -dy) {
3641 for(x=x1,y=y1;x<=x2;y--,x++)
3751 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3752 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3759 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3760 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3763 intCrdT x2, intCrdT y2,
3764 intCrdT x3, intCrdT y3,
3770 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3771 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3774 intCrdT x2, intCrdT y2,
3775 intCrdT x3, intCrdT y3,
3776 colorT c1, colorT c2, colorT c3,
bool solid) {
3777 static intCrdT *minPts, *maxPts;
3778 static intCrdT numPts;
3785 if(minPts == NULL) {
3786 minPts =
new intCrdT[
numPixY];
3787 maxPts =
new intCrdT[
numPixY];
3793 minPts =
new intCrdT[
numPixY];
3794 maxPts =
new intCrdT[
numPixY];
3800 if (!(solid) && ((x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2)) == 0))
3870 minPts[y1] = mjr::math::odr::min3(x1, x2, x3);
3871 maxPts[y1] = mjr::math::odr::max3(x1, x2, x3);
3896 double xOt = (x1*y3+x3*y2-x1*y2-x3*y1);
3897 double xOb = (y3-y1);
3913 for(intCrdT y=y3; y<=y1; y++)
3914 drawLine(minPts[y], y, maxPts[y], y, c1);
3916 for(intCrdT y=y3; y<=y1; y++)
3917 for(intCrdT x=minPts[y]; x<=maxPts[y]; x++) {
3928 drawPointNC(x, y, colorT().wMean(w1/(w1+w2+w3), w2/(w1+w2+w3), w3/(w1+w2+w3), c1, c2, c3));
3934 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3935 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3942 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3943 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3946 for(
int i=0; i<numPoints-1; i++)
3951 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3952 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3959 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3960 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3963 for(
int i=0; i<numPoints-1; i++)
3964 drawLine(x[i], y[i], x[i+1], y[i+1], color);
3968 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3969 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3972 for(
int i=0; i<numPoints-1; i++)
3973 drawLine(thePoints[i].x, thePoints[i].y, thePoints[i+1].x, thePoints[i+1].y, color);
3977 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3978 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3981 for(
int i=0; i<numPoints-1; i++)
3982 drawLine(thePoints[i].x, thePoints[i].y, thePoints[i+1].x, thePoints[i+1].y, color);
3986 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3987 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
3994 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
3995 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4002 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4003 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4012 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4013 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4018 int d = 1 - radiusX;
4020 int deltaSE = -2 * radiusX + 5;
4022 drawPoint( x+centerX, y+centerY, color);
4023 drawPoint( x+centerX,-y+centerY, color);
4024 drawPoint(-x+centerX, y+centerY, color);
4025 drawPoint(-x+centerX,-y+centerY, color);
4026 drawPoint( y+centerX, x+centerY, color);
4027 drawPoint( y+centerX,-x+centerY, color);
4028 drawPoint(-y+centerX, x+centerY, color);
4029 drawPoint(-y+centerX,-x+centerY, color);
4043 drawPoint( x+centerX, y+centerY, color);
4044 drawPoint( x+centerX,-y+centerY, color);
4045 drawPoint(-x+centerX, y+centerY, color);
4046 drawPoint(-x+centerX,-y+centerY, color);
4047 drawPoint( y+centerX, x+centerY, color);
4048 drawPoint( y+centerX,-x+centerY, color);
4049 drawPoint(-y+centerX, x+centerY, color);
4050 drawPoint(-y+centerX,-x+centerY, color);
4056 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4057 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4063 int d = 1 - radiusX;
4065 int deltaSE = -2 * radiusX + 5;
4071 drawLine( x+centerX, y+centerY, x+centerX, minXY+centerY, color);
4072 drawLine( -x+centerX, y+centerY, -x+centerX, minXY+centerY, color);
4073 drawLine( x+centerX, -y+centerY, x+centerX, -minXY+centerY, color);
4074 drawLine( -x+centerX, -y+centerY, -x+centerX, -minXY+centerY, color);
4075 drawLine( y+centerX, x+centerY, minXY+centerX, x+centerY, color);
4076 drawLine( y+centerX, -x+centerY, minXY+centerX, -x+centerY, color);
4077 drawLine( -y+centerX, x+centerY, -minXY+centerX, x+centerY, color);
4078 drawLine( -y+centerX, -x+centerY, -minXY+centerX, -x+centerY, color);
4097 drawLine( x+centerX, y+centerY, x+centerX, minXY+centerY, color);
4098 drawLine( -x+centerX, y+centerY, -x+centerX, minXY+centerY, color);
4099 drawLine( x+centerX, -y+centerY, x+centerX, -minXY+centerY, color);
4100 drawLine( -x+centerX, -y+centerY, -x+centerX, -minXY+centerY, color);
4101 drawLine( y+centerX, x+centerY, minXY+centerX, x+centerY, color);
4102 drawLine( y+centerX, -x+centerY, minXY+centerX, -x+centerY, color);
4103 drawLine( -y+centerX, x+centerY, -minXY+centerX, x+centerY, color);
4104 drawLine( -y+centerX, -x+centerY, -minXY+centerX, -x+centerY, color);
4109 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4110 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4117 if( (y1 <
numPixY) && (x1 <
numPixX) && (y2 >= 0) && (x2 >= 0) ) {
4118 int noTop, noBottom, noLeft, noRight;
4119 if((noTop=(y1 < 0)))
4121 if((noLeft=(x1 < 0)))
4123 if((noBottom=(y2 >=
numPixY)))
4140 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4141 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4159 for(intCrdT y=y1;y<=y2;y++)
4164 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4165 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4168 if constexpr (enableDrawModes)
4183 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4184 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4188 intCrdT new_numPixX_p = xfactor*
numPixX;
4189 intCrdT new_numPixY_p = xfactor*
numPixY;
4190 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4191 for(intCrdT y=0, y1=0; y<
numPixY; y++) {
4192 for(intCrdT x=0, x1=0; x<
numPixX; x++) {
4193 for(
int i=0; i<xfactor; i++) {
4194 for(
int j=0; j<xfactor; j++) {
4195 new_pixels[new_numPixX_p * y1 + x1] =
getPxColor(x, y);
4211 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4212 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4215 if ((xfactor > 1) && (xfactor <=
numPixX) && (xfactor <=
numPixY)) {
4216 intCrdT new_numPixX_p =
numPixX/xfactor;
4217 intCrdT new_numPixY_p =
numPixY/xfactor;
4218 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4219 for(intCrdT y=0, y1=0; y<new_numPixY_p; y++, y1+=xfactor)
4220 for(intCrdT x=0, x1=0; x<new_numPixX_p; x++, x1+=xfactor)
4221 new_pixels[new_numPixX_p * y + x] =
getPxColor(x1, y1);
4227 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4228 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4231 if ((xfactor > 1) && (xfactor <=
numPixX) && (xfactor <=
numPixY)) {
4232 intCrdT new_numPixX_p =
numPixX/xfactor;
4233 intCrdT new_numPixY_p =
numPixY/xfactor;
4234 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4235 for(intCrdT y=0, y1=0; y<new_numPixY_p; y++, y1+=xfactor)
4236 for(intCrdT x=0, x1=0; x<new_numPixX_p; x++, x1+=xfactor) {
4237 std::vector<colorChanArithSDPType> sums(colorT::channelCount,
static_cast<colorChanArithSDPType>(0));
4238 for(
int j=0; j<xfactor; j++)
4239 for(
int i=0; i<xfactor; i++)
4240 for(
int c=0; c<colorT::channelCount; c++)
4241 sums[c] +=
getPxColor(x1+i, y1+j).getChan(c);
4243 for(
int c=0; c<colorT::channelCount; c++)
4244 aColor.setChan(c,
static_cast<colorChanType>(sums[c] / (xfactor*xfactor)));
4245 new_pixels[new_numPixX_p * y + x] = aColor;
4252 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4253 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4256 if ((xfactor > 1) && (xfactor <=
numPixX) && (xfactor <=
numPixY)) {
4257 intCrdT new_numPixX_p =
numPixX/xfactor;
4258 intCrdT new_numPixY_p =
numPixY/xfactor;
4259 colorT *new_pixels =
new colorT[new_numPixX_p * new_numPixY_p];
4260 for(intCrdT y=0, y1=0; y<new_numPixY_p; y++, y1+=xfactor)
4261 for(intCrdT x=0, x1=0; x<new_numPixX_p; x++, x1+=xfactor) {
4262 colorT maxColor =
getPxColor(xfactor*x, xfactor*y);
4263 for(
int yi=0; yi<xfactor; yi++)
4264 for(
int xi=0; xi<xfactor; xi++)
4265 maxColor.tfrmMaxI(
getPxColor(xfactor*x+xi, xfactor*y+yi));
4266 new_pixels[new_numPixX_p * y + x] = maxColor;
4273 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4274 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4277 for(
int yi=0, yis=-(kSize/2); yi<kSize; yi++, yis++)
4278 for(
int xi=0,xis=-(kSize/2); xi<kSize; xi++, xis++)
4279 kernel[kSize * yi + xi] = exp(-(xis*xis+yis*yis)/(2*sd*sd))/(sd*sd*2*std::numbers::pi);
4281 for(
int i=0; i<(kSize*kSize); i++)
4282 divisor += kernel[i];
4283 for(
int i=0; i<(kSize*kSize); i++)
4284 kernel[i] /= divisor;
4288 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4289 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4292 for(
int yi=0, yis=-(kSize/2); yi<kSize; yi++, yis++)
4293 for(
int xi=0,xis=-(kSize/2); xi<kSize; xi++, xis++)
4294 kernel[kSize * yi + xi] = 1.0/(kSize*kSize);
4298 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4299 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4304 if (mjr::math::fc::near_zero(divisor, 0.0001)) {
4306 for(
int i=0; i<(kWide*kTall); i++)
4307 divisor += kernel[i];
4310 double tmp[colorT::channelCount];
4311 for(intCrdT y=0; y<
numPixY; y++) {
4312 for(intCrdT x=0; x<
numPixX; x++) {
4314 for(
int chan=0; chan<colorT::channelCount; chan++)
4316 for(
int yi=0, yis=-(kTall/2); yi<kTall; yi++, yis++) {
4317 intCrdT icY = y + yis;
4318 for(
int xi=0,xis=-(kWide/2); xi<kWide; xi++, xis++) {
4319 intCrdT icX = x + xis;
4321 for(
int chan=0; chan<colorT::channelCount; chan++)
4322 tmp[chan] +=
static_cast<double>(
getPxColor(icX, icY).getChan(chan)) * kernel[kWide * yi + xi];
4326 for(
int chan=0; chan<colorT::channelCount; chan++)
4334 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4335 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4341 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4342 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4349 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4350 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4356 if( (glyphNum < 0) || (glyphNum > 3934) )
4365 x1 =
static_cast<intCrdT
>(magX * ((
mjr::hershey::chars[glyphNum]).components[2*i] -
'R'));
4367 x1 =
static_cast<intCrdT
>(magX * (
'R' - (
mjr::hershey::chars[glyphNum]).components[2*i]));
4370 y1 =
static_cast<intCrdT
>(magY * (
'R' - (
mjr::hershey::chars[glyphNum]).components[2*i+1]));
4372 y1 =
static_cast<intCrdT
>(magY * ((
mjr::hershey::chars[glyphNum]).components[2*i+1] -
'R'));
4374 if(actionIsMoveTo) {
4385 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4386 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4389 for(
auto &c : aString) {
4391 if((c>=32) && (c<=126))
4394 x+=
static_cast<intCrdT
>(spc*cex);
4399 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4400 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4404 intCrdT x, intCrdT y,
4406 double cex, intCrdT spc) {
4408 static_cast<intCrdT
>(y-spc*cex),
4409 static_cast<intCrdT
>(x+spc*cex*
static_cast<int>(aString.length())),
4410 static_cast<intCrdT
>(y+spc*cex),
4412 drawString(aString, aFont, x, y, stringColor, cex, spc);
4416 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4417 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4422 std::ifstream iStream(fileName, std::ios_base::binary);
4424 if (!(iStream.good()))
4427 iStream.getline(strBuf, 10,
'\n');
4428 if (!(iStream.good()))
4430 if (iStream.gcount() != 7)
4432 if(std::string(strBuf) != std::string(
"MJRRAW"))
4438 int fileBitPerChan = -1;
4439 bool fileIsSGN =
true, fileHasS =
false;
4440 bool fileIsInt =
true, fileHasT =
false;
4441 bool fileIsLTL =
true, fileHasI =
false;
4443 iStream.getline(strBuf, 100,
'\n');
4444 if (!(iStream.good()))
4446 if (iStream.gcount() != 93)
4449 std::string::size_type tagIdx;
4450 std::string::size_type prcIdx = 0;
4451 std::string strBufS(strBuf);
4452 std::string delChrs(
"abcdefghijklmnopqrstuvwxyz");
4453 int stoiErrorCount = 0;
4456 tagIdx = strBufS.find_first_of(delChrs, prcIdx);
4457 if (tagIdx == std::string::npos)
4462 switch(strBufS[tagIdx]) {
4463 case 'x' : fileWide = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4464 case 'y' : fileTall = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4465 case 'c' : fileChans = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4466 case 'b' : fileBitPerChan = std::stoi(strBufS.substr(prcIdx, tagIdx-prcIdx));
break;
4467 case 's' : fileIsSGN = (strBufS[prcIdx] ==
'S'); fileHasS =
true;
break;
4468 case 't' : fileIsInt = (strBufS[prcIdx] ==
'I'); fileHasT =
true;
break;
4469 case 'i' : fileIsLTL = (strBufS[prcIdx] ==
'L'); fileHasI =
true;
break;
4477 int fileBytePerChan = fileBitPerChan / 8;
4488 if (stoiErrorCount > 0)
4497 if (fileBitPerChan < 0)
4521 fileIsSGN = ( !(fileIsInt));
4523 if ((colorT::chanIsInt && fileIsSGN))
4526 if ((colorT::chanIsInt && !fileIsInt) ||
4527 (colorT::chanIsFloat && fileIsInt))
4530 if(fileChans != colorT::channelCount)
4533 if(fileBitPerChan != colorT::bitsPerChan)
4545 for((yNat?y=0:y=(
numPixY-1)); (yNat?y<numPixY:y>=0); (yNat?y++:y--)) {
4546 for((xNat?x=0:x=(
numPixX-1)); (xNat?x<numPixX:x>=0); (xNat?x++:x--)) {
4547 for(
int ci=0; ci<fileChans; ci++) {
4548 if constexpr (colorT::chanIsInt) {
4554 for(
int bi=0; bi<fileBytePerChan; bi++) {
4556 if (!(iStream.good()))
4558 if (iStream.gcount() != 1)
4569 iStream.read(strBuf, fileBytePerChan);
4580 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4581 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4584#ifndef MRASTER_FOUND_TIFF
4585 std::cerr <<
"ERROR: libTIFF no supported: readTIFFfile can't read " << fileName << std::endl;
4589 uint32_t wTIFF, hTIFF;
4590 uint16_t pmTIFF, pcTIFF, sppTIFF, bpsTIFF, fmtTIFF;
4593 if( !(tif = TIFFOpen(fileName.c_str(),
"r")))
4596 if(TIFFIsTiled(tif))
4600 if( 1 != TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &wTIFF))
4602 if( 1 != TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &hTIFF))
4604 if( 1 != TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &sppTIFF))
4606 if( 1 != TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &pcTIFF))
4608 if( 1 != TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &pmTIFF))
4610 if( 1 != TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bpsTIFF))
4614 if( 1 != TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &fmtTIFF))
4617 if (pmTIFF == PHOTOMETRIC_PALETTE)
4644 if ((pcTIFF != PLANARCONFIG_CONTIG) && (pcTIFF != PLANARCONFIG_SEPARATE))
4655 uint16_t sppRC = colorT::channelCount;
4658 if(sppTIFF != sppRC)
4661 uint16_t bpsRC = colorT::bitsPerPixel / sppRC;
4663 if(bpsTIFF != bpsRC)
4667 if ((fmtTIFF != SAMPLEFORMAT_UINT) && (fmtTIFF != SAMPLEFORMAT_IEEEFP))
4670 if (( colorType::chanIsInt && (SAMPLEFORMAT_UINT != 1)) ||
4671 (!(colorType::chanIsInt) && (SAMPLEFORMAT_IEEEFP != 3)))
4676 tsize_t scanlinesize = TIFFScanlineSize(tif);
4677 tdata_t scanLineBuffer = _TIFFmalloc(scanlinesize);
4679 if(scanLineBuffer == NULL)
4682 if (pcTIFF == PLANARCONFIG_CONTIG) {
4683 for(uint32_t row=0; row<hTIFF; row++) {
4684 if( !(TIFFReadScanline(tif, scanLineBuffer, row)))
4686 char* p = (
char*)(scanLineBuffer);
4687 for(uint32_t col=0; col<wTIFF; col++) {
4688 int x = (xNat ? col : wTIFF-col-1);
4689 int y = (yNat ? row : hTIFF-row-1);
4690 for(uint16_t samp=0; samp<sppTIFF; samp++) {
4692 p = p + (bpsTIFF/8);
4696 }
else if (pcTIFF == PLANARCONFIG_SEPARATE) {
4697 for(uint16_t samp=0; samp<sppTIFF; samp++) {
4698 for(uint32_t row=0; row<hTIFF; row++) {
4699 if( !(TIFFReadScanline(tif, scanLineBuffer, row, samp)))
4701 char* p = (
char*)(scanLineBuffer);
4702 for(uint32_t col=0; col<wTIFF; col++) {
4703 int x = (xNat ? col : wTIFF-col-1);
4704 int y = (yNat ? row : hTIFF-row-1);
4706 p = p + (bpsTIFF/8);
4712 _TIFFfree(scanLineBuffer);
4719 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4720 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4723#ifndef MRASTER_FOUND_TIFF
4731 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4732 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4741 for(intCrdT y=0; y<
numPixY; y++) {
4742 for(intCrdT x=0; x<
numPixX; x++) {
4746 double xS = fv.
x / oScale + Xo;
4747 double yS = fv.
y / oScale + Yo;
4748 if (
isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4755 return newRamCanvas;
4759 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4760 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4769 for(intCrdT y=0; y<
numPixY; y++) {
4770 for(intCrdT x=0; x<
numPixX; x++) {
4773 double xS = (HAMatrix[0] * xT + HAMatrix[1] * yT + HAMatrix[2]) / oScale + Xo;
4774 double yS = (HAMatrix[3] * xT + HAMatrix[4] * yT + HAMatrix[5]) / oScale + Yo;
4775 if (
isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4782 return newRamCanvas;
4786 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4787 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4797 for(intCrdT y=0; y<
numPixY; y++) {
4798 for(intCrdT x=0; x<
numPixX; x++) {
4799 double xT = (x - Xo);
4800 double yT = (y - Yo);
4801 double rT = std::hypot(xT, yT) / rScale;
4803 double rS = RPoly[0];
4804 for (
unsigned int i=1; i<RPoly.size(); i++)
4805 rS = rS*rT + RPoly[i];
4806 double xS = xT * rS / oScale + Xo;
4807 double yS = yT * rS / oScale + Yo;
4808 if (
isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4815 return newRamCanvas;
4819 template <
class colorT,
class intCrdT,
class fltCrdT,
bool enableDrawModes>
4820 requires (std::is_integral<intCrdT>::value && std::is_signed<intCrdT>::value && std::is_floating_point<fltCrdT>::value)
4823 std::vector<double>
const& BiPolyY,
4830 for(intCrdT y=0; y<
numPixY; y++) {
4831 for(intCrdT x=0; x<
numPixX; x++) {
4834 double xS = mjr::math::bply::eval(BiPolyX, xT, yT) / oScale + Xo;
4835 double yS = mjr::math::bply::eval(BiPolyY, xT, yT) / oScale + Yo;
4836 if (
isCliped(
static_cast<intCrdT
>(xS),
static_cast<intCrdT
>(yS))) {
4843 return newRamCanvas;
4848#define MJR_INCLUDE_ramCanvasTpl
User include file for color types.
Internal include file for ramCanvas types.
std::function< void(colorTpl &)> cr2voidType
static constexpr herChar chars[3935]
Data for each hershey font.
font
Enum for hershey font names.
static constexpr int ascii2hershey[5][95]
ASCII to Hershey Character Number mapping array.
Handy class to hold a point in 2D (integer or real)
Class providing off-screen drawing functionality.
pointFltType int2realCorner(intCrdT x, intCrdT y, int cornerIndex)
Given integer x & y coordinates and a corner index, produce real x & y coordinates for one of the pix...
void freeCanvas()
Free the pixel memory (i)
void drawRectangle(pointFltType *thePoints)
interpolationType
Enum for drawing Mode.
@ TRUNCATE
Coordinates are truncated (fractional bits chopped off)
@ AVERAGE9
Average of 9 sourounding pixels.
@ AVERAGE4
Average of four sourounding pixels.
@ NEAREST
Coordinates are rounded.
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 applyHomoPixTfrm(colorT &(colorT::*HPT)())
Apply a homogeneous pixel transformation.
void drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3)
void applyHomoPixTfrm(colorT &(colorT::*HPT)(int, int, int, int), int, int, int, int)
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)
void drawFillRectangle(pointFltType point1, pointFltType point2, colorArgType color)
void triangleEdger(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT *pts, bool findMin)
Used to find the left and right edges of a triangle.
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)
void drawPLCurve(int numPoints, intCrdT *x, intCrdT *y, colorArgType color)
Draw Piece-Wise Linear Curves.
color8c8b::cornerColorEnum colorCornerEnum
void drawFillTriangleUtl(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorT c1, colorT c2, colorT c3, bool solid)
Utliity function behind the drawFillTriangle() functions.
void drawString(std::string aString, mjr::hershey::font aFont, intCrdT x, intCrdT y, colorArgType aColor, double cex, intCrdT spc)
Render a string using Hershey ASCII Fonts.
void drawFillRectangle(pointIntType *thePoints)
pointFltType int2real(intCrdT x, intCrdT y)
Convert real x & y coordinates to integer x & y coordinates.
color8c8b::csNatType csNatType
int writeRAWfile(std::string fileName)
Simplified overload for writeRAWfile() that only requires the filename.
void drawLine(pointFltType point1, pointFltType point2, colorArgType color)
intCrdT statNumNonZeroPixels()
void moveTo(pointIntType thePoint)
void flipTranspose()
Loss-less, vertical flip of the canvas about the center.
void drawHersheyGlyph(int glyphNum, fltCrdT x, fltCrdT y, double magX, double magY, colorArgType aColor)
int writeTIFFfile(std::string fileName, bool markAlpha=true)
Simplified overload for writeTIFFfile() that only requires the filename.
void adjoinCanvasRight(const ramCanvasTpl &theCanvas)
Adjoin the canvas to the side of the current canvas.
void drawRectangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, colorArgType color)
Draw an unfilled rectangle with diagonal corners located at (x1, y1) and and (x2, y2).
endianType
Endianness Identifiers.
@ AUTO
Whatever the platform uses.
int isOnCanvas(rcSimpleFltCrdT x, rcSimpleFltCrdT y) const
void drawFillCircle(pointIntType centerPoint, intCrdT radiusX, colorArgType color)
void updRealCoords()
Several internal parameters are maintained within this class that make conversion between real coordi...
void computeConvolutionMatrixGausian(double *kernel, int kSize, double sd)
Compute a Gaussian convolution kernel (use with divisor==1.0).
std::function< color8c8b(rcSimpleIntCrdT, rcSimpleIntCrdT)> intCrd2ColType
void rotate180()
Loss-less 180 degree rotation of the canvas about the center.
realAxisOrientation
Enum for real axis orientation.
@ INVERTED
Real axis is inverted with respect to the integer axis.
@ NATURAL
Real axis is not inverted with respect to the integer axis.
~ramCanvasTpl()
Destructor deallocates memory for the canvas.
void flipVert()
Loss-less, vertical flip of the canvas about the center.
void drawFillTriangle(pointFltType *thePoints)
void drawPoint(fltCrdT x, fltCrdT y, colorArgType color)
void drawFillTriangle(pointIntType *thePoints)
void drawPLCurve(int numPoints, fltCrdT *x, fltCrdT *y, colorArgType color)
void clrCanvasChannelToMin(int chan)
Set the given channel to the minimum value.
rcSimpleIntCrdT real2intX(rcSimpleFltCrdT x) const
colorChanType getPxColorChanWrap(fltCrdT x, fltCrdT y) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::function< color8c8b(rcSimpleFltCrdT, rcSimpleFltCrdT)> fltCrd2ColType
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)
void drawFillTriangle(pointFltType *thePoints, colorArgType color)
colorT * clonePixels()
Return a clone (a copy) of the raw pixel store.
void applyHomoPixTfrm(colorT &(colorT::*HPT)(int, int), int, int)
colorChanType getPxColorChanWrap(pointIntType thePoint) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void resizeCanvas(intCrdT new_numPixX_p, intCrdT new_numPixY_p)
Resize the canvas to the given size.
intCrdT statNumNonZeroPixels(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2)
void drawRectangle(pointFltType point1, pointFltType point2, colorArgType color)
void drawLine(pointFltType point1, pointFltType point2)
intAxisOrientation intAxOrientationX
void drawPoint(intCrdT x, intCrdT y)
void writeUIntToStream(std::ostream &oStream, endianType endianness, int numBytes, uint64_t data)
Write an unsigned integer to a stream with given length and endianness.
void drawTriangle(pointIntType point1, pointIntType point2, pointIntType point3)
void drawLine(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2)
drawModeType
Enum for drawing Mode.
@ DIFFCLAMP
See: tfrmDiffClamp()
@ SET
Simply set the pixel value to the new value.
@ ADDCLAMP
See: tfrmAddClamp()
@ MULTCLAMP
See: tfrmMultClamp()
void setDefaultDrawMode()
Set the default draw mode.
rcSimpleFltCrdT canvasWidY
void drawFillTriangle(pointIntType point1, pointIntType point2, pointIntType point3)
void scaleDown1pt(int xfactor)
Scale down using only the upper left pixel from each block.
void applyHomoPixTfrm(colorT &(colorT::*HPT)(colorT, colorT, colorT), colorT, colorT, colorT)
void drawFillTriangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, fltCrdT x3, fltCrdT y3, colorArgType color)
void drawString(std::string aString, mjr::hershey::font aFont, fltCrdT x, fltCrdT y, colorArgType aColor, double cex, intCrdT spc)
void applyHomoPixTfrm(colorT &(colorT::*HPT)(double, double, double, double, double), double, double, double, double, double)
void drawTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3)
rcSimpleFltCrdT canvasWidX
void drawLine(pointIntType point1)
void drawTriangle(pointIntType *thePoints, colorArgType color)
void clrCanvasChannelToMax(int chan)
Set the given channel to the maximum value.
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)
std::function< color8c8b(pointIntType)> intPnt2ColType
void drawLine(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, colorArgType color)
Draw a line.
color8c8b::colorRefType colorRefType
static const rcSimpleIntCrdT intCrdMax
static const rcSimpleIntCrdT intCrdGrdMax
void cropCanvas(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2)
This function will crop the canvas to the given rectangular region.
rcSimpleIntCrdT realDelta2intX(rcSimpleFltCrdT x) const
fltCrdT getCanvasWidD()
Width of the display (real coord)
void drawPLCurve(int numPoints, pointFltType *thePoints, colorArgType color)
void drawStringBox(std::string aString, mjr::hershey::font aFont, intCrdT x, intCrdT y, colorArgType stringColor, colorArgType boxColor, double cex, intCrdT spc)
Renders a filled, bounding box for the given string as rendered via drawString.
void applyHomoPixTfrm(colorT &(colorT::*HPT)(colorT, colorT, colorT, colorT), colorT, colorT, colorT, colorT)
void setDfltColor(std::string cornerColor)
void clrCanvas(colorArgType color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setDrawMode(drawModeType newDrawMode)
Set the current drawing mode NOOP if enableDrawModes is false.
void setDfltColor(const char *cornerColor)
color8c8b::channelArithFltType colorChanArithFltType
void drawFillTriangle(pointIntType point1, pointIntType point2, pointIntType point3, colorArgType color)
void drawRectangle(pointIntType *thePoints, colorArgType color)
color8c8b * pixelIterator
void drawTriangle(pointFltType point1, pointFltType point2, pointFltType point3, colorArgType color)
intAxisOrientation getIntAxOrientationX()
Get the integer X axis orientation.
void incPxChan(fltCrdT x, fltCrdT y, colorChanType v=1)
void newRealCoords(fltCrdT minRealX_p, fltCrdT maxRealX_p, fltCrdT minRealY_p, fltCrdT maxRealY_p)
Change the real coordinate system associated with a canvas.
void combineRamCanvasBinOp(colorT &(colorT::*HPT)(colorT), const ramCanvasTpl &theCanvas, intCrdT trgX=0, intCrdT trgY=0, intCrdT wide=-1, intCrdT tall=-1, intCrdT srcX=0, intCrdT srcY=0)
This function takes a ramCanvasTpl and combines it with the current ramCanvasTpl using the provided b...
colorChanType getPxColorChanWrap(pointFltType thePoint) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void applyHomoPixTfrm(colorT &(colorT::*HPT)(colorT), colorT)
void drawPointS(intCrdT x, intCrdT y, colorArgType color)
Draw a point without any special drawing options.
void drawPoint(pointIntType thePoint)
void tformPixel(pointFltType thePoint, colorType::cr2voidType tform)
void drawTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorArgType color)
Draw an un-filled triangle.
void drawLine(pointIntType point1, pointIntType point2)
void setRealAxOrientationX(realAxisOrientation orientation)
Set the real X axis orientation.
void moveTo(pointFltType thePoint)
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.
void rotate90CW()
Loss-less 90 degree clockwise rotation of the canvas about the center.
colorT getPxColorInterpNear(double x, double y)
Returns the nearest neighbor interpolated color value at the the given coordinates.
void clrCanvasToWhite()
Clear the canvas to black.
void setDfltColor(colorArgType color)
Set the default color.
void flipHorz()
Loss-less, horizontal flip of the canvas about the center.
void moveTo(intCrdT x, intCrdT y)
Set the current default point to the given coordinates.
void drawCircle(pointFltType centerPoint, fltCrdT radiusX)
void applyHomoPixTfrm(colorT &(colorT::*HPT)(double, double), double, double)
void drawTriangle(pointFltType *thePoints, colorArgType color)
fltCrdT getMaxRealX()
x coord of max (real coord)
realAxisOrientation realAxOrientationX
void applyHomoPixTfrm(colorT &(colorT::*HPT)(colorT, colorT), colorT, colorT)
color8c8b::maskType colorMaskType
void drawPLCurve(int numPoints, pointIntType *thePoints, colorArgType color)
void drawFillCircle(pointFltType centerPoint, fltCrdT radiusX, colorArgType color)
void drawCircle(pointFltType centerPoint, fltCrdT radiusX, colorArgType color)
colorT getPxColorChan(pointFltType thePoint) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void applyHomoPixTfrm(colorT &(colorT::*HPT)(double, double, double, double, double, double), double, double, double, double, double, double)
bool isIntAxOrientationNaturalY()
Get the integer Y axis orientation.
void applyPixelRefFun(colorT::cr2voidType f)
Apply a a function to a each pixel via refrence.
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)
void reallocCanvas(intCrdT numPixX_p, intCrdT numPixY_p)
Destroy the current pixel memory and reallocate a new pixel space of the given size.
int isCliped(intCrdT x, intCrdT y) const
color8c8b::colorArgType colorArgType
bool supportLibTIFF()
Is libTIFF supported – that is: will the readTIFFfile() method do anything?
void drawPointNC(rcSimpleIntCrdT x, rcSimpleIntCrdT y, colorArgType color)
ramCanvasTpl(const ramCanvasTpl &theCanvas)
Copy constructor.
point2d< rcSimpleIntCrdT > pointIntType
void scaleUpProximal(int xfactor)
Scale up the image using proximal interpolation.
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...
rcSimpleFltCrdT coordFltType
std::complex< rcSimpleFltCrdT > cplxFltType
void scaleDownMean(int xfactor)
Scale down using the mean pixel value from each block.
int exportRasterData(void *&rasterData, intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, int redChan, int greenChan, int blueChan, int alphaChan)
Extract raster data from the image, and pack it into a typical form used by imaging applications.
void drawFillTriangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, fltCrdT x3, fltCrdT y3)
void clrCanvasToBlack()
Clear the canvas to black.
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)
color8c8b::channelArithSDPType colorChanArithSDPType
void drawRectangle(pointFltType point1, pointFltType point2)
void drawTriangle(pointFltType *thePoints)
void colorizeFltCanvas(std::function< colorT(fltCrdT, fltCrdT)> cFun)
color8c8b::colorPtrType colorPtrType
colorT getPxColorInterpTrunc(double x, double y)
Returns the truncated interpolated color value at the the given coordinates.
void drawCircle(pointIntType centerPoint, intCrdT radiusX)
colorT getPxColorInterpBLin(double x, double y)
Returns the bilinear interpolated color value at the the given coordinates.
void setDfltColor(colorChanType r, colorChanType g, colorChanType b)
ramCanvasTpl geomTfrmRevBiPoly(std::vector< double > const &BiPolyX, std::vector< double > const &BiPolyY, double Xo, double Yo, double oScale, colorArgType errorColor=colorCornerEnum::GREEN, interpolationType interpMethod=interpolationType::BILINEAR)
Geometric Transform via bivariate polynomial implemented with Reverse Mapping.
color8c8b::channelArithSPType colorChanArithSPType
void colorizeIntCanvas(std::function< colorT(intCrdT, intCrdT)> cFun)
void drawLine(pointIntType point1, pointIntType point2, colorArgType color)
int readTIFFfile(std::string fileName)
If the libTIFF library was found at build time, this function will read a TIFF file into current ramC...
void rePointPixels(colorT *new_pixels, intCrdT new_numPixX, intCrdT new_numPixY)
Points the pixels pointer at a new pixel store, and updates coordinates.
void drawPoint(pointFltType thePoint)
ramCanvasTpl(intCrdT numPixX_p, intCrdT numPixY_p, fltCrdT minRealX_p=-1, fltCrdT maxRealX_p=1, fltCrdT minRealY_p=-1, fltCrdT maxRealY_p=1)
Most commonly used constructor.
void incPxChan(pointFltType thePoint, colorChanType v=1)
void drawFillCircle(intCrdT centerX, intCrdT centerY, intCrdT radiusX, colorArgType color)
Draw an un-filled circle.
fltCrdT int2realSideY(intCrdT y, int side)
Given integer y coordinate, produce real y coordinate for one of the pixel's edge.
point2d< rcSimpleFltCrdT > pointFltType
realAxisOrientation realAxOrientationY
std::vector< pointIntType > pointIntVecType
ramCanvasTpl geomTfrmRevAff(std::vector< double > const &HAMatrix, double Xo, double Yo, double oScale, colorArgType errorColor=colorCornerEnum::GREEN, interpolationType interpMethod=interpolationType::BILINEAR)
Homogenious Affine Geometric Transform implemented with Reverse Mapping.
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)
void applyHomoPixTfrm(colorT &(colorT::*HPT)(int, int, int), int, int, int)
intAxisOrientation intAxOrientationY
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.
void drawPLCurve(int numPoints, pointIntType *thePoints)
intCrdT realDelta2intY(fltCrdT y) const
Convert real distance on the y coordinate axis to an integral distance.
void autoMaxHistStrechRGB()
Computes a, possibly different, linear grey level scale homogeneous pixel transformation on each chan...
void convolution(double *kernel, int kSize)
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)
static const rcSimpleIntCrdT intCrdGrdMin
std::function< color8c8b(pointFltType)> fltPnt2ColType
void insertCanvas(const ramCanvasTpl &theCanvas, rcSimpleIntCrdT x1=0, rcSimpleIntCrdT y1=0)
void drawCircle(fltCrdT radiusX)
color8c8b::cmfInterpolationEnum cmfInterpolationEnum
colorT getPxColorInterpAvg9(double x, double y)
Returns the average 9 interpolated color value at the the given coordinates.
color8c8b getPxColorNC(rcSimpleIntCrdT x, rcSimpleIntCrdT y) const
color8c8b::colorSpaceEnum colorSpaceEnum
void drawHersheyGlyph(int glyphNum, intCrdT x, intCrdT y, double magX, double magY, colorArgType aColor)
Render a glyph from the Hershey character set.
int writeRAWfile(std::string fileName, rcConT pxFilter)
Write a MJRRAW file.
void tformPixel(fltCrdT x, fltCrdT y, colorType::cr2voidType tform)
ramCanvasTpl geomTfrmRevArb(mjr::point2d< double >(*f)(double, double), double Xo, double Yo, double oScale, colorArgType errorColor=colorCornerEnum::GREEN, interpolationType interpMethod=interpolationType::BILINEAR)
Geometric Transform via provided mapping function implemented with Reverse Mapping.
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...
void applyHomoPixTfrm(colorT &(colorT::*HPT)(double, double, double, double), double, double, double, double)
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)
void applyHomoPixTfrm(colorT &(colorT::*HPT)(double), double)
void drawFillRectangle(pointIntType point1, pointIntType point2, colorArgType color)
void drawRectangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2)
void drawFillRectangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, colorArgType color)
Draw a filled rectangle with diagonal corners located at (x1, y1) and and (x2, y2).
void tformPixel(intCrdT x, intCrdT y, colorType::cr2voidType tform)
Transform the pixel at the specified coordinates.
void drawFillCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX)
int isOnCanvas(intCrdT x, intCrdT y) const
rcSimpleIntCrdT coordIntType
void drawPoint(colorArgType color)
void drawCircle(pointIntType centerPoint, intCrdT radiusX, colorArgType color)
colorT getPxColorInterpAvg4(double x, double y)
Returns the average 4 interpolated color value at the the given coordinates.
void colorizeIntCanvas(std::function< colorT(pointIntType)> cFun)
ramCanvasTpl(ramCanvasTpl &&theCanvas)
Move constructor.
void drawPLCurve(int numPoints, intCrdT *x, intCrdT *y)
int writeTIFFfile(std::string fileName, rcConT pxFilter, bool markAlpha=true)
Write a TIFF format image file.
void drawPLCurve(int numPoints, pointFltType *thePoints)
fltCrdT getPixWidY()
Height of a pixel (real coord)
void drawCircle(intCrdT centerX, intCrdT centerY, intCrdT radiusX, colorArgType color)
Draw an un-filled circle.
void drawFillCircle(fltCrdT centerX, fltCrdT centerY, fltCrdT radiusX, colorArgType color)
realAxisOrientation getRealAxOrientationY()
Get the real Y axis orientation.
void clrCanvas()
Clear the canvas.
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)
int writeTGAfile(std::string fileName)
Write a 24-bit (8-bit per channel) RGB, TGA format graphics file.
void drawTriangle(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2, fltCrdT x3, fltCrdT y3, colorArgType color)
endianType platformEndianness()
Determine the platform's endianness.
int readRAWfile(std::string fileName)
Read RAW file.
rcSimpleIntCrdT getNumPixX() const
colorT getPxColorChan(intCrdT x, intCrdT y) const
Returns a copy of the color channel value at the given coordinates.
rcSimpleIntCrdT getNumPixY() const
std::complex< rcSimpleIntCrdT > cplxIntType
fltCrdT getMinRealX()
x coord of min (real coord)
void rotate90CCW()
Loss-less 90 degree counter clockwise rotation of the canvas about the center.
void drawRectangle(pointIntType point1, pointIntType point2)
void scaleDownMax(int xfactor)
Scale down using only the pixel with maximum luminosity in each block.
fltCrdT int2realX(intCrdT x)
Convert integral x coordinate to real x coordinate.
void drawTriangle(pointIntType *thePoints)
fltCrdT int2realY(intCrdT y)
Convert integral y coordinate to real y coordinate.
void drawPoint(rcSimpleIntCrdT x, rcSimpleIntCrdT y, colorArgType color)
void setIntAxOrientationY(intAxisOrientation orientation)
Set the integer Y axis orientation.
color8c8b::channelArithLogType colorChanArithLogType
void colorizeFltCanvas(std::function< colorT(pointFltType)> cFun)
ramCanvasTpl geomTfrmRevRPoly(std::vector< double > const &RPoly, double rScale, double Xo, double Yo, double oScale, colorArgType errorColor=colorCornerEnum::GREEN, interpolationType interpMethod=interpolationType::BILINEAR)
Geometric Transform via Radial Polynomial implemented with Reverse Mapping.
void drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorArgType color1, colorArgType color2, colorArgType color3)
Draw a filled triangle using barycentric color interpolation.
void expandCanvas(rcSimpleIntCrdT new_numPixX_p, rcSimpleIntCrdT new_numPixY_p, rcSimpleIntCrdT x1=0, rcSimpleIntCrdT y1=0, colorArgType color=color8c8b(color8c8b::minChanVal))
colorT getPxColorChan(pointIntType thePoint) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
color8c8b::csFltType csFltType
void drawLine(fltCrdT x1, fltCrdT y1, fltCrdT x2, fltCrdT y2)
void autoHistStrech()
Computes a linear grey level scale homogeneous pixel transformation.
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 applyHomoPixTfrm(colorT &(colorT::*HPT)(double, double, double), double, double, double)
colorT getPxColorChan(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)
ramCanvasTpl & operator=(ramCanvasTpl &&theCanvas)
Move assignment operator.
void adjoinCanvasBottom(const ramCanvasTpl &theCanvas)
Adjoin the canvas to the side of the current canvas.
colorT getPxColorInterpolate(double x, double y, interpolationType interpMethod=interpolationType::BILINEAR)
Returns the interpolated color value at the the given coordinates using the given interpolation metho...
void computeConvolutionMatrixBox(double *kernel, int kSize)
Compute a box blur convolution kernel (use with divisor==1.0).
color8c8b::channelType colorChanType
void drawFillTriangle(pointFltType point1, pointFltType point2, pointFltType point3, colorArgType color)
void applyHomoPixTfrm(colorT &(colorT::*HPT)(int), int)
color8c8b::csIntType csIntType
color8c8b::channelArithDType colorChanArithDType
void drawPLCurve(int numPoints, fltCrdT *x, fltCrdT *y)
void drawPoint(pointIntType thePoint, colorArgType color)
void incPxChan(intCrdT x, intCrdT y, colorChanType v=1)
Increment the specified color channel of the pixel at the given coordinates by the specified value.
void convolution(double *kernel, int kSize, double divisor)
void drawFillRectangle(pointIntType point1, pointIntType point2)
intAxisOrientation
Enum for integer axis orientation.
colorT * getPixels()
Returns a pointer to the raw pixel store.
void tformPixel(pointIntType thePoint, colorType::cr2voidType tform)
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 convolution(double *kernel, int kWide, int kTall, double divisor)
Apply a convolution filter.
void drawTriangle(pointIntType point1, pointIntType point2, pointIntType point3, colorArgType color)
color8c8b::colorCRefType colorCRefType
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 drawFillTriangle(intCrdT x1, intCrdT y1, intCrdT x2, intCrdT y2, intCrdT x3, intCrdT y3, colorArgType color)
Draw a triangle filled with a solid color using a nicely optimized, horizontal scan conversion algori...
void setIntAxisDefaultOrientation()
Set the integer axis orientation to default (NATURAL for both X and Y axes)
rcSimpleIntCrdT real2intY(rcSimpleFltCrdT y) const
fltCrdT getMinRealY()
y coord of min (real coord)
void incPxChan(pointIntType thePoint, colorChanType v=1)
ramCanvasTpl()
No arg constructor.
void drawLine(pointIntType point1, colorArgType color)