TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
G3D::Image1 Class Reference

#include <Image1.h>

Public Types

typedef Image1 Type
 
typedef shared_ptr< class Image1Ref
 
typedef Color1 Storage
 
typedef Color1 Compute
 
- Public Types inherited from G3D::Map2D< Color1, Color1 >
typedef Color1 StorageType
 
typedef Color1 ComputeType
 
typedef Map2D< Color1, Color1Type
 
typedef shared_ptr< Map2DRef
 

Public Member Functions

const class ImageFormatformat () const
 
void load (const std::string &filename)
 
void save (const std::string &filename)
 
- Public Member Functions inherited from G3D::Map2D< Color1, Color1 >
const Color1fastGet (int x, int y) const
 
void fastSet (int x, int y, const Color1 &v)
 
Color1 bicubic (float x, float y, WrapMode wrap) const
 
Color1 bicubic (float x, float y) const
 
Color1 bicubic (const Vector2 &p, WrapMode wrap) const
 
Color1 bicubic (const Vector2 &p) const
 
void resize (uint32 newW, uint32 newH)
 
bool changed ()
 
void setChanged (bool c)
 
Color1getCArray ()
 
const Color1getCArray () const
 
Array< Color1 > & getArray ()
 
const Array< Color1 > & getArray () const
 
bool inBounds (int x, int y) const
 
bool inBounds (const Vector2int16 &v) const
 
const Color1get (int x, int y, WrapMode wrap) const
 
const Color1get (int x, int y) const
 
const Color1get (const Vector2int16 &p) const
 
const Color1get (const Vector2int16 &p, WrapMode wrap) const
 
Color1get (int x, int y, WrapMode wrap)
 
Color1get (int x, int y)
 
Color1get (const Vector2int16 &p)
 
void set (const Vector2int16 &p, const Color1 &v)
 
void set (int x, int y, const Color1 &v, WrapMode wrap)
 
void set (int x, int y, const Color1 &v)
 
void set (const shared_ptr< Map2D< Color1, T > > &src)
 
void setAll (const Color1 &v)
 
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)
 
Color1 nearest (float x, float y, WrapMode wrap) const
 
Color1 nearest (float x, float y) const
 
Color1 nearest (const Vector2 &p) const
 
Color1 average () const
 
Color1 bilinear (float x, float y, WrapMode wrap) const
 
Color1 bilinear (float x, float y) const
 
Color1 bilinear (const Vector2 &p) const
 
Color1 bilinear (const Vector2 &p, WrapMode wrap) const
 
int32 width () const
 
int32 height () const
 
Vector2int16 size () const
 
Rect2D rect2DBounds () const
 
size_t sizeInMemory () const
 
WrapMode wrapMode () const
 
void setWrapMode (WrapMode m)
 
- Public Member Functions inherited from G3D::ReferenceCountedObject
virtual ~ReferenceCountedObject ()
 

Static Public Member Functions

static Ref createEmpty (int width, int height, WrapMode wrap=WrapMode::ERROR)
 
static Ref createEmpty (WrapMode wrap=WrapMode::ERROR)
 
static Ref fromFile (const std::string &filename, WrapMode wrap=WrapMode::ERROR)
 
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 fromImage1unorm8 (const shared_ptr< class Image1unorm8 > &im)
 
- Static Public Member Functions inherited from G3D::Map2D< Color1, Color1 >
static Ref create (int w=0, int h=0, WrapMode wrap=WrapMode::ERROR)
 

Protected Member Functions

 Image1 (int w, int h, WrapMode wrap)
 
void copyGImage (const class GImage &im)
 
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)
 
- Protected Member Functions inherited from G3D::Map2D< Color1, Color1 >
const Color1slowGet (int x, int y, WrapMode wrap)
 
Color1 bicubic (const Color1 *ctrl, double s) const
 
 Map2D (int w, int h, WrapMode wrap)
 

Additional Inherited Members

- Public Attributes inherited from G3D::Map2D< Color1, Color1 >
GMutex mutex
 
- Protected Attributes inherited from G3D::Map2D< Color1, Color1 >
Color1 ZERO
 
uint32 w
 
uint32 h
 
WrapMode _wrapMode
 
AtomicInt32 m_changed
 
Array< Color1data
 

Detailed Description

Luminance image with 32-bit floating point storage.

See also G3D::Image1unorm8, G3D::GImage.

Member Typedef Documentation

typedef shared_ptr<class Image1> G3D::Image1::Ref

