Support Forum       Library Source       SourceForge Page       G3D Web Page     
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
G3D::Image3 Class Reference

RGB image with 32-bit floating point storage for each channel. More...

Inherits G3D::Map2D< Color3, Color3 >.

Public Types

typedef Color3 ComputeType
 
typedef shared_ptr< class Image3Ref
 
typedef Color3 StorageType
 
typedef Image3 Type
 

Public Member Functions

Color3 average () const
 Returns the average value of all elements of the map.
 
Color3 bicubic (float x, float y, WrapMode wrap) const
 Uses Catmull-Rom splines to interpolate between grid values.
 
Color3 bicubic (float x, float y) const
 
Color3 bicubic (const Vector2 &p, WrapMode wrap) const
 
Color3 bicubic (const Vector2 &p) const
 
Color3 bilinear (float x, float y, WrapMode wrap) const
 Needs to access elements from (floor(x), floor(y)) to (floor(x) + 1, floor(y) + 1) and will use the wrap mode appropriately (possibly generating out of bounds errors).
 
Color3 bilinear (float x, float y) const
 
Color3 bilinear (const Vector2 &p) const
 
Color3 bilinear (const Vector2 &p, WrapMode wrap) const
 
bool changed ()
 Returns true if this map has been written to since the last call to setChanged(false).
 
virtual void crop (int newX, int newY, int newW, int newH)
 Crops this map so that it only contains pixels between (x, y) and (x + w - 1, y + h - 1) inclusive.
 
virtual void crop (const Rect2D &rect)
 iRounds to the nearest x0 and y0.
 
const Color3fastGet (int x, int y) const
 Unsafe access to the underlying data structure with no wrapping support; requires that (x, y) is in bounds.
 
void fastSet (int x, int y, const Color3 &v)
 Unsafe access to the underlying data structure with no wrapping support; requires that (x, y) is in bounds.
 
virtual void flipHorizontal ()
 
virtual void flipVertical ()
 
class ImageFormatformat () const
 
const Color3get (int x, int y, WrapMode wrap) const
 Get the value at (x, y).
 
const Color3get (int x, int y) const
 
const Color3get (const Vector2int16 &p) const
 
const Color3get (const Vector2int16 &p, WrapMode wrap) const
 
Color3get (int x, int y, WrapMode wrap)
 
Color3get (int x, int y)
 
Color3get (const Vector2int16 &p)
 
Array< Color3 > & getArray ()
 Row-major array.
 
const Array< Color3 > & getArray () const
 
Color3getCArray ()
 Returns a pointer to the underlying row-major data.
 
const Color3getCArray () const
 
int32 height () const
 Pixel height.
 
bool inBounds (int x, int y) const
 is (x, y) strictly within the image bounds, or will it trigger some kind of wrap mode
 
bool inBounds (const Vector2int16 &v) const
 is (x, y) strictly within the image bounds, or will it trigger some kind of wrap mode
 
void load (const std::string &filename)
 Loads from any of the file formats supported by G3D::GImage.
 
void maybeFlipVertical (bool flip)
 flips if flip is true
 
Color3 nearest (float x, float y, WrapMode wrap) const
 Returns the nearest neighbor.
 
Color3 nearest (float x, float y) const
 
Color3 nearest (const Vector2 &p) const
 
Rect2D rect2DBounds () const
 Rectangle from (0, 0) to (w, h)
 
void resize (uint32 newW, uint32 newH)
 Resizes without clearing, leaving garbage.
 
void save (const std::string &filename)
 Saves in any of the formats supported by G3D::GImage.
 
void set (const Vector2int16 &p, const Color3 &v)
 Sets the changed flag to true.
 
void set (int x, int y, const Color3 &v, WrapMode wrap)
 Sets the changed flag to true.
 
void set (int x, int y, const Color3 &v)
 
void set (const shared_ptr< Map2D< Color3, T > > &src)
 Copy values from src, which must have the same size.
 
void setAll (const Color3 &v)
 
void setChanged (bool c)
 Set/unset the changed flag.
 
void setWrapMode (WrapMode m)
 
Vector2int16 size () const
 Dimensions in pixels.
 
size_t sizeInMemory () const
 Number of bytes occupied by the image data and this structure.
 
int32 width () const
 Pixel width.
 
WrapMode wrapMode () const
 

Static Public Member Functions

static Ref create (int w=0, int h=0, WrapMode wrap=WrapMode::ERROR)
 
static Ref createEmpty (int width, int height, WrapMode wrap=WrapMode::ERROR)
 Creates an all-zero width x height image.
 
static Ref createEmpty (WrapMode wrap=WrapMode::ERROR)
 Creates a 0 x 0 image.
 
