26 #include <core/exception.h>
27 #include <fvutils/color/colorspaces.h>
28 #include <fvutils/colormap/cmfile.h>
29 #include <fvutils/colormap/yuvcm.h>
30 #include <fvwidgets/image_display.h>
36 using namespace firevision;
41 main(
int argc,
char **argv)
43 const char *filename =
"qatest.colormap";
48 printf(
"Creating simple one-plane colormap\n");
51 for (
unsigned int u = 100; u < 150; ++u) {
52 for (
unsigned int v = 100; v < 150; ++v) {
53 cm->
set(128, u, v, C_ORANGE);
57 unsigned char *imgb = malloc_buffer(YUV422_PLANAR, cm->
width() * 2, cm->
height() * 2);
67 printf(
"Trying to create colormap with illegal depth, should throw an exception..");
70 printf(
" Test failed, colormap was created\n");
73 printf(
" Test succeeded, caught exception\n");
76 printf(
"Trying colormap with depth of %u\n", BIGDEPTH);
79 for (
unsigned int d = 0; d < cm->
depth(); ++d) {
80 unsigned int y = 256 / cm->
depth() * d;
81 printf(
"d=%u y=%u u=[%u,%u] v=[%u,%u]\n",
85 cm->
depth() * (d + 1),
87 cm->
depth() * (d + 1));
90 u < cm->deepness() / cm->
depth() * (d + 1);
93 v < cm->deepness() / cm->
depth() * (d + 1);
95 cm->
set(y, u, v, C_ORANGE);
104 printf(
"Saving colormap to a file\n");
110 printf(
"Written, created %zu blocks\n", blocks->size());
116 printf(
"Reading colormap from file\n");
120 if ((cm =
dynamic_cast<YuvColormap *
>(tcm)) == 0) {
121 printf(
"Error, did not get valid yuv colormap\n");
123 printf(
"Showing all %u colormap levels\n", cm->
depth());
124 for (
unsigned int d = 0; d < cm->
depth(); ++d) {
133 unsigned int depth = 4, width = 128, height = 128;
134 printf(
"Trying colormap with low resolution, choosing %dx%dx%d\n", depth, width, height);
136 printf(
"YuvColormap dimensions: %dx%dx%d\n", cm->
depth(), cm->
width(), cm->
height());
139 cmfr.write(filename);
142 cm =
dynamic_cast<YuvColormap *
>(cmfr.get_colormap());
143 printf(
"Read back colormap dimensions %dx%dx%d\n", cm->
depth(), cm->
width(), cm->
height());
Base class for exceptions in Fawkes.
Vector of colormap blocks.
virtual void clear()
Clear internal storage.
ColormapBlockVector * colormap_blocks()
Get colormap blocks.
Colormap * get_colormap()
Get a freshly generated colormap based on current file content.
void add_colormap(Colormap *colormap)
Add colormap.
virtual void to_image(unsigned char *yuv422_planar_buffer, unsigned int level=0)
Create image from LUT.
virtual void read(const char *file_name)
Read file.
virtual void write(const char *file_name)
Write file.
void loop_until_quit()
Process SDL events until quit.
void show(colorspace_t colorspace, unsigned char *buffer)
Show image from given colorspace.
virtual unsigned int height() const
Get height of colormap.
virtual unsigned int depth() const
Get depth of colormap.
virtual unsigned int width() const
Get width of colormap.
virtual void set(unsigned int y, unsigned int u, unsigned int v, color_t c)
Set color class for given YUV value.
virtual unsigned int deepness() const
Get deepness of colormap.
Fawkes library namespace.