Raster::Raster(const Raster &rast) { ncols=rast.ncols; nrows=rast.nrows; nodata=rast.nodata; cellsize=rast.cellsize; xll=rast.xll; yll=rast.yll; yur=rast.yur; xur=rast.xur; std::vector<double> rasterRow(ncols,nodata); std::vector< std::vector<double> > newRaster(nrows, rasterRow); data=newRaster; }
Raster::Raster(int NROWS, int NCOLS, double XLL, double YLL,double CELLSIZE ,int NODATA,double VALUE) { nrows=NROWS; ncols=NCOLS; xll=XLL; yll=YLL; xur=XLL+NCOLS*CELLSIZE; yur=YLL+NROWS*CELLSIZE; nodata=NODATA; cellsize=CELLSIZE; std::vector<double> rasterRow(NCOLS,VALUE); std::vector< std::vector<double> > newRaster(NROWS, rasterRow); data=newRaster; }
Raster& Raster::operator=(const Raster &rhs) { nrows=rhs.nrows; ncols=rhs.ncols; xll=rhs.xll; yll=rhs.yll; nodata=rhs.nodata; cellsize=rhs.cellsize; yur=rhs.yur; xur=rhs.xur; std::vector<double> rasterRow(ncols,nodata); std::vector< std::vector<double> > newRaster(nrows, rasterRow); data=newRaster; for(int row=0;row<this->nrows;row++) for(int col=0;col<this->ncols;col++) data[row][col]=rhs.data[row][col]; return *this; }
TRaster32P TRop::copyAndSwapRBChannels(const TRaster32P &srcRaster) { TRaster32P newRaster(srcRaster->getSize()); int lx = srcRaster->getLx(); int y = srcRaster->getLy(); srcRaster->lock(); newRaster->lock(); while (--y >= 0) { TPixel32 *pix = srcRaster->pixels(y); TPixel32 *newpix = newRaster->pixels(y); TPixel32 *endPix = pix + lx; while (pix < endPix) { newpix->r = pix->b; newpix->g = pix->g; newpix->b = pix->r; newpix->m = pix->m; ++pix; ++newpix; } } srcRaster->unlock(); newRaster->unlock(); return newRaster; }