35 #include "../../Core/Math/rect.h"
36 #include "texture_format.h"
37 #include "buffer_usage.h"
50 class PixelBuffer_Impl;
54 class PixelBufferProvider;
84 PixelBuffer(
int width,
int height,
TextureFormat texture_format,
const void *data =
nullptr,
bool only_reference_data =
false);
163 template<
typename Type>
const Type *
get_data()
const {
return reinterpret_cast<Type*
>(
get_data()); }
320 std::shared_ptr<PixelBuffer_Impl> impl;
float get_dip_width() const
Returns the device independent width of this texture.
Definition: pixel_buffer.h:146
bool is_compressed() const
Returns true if compressed.
void set_subimage(const PixelBuffer &source, const Point &dest_pos, const Rect &src_rect)
Copy source pixel buffer into this buffer, doing a format conversion if needed.
int get_width() const
Retrieves the actual width of the buffer.
2D (x,y) point structure - Integer
Definition: point.h:63
bool has_transparency() const
Returns true if format has an alpha channel.
Size get_size() const
Retrieves the actual size of the buffer.
Definition: pixel_buffer.h:134
static unsigned int get_data_size(const Size &size, TextureFormat texture_format)
Returns the size in bytes of the image data.
static bool is_compressed(TextureFormat texture_format)
Returns true if compressed.
unsigned short * get_data_uint16()
Returns a pointer to the beginning of the pixel buffer as 16 bit data.
Definition: pixel_buffer.h:170
float get_pixel_ratio() const
void flip_vertical()
Flip the entire image vertically (turn it upside down)
PixelBuffer()
Constructs a null instance.
Element Array Buffer provider.
Definition: pixel_buffer_provider.h:43
void set_image(const PixelBuffer &source, PixelConverter &converter)
Copy source pixel buffer into this buffer, doing a format conversion if needed.
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:471
Sizef get_dip_size() const
Returns the device independent size of this texture.
Definition: pixel_buffer.h:152
PixelBuffer(IODevice &file, const std::string &image_type, bool srgb=false)
Constructs a PixelBuffer.
void * get_data()
Returns a pointer to the beginning of the pixel buffer.
PixelBuffer to_format(TextureFormat texture_format, PixelConverter &converter) const
Converts current buffer to a new pixel format and returns the result.
Colorf get_pixel(int x, int y)
Return color of pixel at the specified coordinates.
void set_pixel_ratio(float ratio)
Sets the display pixel ratio for this texture.
PixelBuffer to_cpu(GraphicContext &gc)
Downloads the pixel buffer to CPU memory.
I/O Device interface.
Definition: iodevice.h:51
PixelBuffer(const std::string &fullname, bool srgb=false)
Constructs a PixelBuffer.
PixelBuffer(int width, int height, TextureFormat texture_format, const void *data=nullptr, bool only_reference_data=false)
Constructs a PixelBuffer.
Floating point color description class (for float).
Definition: color.h:661
static unsigned int get_bytes_per_block(TextureFormat texture_format)
Returns the number of bytes per compression block.
PixelBuffer to_format(TextureFormat texture_format) const
Converts current buffer to a new pixel format and returns the result.
const Type * get_data() const
Definition: pixel_buffer.h:163
PixelBufferDirection
Pixel buffer prefered direction.
Definition: pixel_buffer.h:59
int get_pitch() const
Returns the pitch (in bytes per scanline).
PixelBuffer copy(const Rect &rect) const
Create a copy of the pixelbuffer that doesn't share data with the original pixel buffer.
void set_subimage(const PixelBuffer &source, const Point &dest_pos, const Rect &src_rect, PixelConverter &converter)
Copy source pixel buffer into this buffer, doing a format conversion if needed.
PixelBuffer to_gpu(GraphicContext &gc)
Uploads the pixel buffer to GPU memory.
void premultiply_gamma(float gamma)
Multiply the RGB components by gamma value.
unsigned short * get_line_uint16(int line)
Returns a pointer to the beginning of a specific line as 16 bit data.
Definition: pixel_buffer.h:186
TextureFormat get_format() const
Returns the pixel format.
friend class PixelBuffer_Impl
Definition: pixel_buffer.h:321
void * get_line(int line)
Returns a pointer to the beginning of a specific line.
Definition: pixel_buffer.h:178
PixelBuffer copy() const
Create a copy of the pixelbuffer that doesn't share data with the original pixel buffer.
void unlock()
Unmaps element buffer.
unsigned int get_bytes_per_block() const
Returns the number of bytes per compression block.
Interface to drawing graphics.
Definition: graphic_context.h:258
PixelBuffer(PixelBufferProvider *provider)
Constructs a PixelBuffer.
unsigned int get_bytes_per_pixel() const
Returns the number of bytes per pixel.
@ data_to_gpu
Use of the pixel buffer is to send data to the gpu.
Definition: pixel_buffer.h:61
Type * get_data()
Definition: pixel_buffer.h:162
void lock(GraphicContext &gc, BufferAccess access)
Maps buffer into system memory.
void set_image(const PixelBuffer &source)
Copy source pixel buffer into this buffer, doing a format conversion if needed.
void premultiply_alpha()
Multiply the RGB components by the Alpha component.
TextureFormat
Texture format.
Definition: texture_format.h:41
bool is_null() const
Returns true if this object is invalid.
Definition: pixel_buffer.h:116
unsigned int * get_line_uint32(int line)
Returns a pointer to the beginning of a specific line as 32 bit data.
Definition: pixel_buffer.h:190
const void * get_data() const
PixelBufferProvider * get_provider() const
Get Provider.
unsigned int get_data_size() const
Returns the size in bytes of the image data.
Virtual File System (VFS).
Definition: file_system.h:48
unsigned int * get_data_uint32()
Returns a pointer to the beginning of the pixel buffer as 32 bit data.
Definition: pixel_buffer.h:174
void throw_if_null() const
Throw an exception if this object is invalid.
Low level pixel format converter class.
Definition: pixel_converter.h:46
unsigned char * get_line_uint8(int line)
Returns a pointer to the beginning of a specific line as 8 bit data.
Definition: pixel_buffer.h:182
const unsigned int * get_data_uint32() const
Definition: pixel_buffer.h:175
Pixel data container.
Definition: pixel_buffer.h:69
const unsigned char * get_data_uint8() const
Definition: pixel_buffer.h:167
void upload_data(GraphicContext &gc, const Rect &dest_rect, const void *data)
Uploads data to buffer.
const unsigned int * get_line_uint32(int line) const
Definition: pixel_buffer.h:191
PixelBuffer(const std::string &filename, const FileSystem &file_system, bool srgb=false)
Constructs a PixelBuffer.
BufferAccess
Array Buffer access enum.
Definition: buffer_usage.h:55
2D (width,height) size structure - Integer
Definition: size.h:157
bool is_gpu() const
Returns true if this pixel buffer is a GPU based one.
@ data_from_gpu
Use of the pixel buffer is to retrieve data from the gpu.
Definition: pixel_buffer.h:64
2D (width,height) size structure - Float
Definition: size.h:170
const unsigned short * get_data_uint16() const
Definition: pixel_buffer.h:171
int get_height() const
Retrieves the actual height of the buffer.
static unsigned int get_bytes_per_pixel(TextureFormat texture_format)
Returns the number of bytes per pixel.
float get_dip_height() const
Returns the device independent height of this texture.
Definition: pixel_buffer.h:149
unsigned char * get_data_uint8()
Returns a pointer to the beginning of the pixel buffer as 8 bit data.
Definition: pixel_buffer.h:166
const unsigned short * get_line_uint16(int line) const
Definition: pixel_buffer.h:187
const void * get_line(int line) const
Definition: pixel_buffer.h:179
const unsigned char * get_line_uint8(int line) const
Definition: pixel_buffer.h:183