pathanimator/c++/image.h

53 lines
1.4 KiB
C
Raw Normal View History

2022-01-17 15:53:17 +01:00
/// \file image.h
/// \copyright 2022 Sascha Nitsch
/// Licence under MIT license
/// \brief declaration of the Image class
#ifndef IMAGE_H_
#define IMAGE_H_
// system includes
#include <inttypes.h>
/// wrapper for pixel data of an image
class Image {
public:
/// constructor
/// \param width width in pixel
/// \param height height in pixel
/// \param channels number of channels
/// \param bits number of bits per channel
/// \param pixels optional memory for the image
Image(uint16_t width, uint16_t height, uint8_t channels, uint8_t bits, void* pixels = nullptr);
/// destructor
~Image();
/// \brief allocate memory for image data
bool allocateMemory();
/// \brief get pointer to pixel data
/// \return pointer to pixel data
uint8_t* getPixels8() const;
/// \brief get pointer to pixel data
/// \return pointer to pixel data
uint16_t* getPixels16() const;
/// \brief get width of image
/// \return width of image
uint16_t getWidth() const;
/// \brief get height of image
/// \return height of image
uint16_t getHeight() const;
private:
/// image width
uint16_t m_width;
/// image height
uint16_t m_height;
/// number of channels
uint8_t m_channels;
/// image data as RGB 8 or 16 bit per channel
void* m_pixels;
/// do we own the pixel memory?
bool m_ownPixel;
/// number of bits per channel
uint8_t m_bitsPerChannel;
};
#endif // IMAGE_H_