Constructor & Destructor Documentation

G3D::Image1::Image1 ( int  w,
int  h,
WrapMode  wrap 
)
protected
24  : Map2D<Color1, Color1>(w, h, wrap) {
25  setAll(Color1(0.0f));
26 }
float wrap(float t, float lo, float hi)
Definition: g3dmath.h:495
uint32 h
Definition: Map2D.h:194
void setAll(const Color1 &v)
Definition: Map2D.h:437
uint32 w
Definition: Map2D.h:191

+ Here is the call graph for this function:

Member Function Documentation

void G3D::Image1::copyArray ( const Color1 src,
int  w,
int  h 
)
protected
161  {
162  resize(w, h);
163  System::memcpy(getCArray(), src, w * h * sizeof(Color1));
164 }
static void memcpy(void *dst, const void *src, size_t numBytes)
Definition: System.cpp:643
uint32 h
Definition: Map2D.h:194
uint32 w
Definition: Map2D.h:191
Color1 * getCArray()
Definition: Map2D.h:329
void resize(uint32 newW, uint32 newH)
Definition: Map2D.h:304

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void G3D::Image1::copyArray ( const Color3 src,
int  w,
int  h 
)
protected
191  {
192  resize(w, h);
193  int N = w * h;
194 
195  Color1* dst = getCArray();
196  for (int i = 0; i < N; ++i) {
197  dst[i] = Color1(src[i].average());
198  }
199 }
Color1 average() const
Definition: Map2D.h:539
uint32 h
Definition: Map2D.h:194
uint32 w
Definition: Map2D.h:191
Color1 * getCArray()
Definition: Map2D.h:329
void resize(uint32 newW, uint32 newH)
Definition: Map2D.h:304

+ Here is the call graph for this function:

void G3D::Image1::copyArray ( const Color4 src,
int  w,
int  h 
)
protected
167  {
168  resize(w, h);
169 
170  int N = w * h;
171  Color1* dst = data.getCArray();
172 
173  // Strip alpha
174  for (int i = 0; i < N; ++i) {
175  dst[i] = Color1(src[i].rgb().average());
176  }
177 }
Color1 average() const
Definition: Map2D.h:539
Array< Color1 > data
Definition: Map2D.h:202
T * getCArray()
Definition: Array.h:256
uint32 h
Definition: Map2D.h:194
uint32 w
Definition: Map2D.h:191
void resize(uint32 newW, uint32 newH)
Definition: Map2D.h:304

+ Here is the call graph for this function:

void G3D::Image1::copyArray ( const Color1unorm8 *  src,
int  w,
int  h 
)
protected
180  {
181  resize(w, h);
182  int N = w * h;
183 
184  Color1* dst = getCArray();
185  for (int i = 0; i < N; ++i) {
186  dst[i]= Color1(src[i]);
187  }
188 }
uint32 h
Definition: Map2D.h:194
uint32 w
Definition: Map2D.h:191
Color1 * getCArray()
Definition: Map2D.h:329
void resize(uint32 newW, uint32 newH)
Definition: Map2D.h:304

+ Here is the call graph for this function:

void G3D::Image1::copyArray ( const Color3unorm8 *  src,
int  w,
int  h 
)
protected
136  {
137  resize(w, h);
138 
139  int N = w * h;
140  Color1* dst = data.getCArray();
141  // Convert int8 -> float
142  for (int i = 0; i < N; ++i) {
143  dst[i] = Color1(Color3(src[i]).average());
144  }
145 }
Color1 average() const
Definition: Map2D.h:539
Array< Color1 > data
Definition: Map2D.h:202
T * getCArray()
Definition: Array.h:256
uint32 h
Definition: Map2D.h:194
uint32 w
Definition: Map2D.h:191
void resize(uint32 newW, uint32 newH)
Definition: Map2D.h:304

+ Here is the call graph for this function:

void G3D::Image1::copyArray ( const Color4unorm8 *  src,
int  w,
int  h 
)
protected
148  {
149  resize(w, h);
150 
151  int N = w * h;
152  Color1* dst = data.getCArray();
153 
154  // Strip alpha and convert
155  for (int i = 0; i < N; ++i) {
156  dst[i] = Color1(Color3(src[i].rgb()).average());
157  }
158 }
Color1 average() const
Definition: Map2D.h:539
Array< Color1 > data
Definition: Map2D.h:202
T * getCArray()
Definition: Array.h:256
uint32 h
Definition: Map2D.h:194
uint32 w
Definition: Map2D.h:191
void resize(uint32 newW, uint32 newH)
Definition: Map2D.h:304

