tec::PixelBuffer
#include <pixel-buffer.hpp>
Public Types
Name | |
---|---|
enum | FILTER_PREFERENCE { DEFAULT, NEAREST, LINEAR} |
Public Functions
Name | |
---|---|
PixelBuffer() =default | |
bool | Load(const Path & filename, bool gamma_space =false) Returns a resource with the specified name. |
PixelBuffer(const PixelBuffer & ) =delete | |
PixelBuffer & | operator=(const PixelBuffer & ) =delete |
PixelBuffer(PixelBuffer && rv) | |
PixelBuffer & | operator=(PixelBuffer && rv) |
PixelBuffer(std::uint32_t width, std::uint32_t height, std::uint32_t bitsperchannel, ImageColorMode mode) Construct a new pixel buffer. |
|
bool | CreateCopy(const PixelBuffer & pbuf) Create a copy of a pixel buffer. |
bool | CreateCopy(const PixelBuffer & pbuf, std::uint32_t bitsperchannel, ImageColorMode mode) Create a copy of a pixel buffer in a different format. |
bool | Create(uint32_t width, uint32_t height, uint32_t bitsperchannel, ImageColorMode mode) Create a new pixel buffer, replacing the old buffer (if any). |
bool | IsDirty() const |
void | Invalidate() Mark dirty. |
void | Validate() Mark not dirty. |
const std::uint8_t * | GetBlockBase() const Returns a pointer to the base address of image data for reading. This function is intended for loading pixel data from the buffer. |
std::mutex & | GetWritelock() |
std::uint8_t * | GetPtr() |
std::uint32_t | Width() const |
std::uint32_t | Height() const |
std::uint32_t | Pitch() const |
std::uint32_t | PixelSize() const |
ImageColorMode | GetFormat() const |
FILTER_PREFERENCE | GetFilter() const |
void | SetFilter(FILTER_PREFERENCE f) |
void | PPMDebug() |
void | PPMDebug(const char * ofile) |
std::shared_ptr< PixelBuffer > | Create(const std::string name, const Path & filename =Path(), bool gamma_space =false) Factory method that creates a PixelBuffer and stores it in the PixelBufferMap under name. It will optionally load a texture file with the given filename. |
Public Attributes
Name | |
---|---|
std::uint32_t | image_x |
std::uint32_t | image_y |
Protected Attributes
Name | |
---|---|
std::int32_t | imagewidth |
std::int32_t | imageheight |
std::uint32_t | bufferpitch number of bytes to move vertical 1 raster line |
std::uint32_t | imagepixelsize |
std::uint32_t | channelbitdepth |
ImageColorMode | imagemode |
FILTER_PREFERENCE | imagefilter |
bool | dirty |
std::unique_ptr< std::uint8_t[]> | blockptr |
std::mutex | writelock |
Public Types Documentation
enum FILTER_PREFERENCE
Enumerator | Value | Description |
---|---|---|
DEFAULT | ||
NEAREST | ||
LINEAR |
Public Functions Documentation
function PixelBuffer
PixelBuffer() =default
function Load
bool Load(
const Path & filename,
bool gamma_space =false
)
Returns a resource with the specified name.
Parameters:
- const Path filename The filename of the image file to load.
Return: bool True if initialization finished with no errors.
function PixelBuffer
PixelBuffer(
const PixelBuffer &
) =delete
function operator=
PixelBuffer & operator=(
const PixelBuffer &
) =delete
function PixelBuffer
PixelBuffer(
PixelBuffer && rv
)
function operator=
PixelBuffer & operator=(
PixelBuffer && rv
)
function PixelBuffer
PixelBuffer(
std::uint32_t width,
std::uint32_t height,
std::uint32_t bitsperchannel,
ImageColorMode mode
)
Construct a new pixel buffer.
Parameters:
- width the width of the buffer in pixels
- height the height of the buffer in pixels
- bitsperchannel the number of bits in a single channel, usually 8
- mode greyscale (Monochrome) or color (RGB), and whether there is alpha or no alpha
function CreateCopy
bool CreateCopy(
const PixelBuffer & pbuf
)
Create a copy of a pixel buffer.
Parameters:
- pbuf the pixel buffer to copy from
Return: true on success
function CreateCopy
bool CreateCopy(
const PixelBuffer & pbuf,
std::uint32_t bitsperchannel,
ImageColorMode mode
)
Create a copy of a pixel buffer in a different format.
Parameters:
- pbuf the pixel buffer to copy from
- bitsperchannel the number of bits in a single channel, usually 8
- mode greyscale (Monochrome) or color (RGB), and whether there is alpha or no alpha
Return: true on success
function Create
bool Create(
uint32_t width,
uint32_t height,
uint32_t bitsperchannel,
ImageColorMode mode
)
Create a new pixel buffer, replacing the old buffer (if any).
Parameters:
- width the width of the buffer in pixels
- height the height of the buffer in pixels
- bitsperchannel the number of bits in a single channel, usually 8
- mode greyscale (Monochrome) or color (RGB), and whether there is alpha or no alpha
Return: true on success
function IsDirty
bool IsDirty() const
function Invalidate
void Invalidate()
Mark dirty.
function Validate
void Validate()
Mark not dirty.
function GetBlockBase
const std::uint8_t * GetBlockBase() const
Returns a pointer to the base address of image data for reading. This function is intended for loading pixel data from the buffer.
Return: uint8_t * base image address or nullptr if invalid.
function GetWritelock
inline std::mutex & GetWritelock()
function GetPtr
inline std::uint8_t * GetPtr()
function Width
inline std::uint32_t Width() const
function Height
inline std::uint32_t Height() const
function Pitch
inline std::uint32_t Pitch() const
function PixelSize
inline std::uint32_t PixelSize() const
function GetFormat
inline ImageColorMode GetFormat() const
function GetFilter
inline FILTER_PREFERENCE GetFilter() const
function SetFilter
inline void SetFilter(
FILTER_PREFERENCE f
)
function PPMDebug
void PPMDebug()
function PPMDebug
void PPMDebug(
const char * ofile
)
function Create
static std::shared_ptr< PixelBuffer > Create(
const std::string name,
const Path & filename =Path(),
bool gamma_space =false
)
Factory method that creates a PixelBuffer and stores it in the PixelBufferMap under name. It will optionally load a texture file with the given filename.
Parameters:
- const std::string name The name to store the PixelBuffer under.
- const Path filename The optional filename of the image to load.
Return: std::shared_ptr
Public Attributes Documentation
variable image_x
std::uint32_t image_x {0};
variable image_y
std::uint32_t image_y {0};
Protected Attributes Documentation
variable imagewidth
std::int32_t imagewidth {0};
variable imageheight
std::int32_t imageheight {0};
variable bufferpitch
std::uint32_t bufferpitch {0};
number of bytes to move vertical 1 raster line
variable imagepixelsize
std::uint32_t imagepixelsize {0};
variable channelbitdepth
std::uint32_t channelbitdepth {0};
variable imagemode
ImageColorMode imagemode {ImageColorMode::MONOCHROME};
variable imagefilter
FILTER_PREFERENCE imagefilter {DEFAULT};
variable dirty
bool dirty {false};
variable blockptr
std::unique_ptr< std::uint8_t[]> blockptr;
variable writelock
std::mutex writelock;
Updated on 2022-07-24 at 19:27:35 +0000