Last active
December 13, 2015 22:49
-
-
Save tclarke/4987644 to your computer and use it in GitHub Desktop.
Flip an Opticks RasterElement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DataAccessor acc = pRaster->getDataAccessor(); | |
DataAccessor outacc = pOutRaster->getDataAccessor(writableDataRequest.release()); | |
/** code to flip horizontally **/ | |
for (int row = 0; row < numrows; ++row) { | |
VERIFY(acc.valid() && outacc.valid()); | |
memcpy(outacc->getRow(), acc->getRow(), rowSizeInBytes); | |
// note: pixeldatatype is the C++ type for BSQ..for BIP, you'll need to use a struct..somthing like this for 10 bands 2-byte data | |
// struct {uint16_t data[10];} | |
// or just use a second loop with appropriate memcpy's | |
std::reverse((pixeldatatype*)outacc->getRow(), ((pixeldatatype*)outacc->getRow()) + pixelsPerRow); | |
acc->nextRow(); | |
outacc->nextRow(); | |
} | |
pOutRaster->update(); | |
/** or, code to flip vertically **/ | |
for (int row = 0; row < numrows; ++row) { | |
outacc->toPixel(numrows - row - 1, 0); | |
VERIFY(acc.valid() && outacc.valid()); | |
memcpy(outacc->getRow(), acc->getRow(), rowSizeInBytes); | |
acc->nextRow(); | |
} | |
pOutRaster->update(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment