gigawidgets 0.3.55
A wxWidgets-style UI library for the Arduino Giga Display Shield.
 
Loading...
Searching...
No Matches
image_file.hpp
1
2#pragma once
3
4#include "../renderable.hpp"
5#include <initializer_list>
6
7namespace ui {
8
10enum ImageType {
11 IMAGE_UNKNOWN,
12 IMAGE_JPEG,
13 IMAGE_PNG,
14 IMAGE_BMP,
15};
16
23struct ImageFile : public Renderable {
24
31 static ImageType getType(uint8_t *const bytes, size_t length);
32
40 static bool hasSequence(uint8_t *const bytes, size_t length, const std::initializer_list<uint8_t> &&sequence, size_t index);
41
48 uint8_t *const bytes;
49
53 size_t length;
54
60 ImageFile(uint8_t *const bytes, size_t length);
61
62protected:
69 unsigned int getInt(size_t index, uint8_t count) const;
70
77 unsigned int getIntLE(size_t index, uint8_t count) const;
78};
79
80} // namespace ui
The common interface for images read from raw data.
Definition image_file.hpp:23
static ImageType getType(uint8_t *const bytes, size_t length)
Determine the image type based on the file data.
ImageFile(uint8_t *const bytes, size_t length)
Constructor.
uint8_t *const bytes
The buffer that the image data is stored in.
Definition image_file.hpp:48
unsigned int getInt(size_t index, uint8_t count) const
Read a big-endian integer from raw bytes.
size_t length
The size of the data buffer.
Definition image_file.hpp:53
unsigned int getIntLE(size_t index, uint8_t count) const
Read a little-endian integer from raw bytes.
static bool hasSequence(uint8_t *const bytes, size_t length, const std::initializer_list< uint8_t > &&sequence, size_t index)
Check if a buffer contains a specific sequence of bytes at the given index.
An abstract interface for arbitrary renderable objects.
Definition renderable.hpp:55