+ Here is the call graph for this function:

void G3D::Image1::copyGImage ( const class GImage &  im)
protected
Image1::Ref G3D::Image1::createEmpty ( int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static

Creates an all-zero width x height image.

43  {
44  return Image1::Ref(new Type(width, height, wrap));
45 }
int32 height() const
Definition: Map2D.h:645
shared_ptr< class Image1 > Ref
Definition: Image1.h:31
float wrap(float t, float lo, float hi)
Definition: g3dmath.h:495
int32 width() const
Definition: Map2D.h:639
Image1 Type
Definition: Image1.h:30

+ Here is the caller graph for this function:

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

Creates a 0 x 0 image.

48  {
49  return createEmpty(0, 0, wrap);
50 }
static Ref createEmpty(int width, int height, WrapMode wrap=WrapMode::ERROR)
Definition: Image1.cpp:43
float wrap(float t, float lo, float hi)
Definition: g3dmath.h:495

+ Here is the call graph for this function:

const ImageFormat * G3D::Image1::format ( ) const
209  {
210  return ImageFormat::L32F();
211 }
static const ImageFormat * L32F()

+ Here is the call graph for this function:

Image1::Ref G3D::Image1::fromArray ( const class Color1unorm8 *  ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static
109  {
110  Ref out = createEmpty(wrap);
111  out->copyArray(ptr, w, h);
112  return out;
113 }
static Ref createEmpty(int width, int height, WrapMode wrap=WrapMode::ERROR)
Definition: Image1.cpp:43
shared_ptr< class Image1 > Ref
Definition: Image1.h:31
float wrap(float t, float lo, float hi)
Definition: g3dmath.h:495
uint32 h
Definition: Map2D.h:194
uint32 w
Definition: Map2D.h:191

+ Here is the call graph for this function:

Image1::Ref G3D::Image1::fromArray ( const class Color3unorm8 *  ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static
95  {
96  Ref out = createEmpty(wrap);
97  out->copyArray(ptr, w, h);
98  return out;
99 }
static Ref createEmpty(int width, int height, WrapMode wrap=WrapMode::ERROR)
Definition: Image1.cpp:43
shared_ptr< class Image1 > Ref
Definition: Image1.h:31
float wrap(float t, float lo, float hi)
Definition: g3dmath.h:495
uint32 h
Definition: Map2D.h:194
uint32 w
Definition: Map2D.h:191

+ Here is the call graph for this function:

Image1::Ref G3D::Image1::fromArray ( const class Color4unorm8 *  ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static
123  {
124  Ref out = createEmpty(wrap);
125  out->copyArray(ptr, w, h);
126  return out;
127 }
static Ref createEmpty(int width, int height, WrapMode wrap=WrapMode::ERROR)
Definition: Image1.cpp:43
shared_ptr< class Image1 > Ref
Definition: Image1.h:31
float wrap(float t, float lo, float hi)
Definition: g3dmath.h:495
uint32 h
Definition: Map2D.h:194
uint32 w
Definition: Map2D.h:191

+ Here is the call graph for this function:

Image1::Ref G3D::Image1::fromArray ( const class Color1 ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static
102  {
103  Ref out = createEmpty(wrap);
104  out->copyArray(ptr, w, h);
105  return out;
106 }
static Ref createEmpty(int width, int height, WrapMode wrap=WrapMode::ERROR)
Definition: Image1.cpp:43
shared_ptr< class Image1 > Ref
Definition: Image1.h:31
float wrap(float t, float lo, float hi)
Definition: g3dmath.h:495
uint32 h
Definition: Map2D.h:194
uint32 w
Definition: Map2D.h:191

+ Here is the call graph for this function:

Image1::Ref G3D::Image1::fromArray ( const class Color3 ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static
116  {
117  Ref out = createEmpty(wrap);
118  out->copyArray(ptr, w, h);
119  return out;
120 }
static Ref createEmpty(int width, int height, WrapMode wrap=WrapMode::ERROR)
Definition: Image1.cpp:43
shared_ptr< class Image1 > Ref
Definition: Image1.h:31
float wrap(float t, float lo, float hi)
Definition: g3dmath.h:495
uint32 h
Definition: Map2D.h:194
uint32 w
Definition: Map2D.h:191

+ Here is the call graph for this function:

Image1::Ref G3D::Image1::fromArray ( const class Color4 ptr,
int  width,
int  height,
WrapMode  wrap = WrapMode::ERROR 
)
static
130  {
131  Ref out = createEmpty(wrap);
132  out->copyArray(ptr, w, h);
133  return out;
134 }
static Ref createEmpty(int width, int height, WrapMode wrap=WrapMode::ERROR)
Definition: Image1.cpp:43
shared_ptr< class Image1 > Ref
Definition: Image1.h:31
float wrap(float t, float lo, float hi)
Definition: g3dmath.h:495
uint32 h
Definition: Map2D.h:194
uint32 w
Definition: Map2D.h:191

+ Here is the call graph for this function:

Image1::Ref G3D::Image1::fromFile ( const std::string &  filename,
WrapMode  wrap = WrapMode::ERROR 
)
static
53  {
54  Ref out = createEmpty(wrap);
55  out->load(filename);
56  return out;
57 }
static Ref createEmpty(int width, int height, WrapMode wrap=WrapMode::ERROR)
Definition: Image1.cpp:43
shared_ptr< class Image1 > Ref
Definition: Image1.h:31
float wrap(float t, float lo, float hi)
Definition: g3dmath.h:495

+ Here is the call graph for this function:

Image1::Ref G3D::Image1::fromImage1unorm8 ( const shared_ptr< class Image1unorm8 > &  im)
static
29  {
30  Ref out = createEmpty(static_cast<WrapMode>(im->wrapMode()));
31  out->resize(im->width(), im->height());
32 
33  int N = im->width() * im->height();
34  const Color1unorm8* src = reinterpret_cast<Color1unorm8*>(im->getCArray());
35  for (int i = 0; i < N; ++i) {
36  out->data[i] = Color1(src[i]);
37  }
38 
39  return out;
40 }
static Ref createEmpty(int width, int height, WrapMode wrap=WrapMode::ERROR)
Definition: Image1.cpp:43
shared_ptr< class Image1 > Ref
Definition: Image1.h:31

+ Here is the call graph for this function:

void G3D::Image1::load ( const std::string &  filename)

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

If there is an alpha channel on the input, it is stripped. Values are automatically scaled to the range [0, 1].

60  {
61  shared_ptr<Image> image = Image::fromFile(filename);
62  if (image->format() != ImageFormat::L32F()) {
63  image->convertToL8();
64  }
65 
66  switch (image->format()->code)
67  {
69  copyArray(static_cast<const Color1unorm8*>(image->toPixelTransferBuffer()->buffer()), image->width(), image->height());
70  break;
72  copyArray(static_cast<const Color1*>(image->toPixelTransferBuffer()->buffer()), image->width(), image->height());
73  break;
75  copyArray(static_cast<const Color3unorm8*>(image->toPixelTransferBuffer()->buffer()), image->width(), image->height());
76  break;
78  copyArray(static_cast<const Color3*>(image->toPixelTransferBuffer()->buffer()), image->width(), image->height());
79  break;
81  copyArray(static_cast<const Color4unorm8*>(image->toPixelTransferBuffer()->buffer()), image->width(), image->height());
82  break;
84  copyArray(static_cast<const Color4*>(image->toPixelTransferBuffer()->buffer()), image->width(), image->height());
85  break;
86  default:
87  debugAssertM(false, "Trying to load unsupported image format");
88  break;
89  }
90 
91  setChanged(true);
92 }
#define debugAssertM(exp, message)
Definition: debugAssert.h:161
void copyArray(const Color1 *src, int w, int h)
Definition: Image1.cpp:161
Definition: ImageFormat.h:60
Definition: ImageFormat.h:55
Definition: ImageFormat.h:37
Definition: ImageFormat.h:110
void setChanged(bool c)
Definition: Map2D.h:323
Definition: ImageFormat.h:107
Definition: ImageFormat.h:40
static const ImageFormat * L32F()

+ Here is the call graph for this function:

void G3D::Image1::save ( const std::string &  filename)

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

The data values are assumed to be on the range [0, 1] and will be scaled appropriately for the save format.

202  {
203  // To avoid saving as floating point image. FreeImage cannot convert floating point to L8.
204  Image1unorm8::Ref unorm8 = Image1unorm8::fromImage1(dynamic_pointer_cast<Image1>(shared_from_this()));
205  unorm8->save(filename);
206 }
unorm8
Definition: unorm8.h:33

The documentation for this class was generated from the following files: