Add vertical flip.
This commit is contained in:
parent
ac5f849e91
commit
85db14f213
@ -941,6 +941,25 @@ void FloatImage::applyKernelHorizontal(const PolyphaseKernel & k, int y, uint c,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Vertical flip in place.
|
||||
void FloatImage::flip()
|
||||
{
|
||||
const uint w = m_width;
|
||||
const uint h = m_height;
|
||||
const uint h2 = h / 2;
|
||||
|
||||
for (uint c = 0; c < m_componentNum; c++) {
|
||||
for (uint y = 0; y < h2; y++) {
|
||||
float * src = scanline(y, c);
|
||||
float * dst = scanline(h - 1 - y, c);
|
||||
for (uint x = 0; x < w; x++) {
|
||||
swap(src[x], dst[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FloatImage* FloatImage::clone() const
|
||||
{
|
||||
FloatImage* copy = new FloatImage();
|
||||
|
@ -77,7 +77,6 @@ public:
|
||||
NVIMAGE_API FloatImage * resize(const Filter & filter, uint w, uint h, WrapMode wm) const;
|
||||
|
||||
NVIMAGE_API FloatImage * resize(const Filter & filter, uint w, uint h, WrapMode wm, uint alpha) const;
|
||||
//@}
|
||||
|
||||
NVIMAGE_API float applyKernel(const Kernel2 * k, int x, int y, uint c, WrapMode wm) const;
|
||||
NVIMAGE_API float applyKernelVertical(const Kernel1 * k, int x, int y, uint c, WrapMode wm) const;
|
||||
@ -86,7 +85,9 @@ public:
|
||||
NVIMAGE_API void applyKernelHorizontal(const PolyphaseKernel & k, int y, uint c, WrapMode wm, float * output) const;
|
||||
NVIMAGE_API void applyKernelVertical(const PolyphaseKernel & k, int x, uint c, uint a, WrapMode wm, float * output) const;
|
||||
NVIMAGE_API void applyKernelHorizontal(const PolyphaseKernel & k, int y, uint c, uint a, WrapMode wm, float * output) const;
|
||||
|
||||
|
||||
NVIMAGE_API void flip();
|
||||
//@}
|
||||
|
||||
uint width() const { return m_width; }
|
||||
uint height() const { return m_height; }
|
||||
|
@ -1086,3 +1086,14 @@ float TexImage::rootMeanSquaredError_alpha(const TexImage & reference) const
|
||||
return float(sqrt(mse / totalCount));
|
||||
}
|
||||
|
||||
void TexImage::flipVertically() {
|
||||
|
||||
detach();
|
||||
|
||||
foreach (i, m->imageArray)
|
||||
{
|
||||
if (m->imageArray[i] == NULL) continue;
|
||||
|
||||
m->imageArray[i]->flip();
|
||||
}
|
||||
}
|
@ -447,6 +447,9 @@ namespace nvtt
|
||||
NVTT_API float rootMeanSquaredError_rgb(const TexImage & reference) const;
|
||||
NVTT_API float rootMeanSquaredError_alpha(const TexImage & reference) const;
|
||||
|
||||
// Geometric transforms.
|
||||
NVTT_API void flipVertically();
|
||||
|
||||
private:
|
||||
void detach();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user