34 #include "../../Core/Math/rect.h"
35 #include "texture_format.h"
65 std::shared_ptr<PixelBuffer>
copy()
const;
66 std::shared_ptr<PixelBuffer>
copy(
const Rect &rect)
const;
69 virtual int width()
const = 0;
72 virtual int height()
const = 0;
78 virtual int pitch()
const = 0;
96 virtual void *
data() = 0;
97 virtual const void *
data()
const = 0;
99 template<
typename Type> Type *
data() {
return reinterpret_cast<Type*
>(
data()); }
100 template<
typename Type>
const Type *
data()
const {
return reinterpret_cast<const Type*
>(
data()); }
104 const unsigned char *
data_uint8()
const {
return reinterpret_cast<const unsigned char*
>(
data()); }
108 const unsigned short *
data_uint16()
const {
return reinterpret_cast<const unsigned short*
>(
data()); }
112 const unsigned int *
data_uint32()
const {
return reinterpret_cast<const unsigned int*
>(
data()); }
119 template<
typename T>
const T *
line(
int line)
const {
const unsigned char *
d =
data_uint8();
return reinterpret_cast<const T*
>(d + line *
pitch()); }
122 unsigned char *
line_uint8(
int index) {
return reinterpret_cast<unsigned char*
>(
line(index)); }
123 const unsigned char *
line_uint8(
int index)
const {
return reinterpret_cast<const unsigned char*
>(
line(index)); }
126 unsigned short *
line_uint16(
int index) {
return reinterpret_cast<unsigned short*
>(
line(index)); }
127 const unsigned short *
line_uint16(
int index)
const {
return reinterpret_cast<const unsigned short*
>(
line(index)); }
130 unsigned int *
line_uint32(
int index) {
return reinterpret_cast<unsigned int*
>(
line(index)); }
131 const unsigned int *
line_uint32(
int index)
const {
return reinterpret_cast<const unsigned int*
>(
line(index)); }
178 void set_image(
const std::shared_ptr<PixelBuffer> &source);
183 void set_image(
const std::shared_ptr<PixelBuffer> &source,
const PixelConverterPtr &converter);
190 void set_subimage(
const std::shared_ptr<PixelBuffer> &source,
const Point &dest_pos,
const Rect &src_rect);
197 void set_subimage(
const std::shared_ptr<PixelBuffer> &source,
const Point &dest_pos,
const Rect &src_rect,
const PixelConverterPtr &converter);
203 std::shared_ptr<PixelBuffer>
to_format(
TextureFormat texture_format,
const PixelConverterPtr &converter)
const;
223 static std::shared_ptr<PixelBuffer>
add_border(
const std::shared_ptr<PixelBuffer> &pb,
int border_size,
const Rect &rect);
unsigned short * data_uint16()
Returns a pointer to the beginning of the pixel buffer as 16 bit data.
Definition: pixel_buffer.h:107
const unsigned short * line_uint16(int index) const
Definition: pixel_buffer.h:127
2D (width,height) size structure - Integer
Definition: size.h:167
std::shared_ptr< PixelBuffer > to_format(TextureFormat texture_format) const
Converts current buffer to a new pixel format and returns the result.
virtual void set_pixel_ratio(float ratio)=0
Sets the display pixel ratio for this image.
virtual int width() const =0
Retrieves the width of the buffer.
Pixel data container.
Definition: pixel_buffer.h:52
unsigned int * line_uint32(int index)
Returns a pointer to the beginning of a specific line as 32 bit data.
Definition: pixel_buffer.h:130
const unsigned short * data_uint16() const
Definition: pixel_buffer.h:108
std::shared_ptr< PixelBuffer > copy() const
Create a copy of the pixelbuffer that doesn't share data with the original pixel buffer.
float dip_width() const
Returns the device independent width of this texture.
Definition: pixel_buffer.h:87
const unsigned int * line_uint32(int index) const
Definition: pixel_buffer.h:131
T * line(int line)
Definition: pixel_buffer.h:118
std::shared_ptr< PixelConverter > PixelConverterPtr
Definition: pixel_buffer.h:48
Type * data()
Definition: pixel_buffer.h:99
TextureFormat
Texture format.
Definition: texture_format.h:35
unsigned short * line_uint16(int index)
Returns a pointer to the beginning of a specific line as 16 bit data.
Definition: pixel_buffer.h:126
static std::shared_ptr< PixelBuffer > add_border(const std::shared_ptr< PixelBuffer > &pb, int border_size, const Rect &rect)
Add a border around a pixelbuffer, duplicating the edge pixels.
2D (x,y) point structure - Integer
Definition: point.h:58
void flip_vertical()
Flip the entire image vertically (turn it upside down)
virtual void * data()=0
Returns a pointer to the beginning of the pixel buffer.
Sizef dip_size() const
Returns the device independent size of this texture.
Definition: pixel_buffer.h:93
virtual TextureFormat format() const =0
Returns the pixel format.
const Type * data() const
Definition: pixel_buffer.h:100
2D (width,height) size structure - Float
Definition: size.h:180
void set_subimage(const std::shared_ptr< PixelBuffer > &source, const Point &dest_pos, const Rect &src_rect)
Copy source pixel buffer into this buffer, doing a format conversion if needed.
virtual float pixel_ratio() const =0
void premultiply_alpha()
Multiply the RGB components by the Alpha component.
unsigned char * line_uint8(int index)
Returns a pointer to the beginning of a specific line as 8 bit data.
Definition: pixel_buffer.h:122
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:491
const unsigned char * line_uint8(int index) const
Definition: pixel_buffer.h:123
void premultiply_gamma(float gamma)
Multiply the RGB components by gamma value.
virtual int height() const =0
Retrieves the height of the buffer.
unsigned char * data_uint8()
Returns a pointer to the beginning of the pixel buffer as 8 bit data.
Definition: pixel_buffer.h:103
unsigned int bytes_per_block() const
Returns the number of bytes per compression block.
std::shared_ptr< PixelBuffer > PixelBufferPtr
Definition: d3d_target.h:39
const unsigned char * data_uint8() const
Definition: pixel_buffer.h:104
std::shared_ptr< GraphicContext > GraphicContextPtr
Definition: d3d_target.h:49
void set_image(const std::shared_ptr< PixelBuffer > &source)
Copy source pixel buffer into this buffer, doing a format conversion if needed.
bool has_transparency() const
Returns true if format has an alpha channel.
virtual int pitch() const =0
Returns the pitch (bytes allocated per row).
void * line(int line)
Returns a pointer to the beginning of a specific line.
Definition: pixel_buffer.h:115
unsigned int bytes_per_pixel() const
Returns the number of bytes per pixel.
const void * line(int line) const
Definition: pixel_buffer.h:116
Pixel format converter class.
Definition: pixel_converter.h:39
Size size() const
Retrieves the size of the buffer.
Definition: pixel_buffer.h:75
float dip_height() const
Returns the device independent height of this texture.
Definition: pixel_buffer.h:90
bool is_compressed() const
Returns true if compressed.
static std::shared_ptr< PixelBuffer > create(int width, int height, TextureFormat texture_format, const void *data=nullptr, bool only_reference_data=false)
Constructs a PixelBuffer.
const unsigned int * data_uint32() const
Definition: pixel_buffer.h:112
Definition: Application/application.h:35
unsigned int data_size() const
Returns the size in bytes of the image data.
unsigned int * data_uint32()
Returns a pointer to the beginning of the pixel buffer as 32 bit data.
Definition: pixel_buffer.h:111
const T * line(int line) const
Definition: pixel_buffer.h:119