Create 2.0.5 release.

This commit is contained in:
castano
2008-12-01 08:11:43 +00:00
parent a30490ab9b
commit 81a40d8abc
229 changed files with 3431 additions and 19484 deletions

View File

@ -1,15 +1,14 @@
// This code is in the public domain -- castanyo@yahoo.es
#include <nvcore/Containers.h>
#include <nvcore/Ptr.h>
#include <nvmath/Color.h>
#include "FloatImage.h"
#include "Filter.h"
#include "Image.h"
#include <nvmath/Color.h>
#include <nvmath/Matrix.h>
#include <nvcore/Containers.h>
#include <nvcore/Ptr.h>
#include <math.h>
using namespace nv;
@ -141,8 +140,7 @@ Image * FloatImage::createImageGammaCorrect(float gamma/*= 2.2f*/) const
/// Allocate a 2d float image of the given format and the given extents.
void FloatImage::allocate(uint c, uint w, uint h)
{
free();
nvCheck(m_mem == NULL);
m_width = w;
m_height = h;
m_componentNum = c;
@ -153,6 +151,7 @@ void FloatImage::allocate(uint c, uint w, uint h)
/// Free the image, but don't clear the members.
void FloatImage::free()
{
nvCheck(m_mem != NULL);
nv::mem::free( reinterpret_cast<void *>(m_mem) );
m_mem = NULL;
}
@ -241,57 +240,6 @@ void FloatImage::exponentiate(uint base_component, uint num, float power)
}
}
/// Apply linear transform.
void FloatImage::transform(uint base_component, const Matrix & m, Vector4::Arg offset)
{
nvCheck(base_component + 4 <= m_componentNum);
const uint size = m_width * m_height;
float * r = this->channel(base_component + 0);
float * g = this->channel(base_component + 1);
float * b = this->channel(base_component + 2);
float * a = this->channel(base_component + 3);
for (uint i = 0; i < size; i++)
{
Vector4 color = nv::transform(m, Vector4(*r, *g, *b, *a)) + offset;
*r++ = color.x();
*g++ = color.y();
*b++ = color.z();
*a++ = color.w();
}
}
void FloatImage::swizzle(uint base_component, uint r, uint g, uint b, uint a)
{
nvCheck(base_component + 4 <= m_componentNum);
nvCheck(r < 7 && g < 7 && b < 7 && a < 7);
const uint size = m_width * m_height;
float consts[] = { 1.0f, 0.0f, -1.0f };
float * c[7];
c[0] = this->channel(base_component + 0);
c[1] = this->channel(base_component + 1);
c[2] = this->channel(base_component + 2);
c[3] = this->channel(base_component + 3);
c[4] = consts;
c[5] = consts + 1;
c[6] = consts + 2;
for (uint i = 0; i < size; i++)
{
float tmp[4] = { *c[r], *c[g], *c[b], *c[a] };
*c[0]++ = tmp[0];
*c[1]++ = tmp[1];
*c[2]++ = tmp[2];
*c[3]++ = tmp[3];
}
}
float FloatImage::sampleNearest(const float x, const float y, const int c, const WrapMode wm) const
{
if( wm == WrapMode_Clamp ) return sampleNearestClamp(x, y, c);
@ -633,7 +581,7 @@ FloatImage * FloatImage::resize(const Filter & filter, uint w, uint h, WrapMode
float * dst_channel = dst_image->channel(c);
for (uint x = 0; x < w; x++) {
tmp_image->applyKernelVertical(ykernel, x, c, wm, tmp_column.mutableBuffer());
tmp_image->applyKernelVertical(ykernel, x, c, wm, tmp_column.unsecureBuffer());
for (uint y = 0; y < h; y++) {
dst_channel[y * w + x] = tmp_column[y];
@ -654,7 +602,7 @@ FloatImage * FloatImage::resize(const Filter & filter, uint w, uint h, WrapMode
float * tmp_channel = tmp_image->channel(c);
for (uint x = 0; x < w; x++) {
tmp_image->applyKernelVertical(ykernel, x, c, wm, tmp_column.mutableBuffer());
tmp_image->applyKernelVertical(ykernel, x, c, wm, tmp_column.unsecureBuffer());
for (uint y = 0; y < h; y++) {
tmp_channel[y * w + x] = tmp_column[y];
@ -812,20 +760,3 @@ void FloatImage::applyKernelHorizontal(const PolyphaseKernel & k, int y, int c,
}
}
FloatImage* FloatImage::clone() const
{
FloatImage* copy = new FloatImage();
copy->m_width = m_width;
copy->m_height = m_height;
copy->m_componentNum = m_componentNum;
copy->m_count = m_count;
if(m_mem)
{
copy->allocate(m_componentNum, m_width, m_height);
memcpy(copy->m_mem, m_mem, m_count * sizeof(float));
}
return copy;
}