void doMakeStereoRaster(const TRasterPT<T> &rleft, const TRasterPT<T> &rright) { int lx = rleft->getLx(); int ly = rright->getLy(); for (int i = 0; i < ly; i++) { T *pixl = rleft->pixels(i); T *pixr = rright->pixels(i); for (int j = 0; j < lx; j++, pixl++, pixr++) { pixl->g = pixr->g; pixl->b = pixr->b; } } }
void doSetChannel(const TRasterPT<T> &rin, const TRasterPT<T> &rout, UCHAR channel, bool greytones) { int lx = rin->getLx(); int ly = rout->getLy(); int i, j; for (i = 0; i < ly; i++) { T *pixin = rin->pixels(i); T *pixout = rout->pixels(i); if (greytones || channel == TRop::MChan) { switch (channel) { case TRop::RChan: for (j = 0; j < lx; j++, pixin++, pixout++) pixout->r = pixout->g = pixout->b = pixout->m = pixin->r; break; case TRop::GChan: for (j = 0; j < lx; j++, pixin++, pixout++) pixout->r = pixout->g = pixout->b = pixout->m = pixin->g; break; case TRop::BChan: for (j = 0; j < lx; j++, pixin++, pixout++) pixout->r = pixout->g = pixout->b = pixout->m = pixin->b; break; case TRop::MChan: for (j = 0; j < lx; j++, pixin++, pixout++) pixout->r = pixout->g = pixout->b = pixout->m = pixin->m; break; default: assert(false); } } else { for (j = 0; j < lx; j++, pixin++, pixout++) { pixout->r = channel & TRop::RChan ? pixin->r : 0; pixout->b = channel & TRop::BChan ? pixin->b : 0; pixout->g = channel & TRop::GChan ? pixin->g : 0; } } } }
void ropSharpen(const TRasterPT<T> &rin, TRasterPT<T> &rout, int sharpen_max_corr) { T *bufin, *east, *northeast, *southeast; T *bufout, *pixout; int lx, ly, wrapin, wrapout, x, y, count; int cntr_r, east_r, col_west_r, col_cntr_r, col_east_r; int cntr_g, east_g, col_west_g, col_cntr_g, col_east_g; int cntr_b, east_b, col_west_b, col_cntr_b, col_east_b; int cntr_m, east_m, col_west_m, col_cntr_m, col_east_m; int lapl, out; #define SET_PIXOUT(X) \ { \ lapl = (cntr_##X << 3) + cntr_##X - \ (col_west_##X + col_cntr_##X + col_east_##X); \ if (lapl < 0) { \ out = cntr_##X - ((256 * 4 - lapl * sharpen_max_corr) >> (8 + 3)); \ pixout->X = (out <= 0) ? 0 : out; \ } else { \ out = cntr_##X + ((256 * 4 + lapl * sharpen_max_corr) >> (8 + 3)); \ pixout->X = (out >= maxChanVal) ? maxChanVal : out; \ } \ } rin->lock(); rout->lock(); bufin = (T *)rin->getRawData(); bufout = (T *)rout->getRawData(); lx = std::min(rin->getLx(), rout->getLx()); ly = std::min(rin->getLy(), rout->getLy()); wrapin = rin->getWrap(); wrapout = rout->getWrap(); int maxChanVal = T::maxChannelValue; if (lx <= 1 || ly <= 1) { for (y = 0; y < ly; y++) for (x = 0; x < lx; x++) bufout[x + y * wrapout] = bufin[x + y * wrapin]; return; } east = bufin; northeast = east + wrapin; east_r = east->r; east_g = east->g; east_b = east->b; east_m = east->m; col_east_r = 2 * east_r + northeast->r; col_east_g = 2 * east_g + northeast->g; col_east_b = 2 * east_b + northeast->b; col_east_m = 2 * east_m + northeast->m; col_cntr_r = col_east_r; col_cntr_g = col_east_g; col_cntr_b = col_east_b; col_cntr_m = col_east_m; east++; northeast++; pixout = bufout; for (count = lx - 1; count > 0; count--, east++, northeast++, pixout++) { cntr_r = east_r; east_r = east->r; col_west_r = col_cntr_r; col_cntr_r = col_east_r; col_east_r = 2 * east_r + northeast->r; SET_PIXOUT(r) cntr_g = east_g; east_g = east->g; col_west_g = col_cntr_g; col_cntr_g = col_east_g; col_east_g = 2 * east_g + northeast->g; SET_PIXOUT(g) cntr_b = east_b; east_b = east->b; col_west_b = col_cntr_b; col_cntr_b = col_east_b; col_east_b = 2 * east_b + northeast->b; SET_PIXOUT(b) cntr_m = east_m; east_m = east->m; col_west_m = col_cntr_m; col_cntr_m = col_east_m; col_east_m = 2 * east_m + northeast->m; SET_PIXOUT(m) } cntr_r = east_r; col_west_r = col_cntr_r; col_cntr_r = col_east_r; SET_PIXOUT(r) cntr_g = east_g; col_west_g = col_cntr_g; col_cntr_g = col_east_g; SET_PIXOUT(g) cntr_b = east_b; col_west_b = col_cntr_b; col_cntr_b = col_east_b; SET_PIXOUT(b) cntr_m = east_m; col_west_m = col_cntr_m; col_cntr_m = col_east_m; SET_PIXOUT(m) for (y = 1; y < ly - 1; y++) { east = bufin + y * wrapin; northeast = east + wrapin; southeast = east - wrapin; east_r = east->r; east_g = east->g; east_b = east->b; east_m = east->m; col_east_r = east_r + northeast->r + southeast->r; col_east_g = east_g + northeast->g + southeast->g; col_east_b = east_b + northeast->b + southeast->b; col_east_m = east_m + northeast->m + southeast->m; col_cntr_r = col_east_r; col_cntr_g = col_east_g; col_cntr_b = col_east_b; col_cntr_m = col_east_m; east++; northeast++; southeast++; pixout = bufout + y * wrapout; for (count = lx - 1; count > 0; count--, east++, northeast++, southeast++, pixout++) { cntr_r = east_r; east_r = east->r; col_west_r = col_cntr_r; col_cntr_r = col_east_r; col_east_r = east_r + northeast->r + southeast->r; SET_PIXOUT(r) cntr_g = east_g; east_g = east->g; col_west_g = col_cntr_g; col_cntr_g = col_east_g; col_east_g = east_g + northeast->g + southeast->g; SET_PIXOUT(g) cntr_b = east_b; east_b = east->b; col_west_b = col_cntr_b; col_cntr_b = col_east_b; col_east_b = east_b + northeast->b + southeast->b; SET_PIXOUT(b) cntr_m = east_m; east_m = east->m; col_west_m = col_cntr_m; col_cntr_m = col_east_m; col_east_m = east_m + northeast->m + southeast->m; SET_PIXOUT(m) } cntr_r = east_r; col_west_r = col_cntr_r; col_cntr_r = col_east_r; SET_PIXOUT(r) cntr_g = east_g; col_west_g = col_cntr_g; col_cntr_g = col_east_g; SET_PIXOUT(g) cntr_b = east_b; col_west_b = col_cntr_b; col_cntr_b = col_east_b; SET_PIXOUT(b) cntr_m = east_m; col_west_m = col_cntr_m; col_cntr_m = col_east_m; SET_PIXOUT(m) } east = bufin + y * wrapin; southeast = east - wrapin; east_r = east->r; east_g = east->g; east_b = east->b; east_m = east->m; col_east_r = 2 * east_r + southeast->r; col_east_g = 2 * east_g + southeast->g; col_east_b = 2 * east_b + southeast->b; col_east_m = 2 * east_m + southeast->m; col_cntr_r = col_east_r; col_cntr_g = col_east_g; col_cntr_b = col_east_b; col_cntr_m = col_east_m; east++; southeast++; pixout = bufout + y * wrapout; for (count = lx - 1; count > 0; count--, east++, southeast++, pixout++) { cntr_r = east_r; east_r = east->r; col_west_r = col_cntr_r; col_cntr_r = col_east_r; col_east_r = 2 * east_r + southeast->r; SET_PIXOUT(r) cntr_g = east_g; east_g = east->g; col_west_g = col_cntr_g; col_cntr_g = col_east_g; col_east_g = 2 * east_g + southeast->g; SET_PIXOUT(g) cntr_b = east_b; east_b = east->b; col_west_b = col_cntr_b; col_cntr_b = col_east_b; col_east_b = 2 * east_b + southeast->b; SET_PIXOUT(b) cntr_m = east_m; east_m = east->m; col_west_m = col_cntr_m; col_cntr_m = col_east_m; col_east_m = 2 * east_m + southeast->m; SET_PIXOUT(m) } cntr_r = east_r; col_west_r = col_cntr_r; col_cntr_r = col_east_r; SET_PIXOUT(r) cntr_g = east_g; col_west_g = col_cntr_g; col_cntr_g = col_east_g; SET_PIXOUT(g) cntr_b = east_b; col_west_b = col_cntr_b; col_cntr_b = col_east_b; SET_PIXOUT(b) cntr_m = east_m; col_west_m = col_cntr_m; col_cntr_m = col_east_m; SET_PIXOUT(m) rin->unlock(); rout->unlock(); }