roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
image.h
Go to the documentation of this file.
1#pragma once
2
12
13/// Image helpers and type aliases.
14///
15/// Images are drawables that render a rectangular area based on data from an
16/// immutable data source. Image classes are templated on `Resource`, which
17/// specifies the input source (e.g., DRAM, flash, SD card). Resource helpers
18/// live in the io/ directory, but you can define your own.
19///
20/// Each image alias recognizes a specific data format (e.g., raster bitmap or
21/// RLE-encoded data). Every image is a `Drawable`; many are `Streamable`, and
22/// some may be `Rasterizable`.
23
24/// Streamable and Rasterizable images can be alpha-blended without full
25/// buffering. Common use: semi-transparent images over solid backgrounds.
26//
27/// Note: for uncompressed images in native color modes, use `Raster`.
28//
29/// How to implement a new Streamable image class:
30/// 1) Implement a stream type with `Color next()` and `skip(int)`.
31/// 2) For full-stream images backed by memory, typedef
32/// `SimpleStreamable<YourStreamType>`.
33/// 3) For clipped sub-rectangles, use `Clipping<SimpleStreamable<...>>`.
34/// 4) For custom constructors, inherit and delegate (see `XBitmap`).
35
36namespace roo_display {
37
38/// Run-length-encoded image for color modes with >= 8 bits per pixel.
39template <typename ColorMode, typename Resource = ProgMemPtr>
40using RleImage =
41 SimpleStreamable<Resource, ColorMode,
43
44/// RLE 4-bit image with bias for extreme values (0x0/0xF).
45template <typename ColorMode, typename Resource = ProgMemPtr>
47 SimpleStreamable<Resource, ColorMode,
49
50/// Convenience alias for small anti-aliased monochrome artwork.
52
53/// Uncompressed image.
54template <typename Resource, typename ColorMode,
56 ByteOrder byte_order = roo_io::kBigEndian>
58 Resource, ColorMode,
60
61/// Uncompressed ARGB8888 image.
62template <typename Resource, ByteOrder byte_order = roo_io::kBigEndian>
65
66/// Uncompressed ARGB6666 image.
67template <typename Resource, ByteOrder byte_order = roo_io::kBigEndian>
70
71/// Uncompressed ARGB4444 image.
72template <typename Resource, ByteOrder byte_order = roo_io::kBigEndian>
75
76/// Uncompressed RGB565 image.
77template <typename Resource, ByteOrder byte_order = roo_io::kBigEndian>
80
81/// Uncompressed RGB565 image with reserved transparency.
82template <typename Resource, ByteOrder byte_order = roo_io::kBigEndian>
85 byte_order>;
86
87/// Uncompressed Grayscale8 image.
88template <typename Resource>
91 roo_io::kBigEndian>;
92
93/// Uncompressed Alpha8 image.
94template <typename Resource>
97 roo_io::kBigEndian>;
98
99/// Uncompressed Grayscale4 image.
100template <typename Resource,
104
105/// Uncompressed Alpha4 image.
106template <typename Resource,
110
111/// Uncompressed monochrome image.
112template <typename Resource,
116
117/// Monochrome XBitmap image (rows rounded to 8 pixels).
118template <typename Resource = ProgMemPtr>
120 : public Clipping<
121 SimpleImage<Resource, Monochrome, ColorPixelOrder::kLsbFirst,
122 roo_io::kBigEndian>> {
123 public:
125 ColorPixelOrder::kLsbFirst, roo_io::kBigEndian>>
127
128 XBitmap(int16_t width, int16_t height, const Resource& input, Color fg,
129 Color bg = color::Transparent)
130 : Base(Box(0, 0, width - 1, height - 1), ((width + 7) / 8) * 8, height,
131 std::move(input), Monochrome(fg, bg)) {}
132};
133
134} // namespace roo_display
Axis-aligned integer rectangle.
Definition box.h:12
ARGB8888 color stored as a 32-bit unsigned integer.
Definition color.h:16
RGB565 with a reserved value representing transparency.
Convenience wrapper for images backed by a byte stream.
Definition streamable.h:464
Monochrome XBitmap image (rows rounded to 8 pixels).
Definition image.h:122
Clipping< SimpleImage< Resource, Monochrome, ColorPixelOrder::kLsbFirst, roo_io::kBigEndian > > Base
Definition image.h:126
XBitmap(int16_t width, int16_t height, const Resource &input, Color fg, Color bg=color::Transparent)
Definition image.h:128
Defines 140 opaque HTML named colors.
roo_io::ByteOrder ByteOrder
Definition byte_order.h:7