Fixed pixel flipping (ex:horizontal was vertical)
Former-commit-id: 8fb8e6949ae1d2c3d53e42b979f1716e25d3bba9
This commit is contained in:
@@ -98,6 +98,35 @@ inline bool NzPixelFormat::Flip(nzPixelFlipping flipping, nzPixelFormat format,
|
||||
switch (flipping)
|
||||
{
|
||||
case nzPixelFlipping_Horizontally:
|
||||
{
|
||||
if (src == dst)
|
||||
{
|
||||
for (unsigned int z = 0; z < depth; ++z)
|
||||
{
|
||||
nzUInt8* ptr = reinterpret_cast<nzUInt8*>(dst) + width*height*z;
|
||||
for (unsigned int y = 0; y < height/2; ++y)
|
||||
std::swap_ranges(&ptr[y*lineStride], &ptr[(y+1)*lineStride-1], &ptr[(height-y-1)*lineStride]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int z = 0; z < depth; ++z)
|
||||
{
|
||||
const nzUInt8* srcPtr = reinterpret_cast<const nzUInt8*>(src);
|
||||
nzUInt8* dstPtr = reinterpret_cast<nzUInt8*>(dst) + (width-1)*height*depth*bpp;
|
||||
for (unsigned int y = 0; y < height; ++y)
|
||||
{
|
||||
std::memcpy(dstPtr, srcPtr, lineStride);
|
||||
|
||||
srcPtr += lineStride;
|
||||
dstPtr -= lineStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case nzPixelFlipping_Vertically:
|
||||
{
|
||||
if (src == dst)
|
||||
{
|
||||
@@ -129,35 +158,6 @@ inline bool NzPixelFormat::Flip(nzPixelFlipping flipping, nzPixelFormat format,
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case nzPixelFlipping_Vertically:
|
||||
{
|
||||
if (src == dst)
|
||||
{
|
||||
for (unsigned int z = 0; z < depth; ++z)
|
||||
{
|
||||
nzUInt8* ptr = reinterpret_cast<nzUInt8*>(dst) + width*height*z;
|
||||
for (unsigned int y = 0; y < height/2; ++y)
|
||||
std::swap_ranges(&ptr[y*lineStride], &ptr[(y+1)*lineStride-1], &ptr[(height-y-1)*lineStride]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int z = 0; z < depth; ++z)
|
||||
{
|
||||
const nzUInt8* srcPtr = reinterpret_cast<const nzUInt8*>(src);
|
||||
nzUInt8* dstPtr = reinterpret_cast<nzUInt8*>(dst) + (width-1)*height*depth*bpp;
|
||||
for (unsigned int y = 0; y < height; ++y)
|
||||
{
|
||||
std::memcpy(dstPtr, srcPtr, lineStride);
|
||||
|
||||
srcPtr += lineStride;
|
||||
dstPtr -= lineStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user