add support to passthough mjpeg images

This commit is contained in:
2023-11-18 16:23:52 +01:00
parent 24487a6a51
commit 76bd00363b
5 changed files with 72 additions and 21 deletions

29
image.h
View File

@ -6,16 +6,39 @@
class Image
{
private:
ssize_t bufferSize = -1;
public:
enum {
FORMAT_RGB,
FORMAT_JPEG,
FORMAT_YUYV
} typedef format_t;
std::shared_ptr<unsigned char> data = nullptr;
uint32_t width;
uint32_t height;
uint8_t channels;
const uint32_t size()
format_t format = FORMAT_RGB;
const size_t size() const
{
return width*height*channels;
return bufferSize < 0 ? width*height*channels : bufferSize;
}
void save(const char* filename)
void setSize(size_t size)
{
bufferSize = size;
}
void setBuffer(std::shared_ptr<unsigned char> buffer, size_t size, format_t inFormat = FORMAT_RGB)
{
data = buffer;
bufferSize = size;
format = inFormat;
}
void save(const char* filename) const
{
std::ofstream outfile(filename);
outfile.write((char *) data.get(), size());