Support Forum       G3D Web Page     
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | 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 Color3 StorageType
 
typedef Image3 Type
 

Public Member Functions

Color3 average () const
 Returns the average value of all elements of the map. More...
 
Color3 bicubic (float x, float y, WrapMode wrap) const
 
Uses Catmull-Rom splines to interpolate between grid values. More...
 
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). More...
 
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). More...
 
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. More...
 
virtual void crop (const Rect2D &rect)
 iRounds to the nearest x0 and y0. More...
 
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. More...
 
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. More...
 
virtual void flipHorizontal ()
 
virtual void flipVertical ()
 
const class ImageFormatformat () const
 
const Color3get (int x, int y, WrapMode wrap) const
 Get the value at (x, y). More...
 
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. More...
 
const Array< Color3 > & getArray () const
 
Color3getCArray ()
 Returns a pointer to the underlying row-major data. More...
 
const Color3getCArray () const
 
int32 height () const
 Pixel height. More...
 
bool inBounds (int x, int y) const
 is (x, y) strictly within the image bounds, or will it trigger some kind of wrap mode More...
 
bool inBounds (const Vector2int16 &v) const
 is (x, y) strictly within the image bounds, or will it trigger some kind of wrap mode More...
 
void load (const String &filename)
 Loads from any of the file formats supported by G3D::GImage. More...
 
void maybeFlipVertical (bool flip)
 flips if flip is true More...
 
Color3 nearest (float x, float y, WrapMode wrap) const
 Returns the nearest neighbor. More...
 
Color3 nearest (float x, float y) const
 
Color3 nearest (const Vector2 &p) const
 
Rect2D rect2DBounds () const
 Rectangle from (0, 0) to (w, h) More...
 
void resize (uint32 newW, uint32 newH, uint32 newD=1)
 Resizes without clearing, leaving garbage. More...
 
void save (const String &filename)
 Saves in any of the formats supported by G3D::GImage. More...
 
void set (const Vector2int16 &p, const Color3 &v)
 Sets the changed flag to true. More...
 
void set (int x, int y, const Color3 &v, WrapMode wrap)
 Sets the changed flag to true. More...
 
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. More...
 
void setAll (const Color3 &v)
 
void setChanged (bool c)
 Set/unset the changed flag. More...
 
void setWrapMode (WrapMode m)
 
Vector2int16 size () const
 Dimensions in pixels. More...
 
size_t sizeInMemory () const
 Number of bytes occupied by the image data and this structure. More...
 
int32 width () const
 Pixel width. More...
 
WrapMode wrapMode () const
 

Static Public Member Functions

static shared_ptr< Map2D< Color3, Color3 > > create (int w=0, int h=0, WrapMode wrap=WrapMode::ERROR, int d=1)
 
static shared_ptr< Image3createEmpty (int width, int height, WrapMode wrap=WrapMode::ERROR, int depth=1)
 Creates an all-zero width x height image. More...
 
static shared_ptr< Image3createEmpty (WrapMode wrap=WrapMode::ERROR)
 Creates a 0 x 0 image. More...
 
static shared_ptr< Image3fromArray (const class Color1unorm8 *ptr, int width, int height, WrapMode wrap=WrapMode::ERROR, int depth=1)
 
static shared_ptr< Image3fromArray (const class Color3unorm8 *ptr, int width, int height, WrapMode wrap=WrapMode::ERROR, int depth=1)
 
static shared_ptr< Image3fromArray (const class Color4unorm8 *ptr, int width, int height, WrapMode wrap=WrapMode::ERROR, int depth=1)
 
static shared_ptr< Image3fromArray (const class Color1 *ptr, int width, int height, WrapMode wrap=WrapMode::ERROR, int depth=1)
 
static shared_ptr< Image3fromArray (const class Color3 *ptr, int width, int height, WrapMode wrap=WrapMode::ERROR, int depth=1)
 
static shared_ptr< Image3fromArray (const class Color4 *ptr, int width, int height, WrapMode wrap=WrapMode::ERROR, int depth=1)
 
static shared_ptr< Image3fromFile (const String &filename, WrapMode wrap=WrapMode::ERROR)
 
static shared_ptr< Image3fromImage3unorm8 (const shared_ptr< class Image3unorm8 > &im)
 
static float R (float x)
 

Public Attributes

std::mutex 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. More...
 

Protected Member Functions

 Image3 (int w=1, int h=1, WrapMode wrap=WrapMode::ERROR, int d=1)
 
void copyArray (const Color1 *src, int w, int h, int d=1)
 
void copyArray (const Color3 *src, int w, int h, int d=1)
 
