40 #ifndef H_OGF_IMAGE_TYPES_IMAGE_H
41 #define H_OGF_IMAGE_TYPES_IMAGE_H
67 GRAY, INDEXED, RGB, BGR, RGBA, YUV
75 BYTE, INT16, INT32, FLOAT32, FLOAT64
99 initialize(color_rep, component_rep, width, height, depth);
166 return bytes_per_pixel_;
174 return nb_components(color_encoding());
182 return size_t(size_[0]) * size_t(size_[1]) * size_t(size_[2]);
191 return nb_pixels() * bytes_per_pixel();
199 return component_encoding_;
207 return color_encoding_;
232 colormap_ = colormap;
251 return byte_ptr(base_mem_);
261 return int16_ptr(base_mem_);
271 return int32_ptr(base_mem_);
281 return float32_ptr(base_mem_);
291 return float64_ptr(base_mem_);
301 return base_mem() + x * factor_[0];
312 return byte_ptr(base_mem() + x * factor_[0]);
322 return int16_ptr(base_mem() + x * factor_[0]);
332 return int32_ptr(base_mem() + x * factor_[0]);
342 return float32_ptr(base_mem() + x * factor_[0]);
352 return float64_ptr(base_mem() + x * factor_[0]);
363 return base_mem() + x * factor_[0] + y * factor_[1];
373 return byte_ptr(base_mem() + x * factor_[0] + y * factor_[1]);
383 return int16_ptr(base_mem() + x * factor_[0] + y * factor_[1]);
393 return int32_ptr(base_mem() + x * factor_[0] + y * factor_[1]);
403 return float32_ptr(base_mem() + x * factor_[0] + y * factor_[1]);
413 return float64_ptr(base_mem() + x * factor_[0] + y * factor_[1]);
424 x * factor_[0] + y * factor_[1] + z * factor_[2];
435 return byte_ptr(base_mem() +
436 x * factor_[0] + y * factor_[1] + z * factor_[2]
448 return int16_ptr(base_mem() +
449 x * factor_[0] + y * factor_[1] + z * factor_[2]
461 return int32_ptr(base_mem() +
462 x * factor_[0] + y * factor_[1] + z * factor_[2]
477 return float32_ptr(base_mem() +
478 x * factor_[0] + y * factor_[1] + z * factor_[2]
493 return float64_ptr(base_mem() +
494 x * factor_[0] + y * factor_[1] + z * factor_[2]
623 size_t bytes_per_pixel_;
#define geo_assert(x)
Verifies that a condition is met.
#define geo_debug_assert(x)
Verifies that a condition is met.
Base class for reference-counted objects.
Numeric::float64 * pixel_base_float64_ptr(index_t x, index_t y, index_t z)
Gets the address of a pixel in a 3D image as a float64 pointer.
Numeric::float32 * pixel_base_float32_ptr(index_t x, index_t y)
Gets the address of a pixel in a 2D image as a float32 pointer.
Image()
Image constructor.
Memory::pointer pixel_base(index_t x)
Gets the address of a pixel in a 1D image.
Numeric::float64 * base_mem_float64_ptr() const
Gets the base memory as a 64 bits floating point pointer.
void swap_components(index_t channel1, index_t channel2)
Swaps two color components of this image.
ComponentEncoding component_encoding() const
Gets the ComponentEncoding.
Numeric::float32 * float32_ptr(Memory::pointer ptr) const
Converts an untyped pointer into a 32 bits floating point pointer.
Numeric::int16 * pixel_base_int16_ptr(index_t x)
Gets the address of a pixel in a 1D image as a int16 pointer.
Numeric::float32 * base_mem_float32_ptr() const
Gets the base memory as a 32 bits floating point pointer.
Numeric::int16 * base_mem_int16_ptr() const
Gets the base memory as a 16 bits integer pointer.
Numeric::int32 * pixel_base_int32_ptr(index_t x, index_t y, index_t z)
Gets the address of a pixel in a 3D image as an int32 pointer.
Numeric::float32 * pixel_base_float32_ptr(index_t x, index_t y, index_t z)
Gets the address of a pixel in a 3D image as a float32 pointer.
~Image() override
Image destructor.
ColorEncoding color_encoding() const
Gets the ColorEncoding.
index_t height() const
Gets the height of the image.
Numeric::float32 * pixel_base_float32_ptr(index_t x)
Gets the address of a pixel in a 1D image as a float32 pointer.
static size_t bytes_per_component(ComponentEncoding component_rep)
Gets the number of bytes used by a ComponentEncoding.
Memory::byte * pixel_base_byte_ptr(index_t x, index_t y, index_t z)
Gets the address of a pixel in a 3D image as a byte pointer.
static size_t nb_components(ColorEncoding color_rep)
Gets the number of components associated with a ColorEncoding.
size_t nb_pixels() const
Gets the number of pixels.
Memory::byte * pixel_base_byte_ptr(index_t x, index_t y)
Gets the address of a pixel in a 2D image as a byte pointer.
const Colormap * colormap() const
Gets the Colormap.
Numeric::float64 * pixel_base_float64_ptr(index_t x)
Gets the address of a pixel in a 1D image as a float64 pointer.
index_t depth() const
Gets the depth of the image.
Numeric::int32 * base_mem_int32_ptr() const
Gets the base memory as a 32 bits integer pointer.
Numeric::int32 * pixel_base_int32_ptr(index_t x)
Gets the address of a pixel in a 1D image as a int32 pointer.
index_t dimension() const
Gets the dimension of the image.
Image(ColorEncoding color_rep, ComponentEncoding component_rep, index_t width, index_t height=1, index_t depth=1)
Image constructor.
virtual void acquire()
Some implementations get the image from some sources. Default implementation does nothing.
Memory::byte * byte_ptr(Memory::pointer ptr) const
Converts an untyped pointer into a byte pointer.
Numeric::int32 * pixel_base_int32_ptr(index_t x, index_t y)
Gets the address of a pixel in a 2D image as an int32 pointer.
void flip_vertically()
Flips this image along the y axis.
void initialize(ColorEncoding color_rep, ComponentEncoding component_rep, index_t size_x, index_t size_y=1, index_t size_z=1)
Creates storage for the specified encoding and image dimensions.
size_t bytes() const
Gets the number of bytes.
Memory::pointer pixel_base(index_t x, index_t y)
Gets the address of a pixel in a 2D image.
Numeric::float64 * pixel_base_float64_ptr(index_t x, index_t y)
Gets the address of a pixel in a 2D image as a float64 pointer.
Numeric::int16 * pixel_base_int16_ptr(index_t x, index_t y)
Gets the address of a pixel in a 2D image as an int16 pointer.
Numeric::int32 * int32_ptr(Memory::pointer ptr) const
Converts an untyped pointer into a 32 bits integer pointer.
Numeric::float64 * float64_ptr(Memory::pointer ptr) const
Converts an untyped pointer into a 64 bits floating point pointer.
ComponentEncoding
Indicates the datatype used to encode each component of the colors.
index_t size(index_t axis) const
Gets the size of the image along one of the axes.
void set_colormap(Colormap *colormap)
Sets the Colormap.
Memory::pointer base_mem() const
Gets the base memory.
Colormap * colormap()
Gets the Colormap.
index_t width() const
Gets the width of the image.
Memory::byte * base_mem_byte_ptr() const
Gets the base memory as a byte pointer.
size_t components_per_pixel() const
Gets the number of components per pixel.
ColorEncoding
Indicates how colors are encoded within the image.
size_t bytes_per_pixel() const
Gets the number of bytes per pixel.
Memory::pointer pixel_base(index_t x, index_t y, index_t z)
Gets the address of a pixel in a 3D image.
Numeric::int16 * pixel_base_int16_ptr(index_t x, index_t y, index_t z)
Gets the address of a pixel in a 3D image as an int16 pointer.
Memory::byte * pixel_base_byte_ptr(index_t x)
Gets the address of a pixel in a 1D image as a byte pointer.
Numeric::int16 * int16_ptr(Memory::pointer ptr) const
Converts an untyped pointer into a 16 bits integer pointer.
Common include file, providing basic definitions. Should be included before anything else by all head...
unsigned char byte
Unsigned byte type.
byte * pointer
Pointer to unsigned byte(s)
Global Vorpaline namespace.
geo_index_t index_t
The type for storing and manipulating indices.
void initialize(int flags=GEOGRAM_INSTALL_NONE)
Initialize Geogram.