|
const Storage & | fastGet (int x, int y) const |
|
void | fastSet (int x, int y, const Storage &v) |
|
void | resize (uint32 newW, uint32 newH) |
|
bool | changed () |
|
void | setChanged (bool c) |
|
Storage * | getCArray () |
|
const Storage * | getCArray () const |
|
Array< Storage > & | getArray () |
|
const Array< Storage > & | getArray () const |
|
bool | inBounds (int x, int y) const |
|
bool | inBounds (const Vector2int16 &v) const |
|
const Storage & | get (int x, int y, WrapMode wrap) const |
|
const Storage & | get (int x, int y) const |
|
const Storage & | get (const Vector2int16 &p) const |
|
const Storage & | get (const Vector2int16 &p, WrapMode wrap) const |
|
Storage & | get (int x, int y, WrapMode wrap) |
|
Storage & | get (int x, int y) |
|
Storage & | get (const Vector2int16 &p) |
|
void | set (const Vector2int16 &p, const Storage &v) |
|
void | set (int x, int y, const Storage &v, WrapMode wrap) |
|
void | set (int x, int y, const Storage &v) |
|
void | setAll (const Storage &v) |
|
template<class T > |
void | set (const shared_ptr< Map2D< Storage, T > > &src) |
|
void | maybeFlipVertical (bool flip) |
|
virtual void | flipVertical () |
|
virtual void | flipHorizontal () |
|
virtual void | crop (int newX, int newY, int newW, int newH) |
|
virtual void | crop (const Rect2D &rect) |
|
Compute | nearest (float x, float y, WrapMode wrap) const |
|
Compute | nearest (float x, float y) const |
|
Compute | nearest (const Vector2 &p) const |
|
Compute | average () const |
|
Compute | bilinear (float x, float y, WrapMode wrap) const |
|
Compute | bilinear (float x, float y) const |
|
Compute | bilinear (const Vector2 &p) const |
|
Compute | bilinear (const Vector2 &p, WrapMode wrap) const |
|
Compute | bicubic (float x, float y, WrapMode wrap) const |
|
Compute | bicubic (float x, float y) const |
|
Compute | bicubic (const Vector2 &p, WrapMode wrap) const |
|
Compute | bicubic (const Vector2 &p) const |
|
int32 | width () const |
|
int32 | height () const |
|
Vector2int16 | size () const |
|
Rect2D | rect2DBounds () const |
|
size_t | sizeInMemory () const |
|
WrapMode | wrapMode () const |
|
void | setWrapMode (WrapMode m) |
|
virtual | ~ReferenceCountedObject () |
|
template<typename Storage, typename Compute = typename G3D::_internal::_GetComputeType<Storage>::Type>
class G3D::Map2D< Storage, Compute >
Map of values across a discrete 2D plane. Can be thought of as a generic class for 2D images, allowing flexibility as to pixel format and convenient methods. In fact, the "pixels" can be any values on a grid that can be sensibly interpolated–RGB colors, scalars, 4D vectors, and so on.
Other "image" classes in G3D:
G3D::GImage - Supports file formats, fast, Color3uint8 and Color4uint8 formats. No interpolation.
G3D::shared_ptr<Texture> - Represents image on the graphics card (not directly readable on the CPU). Supports 2D, 3D, and a variety of interpolation methods, loads file formats.
G3D::Image3 - A subclass of Map2D<Color3> that supports image loading and saving and conversion to Texture.
G3D::Image4 - A subclass of Map2D<Color4> that supports image loading and saving and conversion to Texture.
G3D::Image3uint8 - A subclass of Map2D<Color3uint8> that supports image loading and saving and conversion to Texture.
G3D::Image4uint8 - A subclass of Map2D<Color4uint8> that supports image loading and saving and conversion to Texture.
There are two type parameters– the first (@ Storage) is the type used to store the "pixel" values efficiently and the second (Compute) is the type operated on by computation. The Compute::Compute(Storage&) constructor is used to convert between storage and computation types. Storage is often an integer version of Compute, for example Map2D<double, uint8>
. By default, the computation type is:
Storage Computation
uint8 float32
uint16 float32
uint32 float64
uint64 float64
int8 float32
int16 float32
int32 float64
int64 float64
float32 float64
float64 float64
Vector2 Vector2
Vector2int16 Vector2
Vector3 Vector3
Vector3int16 Vector3
Vector4 Vector4
Color3 Color3
Color3uint8 Color3
Color4 Color4
Color4uint8 Color4
Any other storage type defaults to itself as the computation type.
The computation type can be any that supports lerp, +, -, *, /, and an empty constructor.
Assign value:
im->set(x, y, 7);
or im->get(x, y) = 7;
Read value:
int c = im(x, y);
Can also sample with nearest neighbor, bilinear, and bicubic interpolation.
Sampling follows OpenGL conventions, where pixel values represent grid points and (0.5, 0.5) is half-way between two vertical and two horizontal grid points. To draw an image of dimensions w x h with nearest neighbor sampling, render pixels from [0, 0] to [w - 1, h - 1].
Under the WrapMode::CLAMP wrap mode, the value of bilinear interpolation becomes constant outside [1, w - 2] horizontally. Nearest neighbor interpolation is constant outside [0, w - 1] and bicubic outside [3, w - 4]. The class does not offer quadratic interpolation because the interpolation filter could not center over a pixel.
- Author
- Morgan McGuire, http://graphics.cs.williams.edu