void copyArray (const Color4 *src, int w, int h, int d=1)
 
void copyArray (const Color1unorm8 *src, int w, int h, int d=1)
 
void copyArray (const Color3unorm8 *src, int w, int h, int d=1)
 
void copyArray (const Color4unorm8 *src, int w, int h, int d=1)
 
const Color3slowGet (int x, int y, WrapMode wrap)
 Handles the exceptional cases from get. More...
 

Static Protected Member Functions

template<class T , class ... ArgTypes>
static shared_ptr< T > createShared (ArgTypes &&... args)
 Like std::make_shared, but works for protected constructors. More...
 

Protected Attributes

uint32 d
 Depth, in pixels, defaults to 1. More...
 
Array< Color3data
 
uint32 h
 Height, in pixels. More...
 
std::atomic_bool m_changed
 false if no mutating method has been invoked since the last call to setChanged(); More...
 
WrapMode m_wrapMode
 
uint32 w
 Width, in pixels. More...
 
Color3 ZERO
 

Friends

class CubeMap
 

Detailed Description


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

Can have depth (to be CPU versions of layered textures)

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

Member Typedef Documentation

◆ ComputeType

typedef Color3 G3D::Map2D< Color3 , Color3 >::ComputeType
inherited

◆ StorageType

typedef Color3 G3D::Map2D< Color3 , Color3 >::StorageType
inherited

◆ Type

Constructor & Destructor Documentation

◆ Image3()

G3D::Image3::Image3 ( int  w = 1,
int  h = 1,
WrapMode  wrap = WrapMode::ERROR,
int  d = 1 
)
protected

Member Function Documentation

◆ average()

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

Returns the average value of all elements of the map.

◆ bicubic() [1/4]

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


Uses Catmull-Rom splines to interpolate between grid values.

◆ bicubic() [2/4]

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

◆ bicubic() [3/4]

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

◆ bicubic() [4/4]

Color3 G3D::Map2D< Color3 , Color3 >::bicubic ( const Vector2 p) const
inlineinherited

◆ bilinear() [1/4]

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.

◆ bilinear() [2/4]

Color3 G3D::Map2D< Color3 , Color3 >::bilinear ( float  x,
float  y 
) const
inlineinherited

◆ bilinear() [3/4]

Color3 G3D::Map2D< Color3 , Color3 >::bilinear ( const Vector2 p) const
inlineinherited

◆ bilinear() [4/4]

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

◆ changed()

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.

◆ copyArray() [1/6]

void G3D::Image3::copyArray ( const Color1 src,
int  w,
int  h,
int  d = 1 
)
protected

◆ copyArray() [2/6]

void G3D::Image3::copyArray ( const Color3 src,
int  w,
int  h,
int  d = 1 
)
protected

◆ copyArray() [3/6]

void G3D::Image3::copyArray ( const Color4 src,
int  w,
int  h,
int  d = 1 
)
protected

◆ copyArray() [4/6]

void G3D::Image3::copyArray ( const Color1unorm8 src,
int  w,
int  h,
int  d = 1 
)
protected

◆ copyArray() [5/6]

void G3D::Image3::copyArray ( const Color3unorm8 src,
int  w,
int  h,
int  d = 1 
)
protected

◆ copyArray() [6/6]

void G3D::Image3::copyArray ( const Color4unorm8 src,
int  w,
int  h,
int  d = 1 
)
protected

◆ create()

static shared_ptr< Map2D<Color3 , Color3 > > G3D::Map2D< Color3 , Color3 >::create ( int  w = 0,
int  h = 0,
WrapMode  wrap = WrapMode::ERROR,
int  d = 1 
)
inlinestaticinherited

◆ createEmpty() [1/2]

static shared_ptr<Image3> G3D::Image3::createEmpty ( int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR,
int  depth = 1 
)
static

Creates an all-zero width x height image.

◆ createEmpty() [2/2]

static shared_ptr<Image3> G3D::Image3::createEmpty ( WrapMode  wrap = WrapMode::ERROR)
static

Creates a 0 x 0 image.

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ crop() [1/2]

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.

◆ crop() [2/2]

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

iRounds to the nearest x0 and y0.

◆ fastGet()

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.

◆ fastSet()

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.

◆ flipHorizontal()

virtual void G3D::Map2D< Color3 , Color3 >::flipHorizontal ( )
inlinevirtualinherited

◆ flipVertical()

virtual void G3D::Map2D< Color3 , Color3 >::flipVertical ( )
inlinevirtualinherited

◆ format()

const class ImageFormat* G3D::Image3::format ( ) const

