Fawkes API
Fawkes Development Version
|
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));
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());
virtual void clear()
Clear internal storage.
virtual unsigned int depth() const
virtual void read(const char *file_name)
Read file.
Colormap * get_colormap()
Get a freshly generated colormap based on current file content.
virtual unsigned int width() const
virtual void to_image(unsigned char *yuv422_planar_buffer, unsigned int level=0)
Create image from LUT.
virtual void write(const char *file_name)
Write file.
void loop_until_quit()
Process SDL events until quit.
ColormapBlockVector * colormap_blocks()
Get colormap blocks.
void add_colormap(Colormap *colormap)
Add colormap.
virtual unsigned int height() const
void show(colorspace_t colorspace, unsigned char *buffer)
Show image from given colorspace.
virtual void set(unsigned int y, unsigned int u, unsigned int v, color_t c)
virtual unsigned int deepness() const