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> 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",
virtual unsigned int deepness() const
Get deepness of colormap.
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 unsigned int width() const
Get width of colormap.
Fawkes library namespace.
Colormap * get_colormap()
Get a freshly generated colormap based on current file content.
virtual void write(const char *file_name)
Write file.
virtual void read(const char *file_name)
Read file.
Base class for exceptions in Fawkes.
ColormapBlockVector * colormap_blocks()
Get colormap blocks.
virtual void set(unsigned int y, unsigned int u, unsigned int v, color_t c)
Set color class for given YUV value.
Vector of colormap blocks.
void loop_until_quit()
Process SDL events until quit.
virtual void clear()
Clear internal storage.
virtual unsigned int depth() const
Get depth of colormap.
virtual unsigned int height() const
Get height of colormap.
void show(colorspace_t colorspace, unsigned char *buffer)
Show image from given colorspace.