◆ fromArray() [1/6]

static shared_ptr<Image3> G3D::Image3::fromArray ( const class Color1unorm8 ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR,
int  depth = 1 
)
static

◆ fromArray() [2/6]

static shared_ptr<Image3> G3D::Image3::fromArray ( const class Color3unorm8 ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR,
int  depth = 1 
)
static

◆ fromArray() [3/6]

static shared_ptr<Image3> G3D::Image3::fromArray ( const class Color4unorm8 ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR,
int  depth = 1 
)
static

◆ fromArray() [4/6]

static shared_ptr<Image3> G3D::Image3::fromArray ( const class Color1 ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR,
int  depth = 1 
)
static

◆ fromArray() [5/6]

static shared_ptr<Image3> G3D::Image3::fromArray ( const class Color3 ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR,
int  depth = 1 
)
static

◆ fromArray() [6/6]

static shared_ptr<Image3> G3D::Image3::fromArray ( const class Color4 ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR,
int  depth = 1 
)
static

◆ fromFile()

static shared_ptr<Image3> G3D::Image3::fromFile ( const String filename,
WrapMode  wrap = WrapMode::ERROR 
)
static

◆ fromImage3unorm8()

static shared_ptr<Image3> G3D::Image3::fromImage3unorm8 ( const shared_ptr< class Image3unorm8 > &  im)
static

◆ get() [1/7]

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.

◆ get() [2/7]

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

◆ get() [3/7]

const Color3 & G3D::Map2D< Color3 , Color3 >::get ( const Vector2int16 p) const
inlineinherited

◆ get() [4/7]

const Color3 & G3D::Map2D< Color3 , Color3 >::get ( const Vector2int16 p,
WrapMode  wrap 
) const
inlineinherited

◆ get() [5/7]

Color3 & G3D::Map2D< Color3 , Color3 >::get ( int  x,
int  y,
WrapMode  wrap 
)
inlineinherited

◆ get() [6/7]

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

◆ get() [7/7]

Color3 & G3D::Map2D< Color3 , Color3 >::get ( const Vector2int16 p)
inlineinherited

◆ getArray() [1/2]

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

Row-major array.

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

◆ getArray() [2/2]

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

◆ getCArray() [1/2]

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.

◆ getCArray() [2/2]

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

◆ height()

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

Pixel height.

◆ inBounds() [1/2]

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

◆ inBounds() [2/2]

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

◆ load()

void G3D::Image3::load ( const 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)

◆ maybeFlipVertical()

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

flips if flip is true

◆ nearest() [1/3]

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)

◆ nearest() [2/3]

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

◆ nearest() [3/3]

Color3 G3D::Map2D< Color3 , Color3 >::nearest ( const Vector2 p) const
inlineinherited

◆ R()

static float G3D::Map2D< Color3 , Color3 >::R ( float  x)
inlinestaticinherited

◆ rect2DBounds()

Rect2D G3D::Map2D< Color3 , Color3 >::rect2DBounds ( ) const
inlineinherited

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

◆ resize()

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

Resizes without clearing, leaving garbage.

◆ save()

void G3D::Image3::save ( const 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.

If depth >1, only saves the depth = 0 layer.

◆ set() [1/4]

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

Sets the changed flag to true.

◆ set() [2/4]

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

Sets the changed flag to true.

◆ set() [3/4]

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

◆ set() [4/4]

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

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

◆ setAll()

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

◆ setChanged()

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

Set/unset the changed flag.

◆ setWrapMode()

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

◆ size()

Vector2int16 G3D::Map2D< Color3 , Color3 >::size ( ) const
inlineinherited

Dimensions in pixels.

◆ sizeInMemory()

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

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

◆ slowGet()

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

Handles the exceptional cases from get.

◆ width()

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

Pixel width.

◆ wrapMode()

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

Friends And Related Function Documentation

◆ CubeMap

friend class CubeMap
friend

Member Data Documentation

◆ d

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

Depth, in pixels, defaults to 1.

◆ data

Array<Color3 > G3D::Map2D< Color3 , Color3 >::data
protectedinherited

◆ h

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

Height, in pixels.

◆ m_changed

std::atomic_bool G3D::Map2D< Color3 , Color3 >::m_changed
protectedinherited

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

◆ m_wrapMode

WrapMode G3D::Map2D< Color3 , Color3 >::m_wrapMode
protectedinherited

◆ mutex

std::mutex 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.

◆ w

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

Width, in pixels.

◆ ZERO

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

documentation generated on Wed Nov 24 2021 08:01:57 using doxygen 1.8.15