File tree Expand file tree Collapse file tree
DeviceAdapters/DemoCamera Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3535#include < string>
3636#include < map>
3737#include < algorithm>
38+ #include < cstring>
3839#include < stdint.h>
3940#include < future>
41+ #include < vector>
4042
4143// ////////////////////////////////////////////////////////////////////////////
4244// Error codes
@@ -967,18 +969,16 @@ class ImageFlipY : public CImageProcessorBase<ImageFlipY>
967969 template <typename PixelType>
968970 int Flip (PixelType* pI, unsigned int width, unsigned int height)
969971 {
970- PixelType tmp;
971- int ret = DEVICE_OK;
972- for ( unsigned long ix = 0 ; ix < width ; ++ix)
972+ std::vector<PixelType> rowBuf (width);
973+ for (unsigned int iy = 0 ; iy < height / 2 ; ++iy)
973974 {
974- for ( unsigned long iy = 0 ; iy < (height>>1 ); ++iy)
975- {
976- tmp = pI[ ix + iy*width];
977- pI[ ix + iy*width] = pI[ ix + (height - 1 - iy)*width];
978- pI[ ix + (height - 1 - iy)*width] = tmp;
979- }
975+ PixelType* topRow = pI + iy * width;
976+ PixelType* botRow = pI + (height - 1 - iy) * width;
977+ std::memcpy (rowBuf.data (), topRow, width * sizeof (PixelType));
978+ std::memcpy (topRow, botRow, width * sizeof (PixelType));
979+ std::memcpy (botRow, rowBuf.data (), width * sizeof (PixelType));
980980 }
981- return ret ;
981+ return DEVICE_OK ;
982982 }
983983
984984
You can’t perform that action at this time.
0 commit comments