static Ref fromArray (const class Color1unorm8 *ptr, int width, int height, WrapMode wrap=WrapMode::ERROR)
 
static Ref fromArray (const class Color3unorm8 *ptr, int width, int height, WrapMode wrap=WrapMode::ERROR)
 
static Ref fromArray (const class Color4unorm8 *ptr, int width, int height, WrapMode wrap=WrapMode::ERROR)
 
static Ref fromArray (const class Color1 *ptr, int width, int height, WrapMode wrap=WrapMode::ERROR)
 
static Ref fromArray (const class Color3 *ptr, int width, int height, WrapMode wrap=WrapMode::ERROR)
 
static Ref fromArray (const class Color4 *ptr, int width, int height, WrapMode wrap=WrapMode::ERROR)
 
static Ref fromFile (const std::string &filename, WrapMode wrap=WrapMode::ERROR)
 
static Ref fromImage3unorm8 (const shared_ptr< class Image3unorm8 > &im)
 

Public Attributes

GMutex mutex
 Although Map2D is not threadsafe (except for the setChanged() method), you can use this mutex to create your own threadsafe access to a Map2D.
 

Protected Member Functions

 Image3 (int w, int h, WrapMode wrap)
 
Color3 bicubic (const Color3 *ctrl, double s) const
 Given four control points and a value on the range [0, 1) evaluates the Catmull-rom spline between the times of the middle two control points.
 
void copyArray (const Color1 *src, int w, int h)
 
void copyArray (const Color3 *src, int w, int h)
 
void copyArray (const Color4 *src, int w, int h)
 
void copyArray (const Color1unorm8 *src, int w, int h)
 
void copyArray (const Color3unorm8 *src, int w, int h)
 
void copyArray (const Color4unorm8 *src, int w, int h)
 
const Color3slowGet (int x, int y, WrapMode wrap)
 Handles the exceptional cases from get.
 

Protected Attributes

WrapMode _wrapMode
 
Array< Color3data
 
uint32 h
 Height, in pixels.
 
AtomicInt32 m_changed
 0 if no mutating method has been invoked since the last call to setChanged();
 
uint32 w
 Width, in pixels.
 
Color3 ZERO
 

Detailed Description

RGB image with 32-bit floating point storage for each channel.

See also G3D::Image3unorm8, G3D::GImage.

Member Typedef Documentation

typedef Color3 G3D::Map2D< Color3 , Color3 >::ComputeType
inherited
typedef shared_ptr<class Image3> G3D::Image3::Ref
typedef Color3 G3D::Map2D< Color3 , Color3 >::StorageType
inherited

Constructor & Destructor Documentation

G3D::Image3::Image3 ( int  w,
int  h,
WrapMode  wrap 
)
protected

Member Function Documentation

Color3 G3D::Map2D< Color3 , Color3 >::average ( ) const
inlineinherited

Returns the average value of all elements of the map.

Color3 G3D::Map2D< Color3 , Color3 >::bicubic ( const Color3 ctrl,
double  s 
) const
inlineprotectedinherited

Given four control points and a value on the range [0, 1) evaluates the Catmull-rom spline between the times of the middle two control points.

Color3 G3D::Map2D< Color3 , Color3 >::bicubic ( float  x,
float  y,
WrapMode  wrap 
) const
inlineinherited

Uses Catmull-Rom splines to interpolate between grid values.

Guaranteed to match nearest(x, y) at integers.

Color3 G3D::Map2D< Color3 , Color3 >::bicubic ( float  x,
float  y 
) const
inlineinherited
Color3 G3D::Map2D< Color3 , Color3 >::bicubic ( const Vector2 p,
WrapMode  wrap 
) const
inlineinherited
Color3 G3D::Map2D< Color3 , Color3 >::bicubic ( const Vector2 p) const
inlineinherited
Color3 G3D::Map2D< Color3 , Color3 >::bilinear ( float  x,
float  y,
WrapMode  wrap 
) const
inlineinherited

Needs to access elements from (floor(x), floor(y)) to (floor(x) + 1, floor(y) + 1) and will use the wrap mode appropriately (possibly generating out of bounds errors).

Guaranteed to match nearest(x, y) at integers.

Color3 G3D::Map2D< Color3 , Color3 >::bilinear ( float  x,
float  y 
) const
inlineinherited
Color3 G3D::Map2D< Color3 , Color3 >::bilinear ( const Vector2 p) const
inlineinherited
Color3 G3D::Map2D< Color3 , Color3 >::bilinear ( const Vector2 p,
WrapMode  wrap 
) const
inlineinherited
bool G3D::Map2D< Color3 , Color3 >::changed ( )
inlineinherited

Returns true if this map has been written to since the last call to setChanged(false).

