26 #include <fvutils/colormap/yuvcm.h>
27 #include <fvutils/colormap/cmfile.h>
28 #include <fvutils/color/colorspaces.h>
30 #include <fvwidgets/image_display.h>
31 #include <core/exception.h>
36 using namespace fawkes;
37 using namespace firevision;
42 main(
int argc,
char **argv)
45 const char *filename =
"qatest.colormap";
50 printf(
"Creating simple one-plane colormap\n");
53 for (
unsigned int u = 100; u < 150; ++u) {
54 for (
unsigned int v = 100; v < 150; ++v) {
55 cm->
set(128, u, v, C_ORANGE);
59 unsigned char *imgb = malloc_buffer(YUV422_PLANAR, cm->
width() * 2, cm->
height() * 2);
69 printf(
"Trying to create colormap with illegal depth, should throw an exception..");
72 printf(
" Test failed, colormap was created\n");
75 printf(
" Test succeeded, caught exception\n");
78 printf(
"Trying colormap with depth of %u\n", BIGDEPTH);
81 for (
unsigned int d = 0; d < cm->
depth(); ++d) {
82 unsigned int y = 256 / cm->
depth() * d;
83 printf(
"d=%u y=%u u=[%u,%u] v=[%u,%u]\n", d, y,
88 cm->
set(y, u, v, C_ORANGE);
97 printf(
"Saving colormap to a file\n");
103 printf(
"Written, created %zu blocks\n", blocks->size());
109 printf(
"Reading colormap from file\n");
113 if ( (cm = dynamic_cast<YuvColormap *>(tcm)) == 0 ) {
114 printf(
"Error, did not get valid yuv colormap\n");
116 printf(
"Showing all %u colormap levels\n", cm->
depth());
117 for (
unsigned int d = 0; d < cm->
depth(); ++d) {
126 unsigned int depth = 4, width = 128, height = 128;
127 printf(
"Trying colormap with low resolution, choosing %dx%dx%d\n", depth, width, height);
129 printf(
"YuvColormap dimensions: %dx%dx%d\n", cm->
depth(), cm->
width(), cm->
height());
132 cmfr.write(filename);
135 cm =
dynamic_cast<YuvColormap *
>(cmfr.get_colormap());
136 printf(
"Read back colormap dimensions %dx%dx%d\n",