This is useful if you are caching a texture map other value that must be recomputed whenever this changes.

void G3D::Image3::copyArray ( const Color1 src,
int  w,
int  h 
)
protected
void G3D::Image3::copyArray ( const Color3 src,
int  w,
int  h 
)
protected
void G3D::Image3::copyArray ( const Color4 src,
int  w,
int  h 
)
protected
void G3D::Image3::copyArray ( const Color1unorm8 *  src,
int  w,
int  h 
)
protected
void G3D::Image3::copyArray ( const Color3unorm8 *  src,
int  w,
int  h 
)
protected
void G3D::Image3::copyArray ( const Color4unorm8 *  src,
int  w,
int  h 
)
protected
static Ref G3D::Map2D< Color3 , Color3 >::create ( int  w = 0,
int  h = 0,
WrapMode  wrap = WrapMode::ERROR 
)
inlinestaticinherited
static Ref G3D::Image3::createEmpty ( int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static

Creates an all-zero width x height image.

static Ref G3D::Image3::createEmpty ( WrapMode  wrap = WrapMode::ERROR)
static

Creates a 0 x 0 image.

virtual void G3D::Map2D< Color3 , Color3 >::crop ( int  newX,
int  newY,
int  newW,
int  newH 
)
inlinevirtualinherited

Crops this map so that it only contains pixels between (x, y) and (x + w - 1, y + h - 1) inclusive.

virtual void G3D::Map2D< Color3 , Color3 >::crop ( const Rect2D rect)
inlinevirtualinherited

iRounds to the nearest x0 and y0.

const Color3 & G3D::Map2D< Color3 , Color3 >::fastGet ( int  x,
int  y 
) const
inlineinherited

Unsafe access to the underlying data structure with no wrapping support; requires that (x, y) is in bounds.

void G3D::Map2D< Color3 , Color3 >::fastSet ( int  x,
int  y,
const Color3 v 
)
inlineinherited

Unsafe access to the underlying data structure with no wrapping support; requires that (x, y) is in bounds.

virtual void G3D::Map2D< Color3 , Color3 >::flipHorizontal ( )
inlinevirtualinherited
virtual void G3D::Map2D< Color3 , Color3 >::flipVertical ( )
inlinevirtualinherited
class ImageFormat* G3D::Image3::format ( ) const
static Ref G3D::Image3::fromArray ( const class Color1unorm8 *  ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static
static Ref G3D::Image3::fromArray ( const class Color3unorm8 *  ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static
static Ref G3D::Image3::fromArray ( const class Color4unorm8 *  ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static
static Ref G3D::Image3::fromArray ( const class Color1 ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static
static Ref G3D::Image3::fromArray ( const class Color3 ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static
static Ref G3D::Image3::fromArray ( const class Color4 ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static
static Ref G3D::Image3::fromFile ( const std::string filename,
WrapMode  wrap = WrapMode::ERROR 
)
static
static Ref G3D::Image3::fromImage3unorm8 ( const shared_ptr< class Image3unorm8 > &  im)
static
const Color3 & G3D::Map2D< Color3 , Color3 >::get ( int  x,
int  y,
WrapMode  wrap 
) const
inlineinherited

Get the value at (x, y).

Note that the type of image->get(x, y) is the storage type, not the computation type. If the constructor promoting Storage to Compute rescales values (as, for example Color3(Color3uint8&) does), this will not match the value returned by Map2D::nearest.

const Color3 & G3D::Map2D< Color3 , Color3 >::get ( int  x,
int  y 
) const
inlineinherited
const Color3 & G3D::Map2D< Color3 , Color3 >::get ( const Vector2int16 p) const
inlineinherited
const Color3 & G3D::Map2D< Color3 , Color3 >::get ( const Vector2int16 p,
WrapMode  wrap 
) const
inlineinherited
Color3 & G3D::Map2D< Color3 , Color3 >::get ( int  x,
int  y,
WrapMode  wrap 
)
inlineinherited
Color3 & G3D::Map2D< Color3 , Color3 >::get ( int  x,
int  y 
)
inlineinherited
Color3 & G3D::Map2D< Color3 , Color3 >::get ( const Vector2int16 p)
inlineinherited
Array<Color3 >& G3D::Map2D< Color3 , Color3 >::getArray ( )
inlineinherited

Row-major array.

You should call setChanged(true) if you mutate the array.

const Array<Color3 >& G3D::Map2D< Color3 , Color3 >::getArray ( ) const
inlineinherited
Color3 * G3D::Map2D< Color3 , Color3 >::getCArray ( )
inlineinherited

Returns a pointer to the underlying row-major data.

There is no padding at the end of the row. Be careful–this will be reallocated during a resize. You should call setChanged(true) if you mutate the array.

const Color3 * G3D::Map2D< Color3 , Color3 >::getCArray ( ) const
inlineinherited
int32 G3D::Map2D< Color3 , Color3 >::height ( ) const
inlineinherited

Pixel height.

bool G3D::Map2D< Color3 , Color3 >::inBounds ( int  x,
int  y 
) const
inlineinherited

is (x, y) strictly within the image bounds, or will it trigger some kind of wrap mode

bool G3D::Map2D< Color3 , Color3 >::inBounds ( const Vector2int16 v) const
inlineinherited

is (x, y) strictly within the image bounds, or will it trigger some kind of wrap mode

void G3D::Image3::load ( const std::string filename)

Loads from any of the file formats supported by G3D::GImage.

If there is an alpha channel on the input, it is stripped. Converts 8-bit formats to the range (0, 1)

void G3D::Map2D< Color3 , Color3 >::maybeFlipVertical ( bool  flip)
inlineinherited

flips if flip is true

Color3 G3D::Map2D< Color3 , Color3 >::nearest ( float  x,
float  y,
WrapMode  wrap 
) const
inlineinherited

Returns the nearest neighbor.

Pixel values are considered to be at the upper left corner, so image->nearest(x, y) == image(x, y)

Color3 G3D::Map2D< Color3 , Color3 >::nearest ( float  x,
float  y 
) const
inlineinherited
Color3 G3D::Map2D< Color3 , Color3 >::nearest ( const Vector2 p) const
inlineinherited
Rect2D G3D::Map2D< Color3 , Color3 >::rect2DBounds ( ) const
inlineinherited

Rectangle from (0, 0) to (w, h)

void G3D::Map2D< Color3 , Color3 >::resize ( uint32  newW,
uint32  newH 
)
inlineinherited

Resizes without clearing, leaving garbage.

void G3D::Image3::save ( const std::string filename)

Saves in any of the formats supported by G3D::GImage.

Assumes the data is on the range (0, 1) if saving to an 8-bit format.

void G3D::Map2D< Color3 , Color3 >::set ( const Vector2int16 p,
const Color3 v 
)
inlineinherited

Sets the changed flag to true.

void G3D::Map2D< Color3 , Color3 >::set ( int  x,
int  y,
const Color3 v,
WrapMode  wrap 
)
inlineinherited

Sets the changed flag to true.

void G3D::Map2D< Color3 , Color3 >::set ( int  x,
int  y,
const Color3 v 
)
inlineinherited
void G3D::Map2D< Color3 , Color3 >::set ( const shared_ptr< Map2D< Color3 , T > > &  src)
inlineinherited

Copy values from src, which must have the same size.

void G3D::Map2D< Color3 , Color3 >::setAll ( const Color3 v)
inlineinherited
void G3D::Map2D< Color3 , Color3 >::setChanged ( bool  c)
inlineinherited

Set/unset the changed flag.

void G3D::Map2D< Color3 , Color3 >::setWrapMode ( WrapMode  m)
inlineinherited
Vector2int16 G3D::Map2D< Color3 , Color3 >::size ( ) const
inlineinherited

Dimensions in pixels.

size_t G3D::Map2D< Color3 , Color3 >::sizeInMemory ( ) const
inlineinherited

Number of bytes occupied by the image data and this structure.

const Color3 & G3D::Map2D< Color3 , Color3 >::slowGet ( int  x,
int  y,
WrapMode  wrap 
)
inlineprotectedinherited

Handles the exceptional cases from get.

int32 G3D::Map2D< Color3 , Color3 >::width ( ) const
inlineinherited

Pixel width.

WrapMode G3D::Map2D< Color3 , Color3 >::wrapMode ( ) const
inlineinherited

Member Data Documentation

WrapMode G3D::Map2D< Color3 , Color3 >::_wrapMode
protectedinherited
Array<Color3 > G3D::Map2D< Color3 , Color3 >::data
protectedinherited
uint32 G3D::Map2D< Color3 , Color3 >::h
protectedinherited

Height, in pixels.

AtomicInt32 G3D::Map2D< Color3 , Color3 >::m_changed
protectedinherited

0 if no mutating method has been invoked since the last call to setChanged();

GMutex G3D::Map2D< Color3 , Color3 >::mutex
inherited

Although Map2D is not threadsafe (except for the setChanged() method), you can use this mutex to create your own threadsafe access to a Map2D.

Not used by the default implementation.

uint32 G3D::Map2D< Color3 , Color3 >::w
protectedinherited

Width, in pixels.

Color3 G3D::Map2D< Color3 , Color3 >::ZERO
protectedinherited

documentation generated on Sat Jan 12 2013 22:49:55 using doxygen 1.8.2