23#include "colormap_viewer_widget.h"
25#include <fvutils/color/conversions.h>
26#include <fvutils/colormap/colormap.h>
27#include <fvutils/scalers/lossy.h>
29using namespace firevision;
41 m_scl_layer_selector = 0;
42 m_colormap_img_buf = 0;
48 free(m_colormap_img_buf);
59 if (m_scl_layer_selector) {
61 m_scl_layer_selector->set_range(0.0, max);
62 m_scl_layer_selector->set_increments(1.0, 1.0);
63 m_scl_layer_selector->set_value(0.0);
82 m_scl_layer_selector = scl;
90 m_scl_layer_selector->set_range(0.0, max);
91 m_scl_layer_selector->set_increments(1.0, 1.0);
92 m_scl_layer_selector->set_value(0.0);
94 m_scl_layer_selector->signal_change_value().connect(
95 sigc::mem_fun(*
this, &ColormapViewerWidget::on_layer_selected));
99ColormapViewerWidget::on_layer_selected(Gtk::ScrollType scroll,
double value)
101 unsigned int layer = (
unsigned int)rint(value);
113 if (m_cm == 0 || m_img_colormap == 0) {
118 if (!m_scl_layer_selector)
121 layer = (
unsigned int)rint(m_scl_layer_selector->get_value());
124 unsigned int cm_layer = (layer * m_cm->
depth()) / m_cm->
deepness();
126 unsigned char *colormap_buffer = (
unsigned char *)malloc(
128 m_cm->
to_image(colormap_buffer, cm_layer);
130 unsigned int img_width = (
unsigned int)m_img_colormap->get_width();
131 unsigned int img_height = (
unsigned int)m_img_colormap->get_height();
133 img_width = (img_width < img_height) ? img_width : img_height;
134 img_height = (img_width < img_height) ? img_width : img_height;
143 unsigned char *scaled_colormap_buffer =
144 (
unsigned char *)malloc(colorspace_buffer_size(YUV422_PLANAR, img_width, img_height));
148 free(m_colormap_img_buf);
149 m_colormap_img_buf = (
unsigned char *)malloc(colorspace_buffer_size(RGB, img_width, img_height));
150 convert(YUV422_PLANAR, RGB, scaled_colormap_buffer, m_colormap_img_buf, img_width, img_height);
152 Glib::RefPtr<Gdk::Pixbuf> colormap_image = Gdk::Pixbuf::create_from_data(
153 m_colormap_img_buf, Gdk::COLORSPACE_RGB,
false, 8, img_width, img_height, 3 * img_width);
154 m_img_colormap->set(colormap_image);
156 free(colormap_buffer);
157 free(scaled_colormap_buffer);
virtual unsigned int image_width() const
Width of conversion image.
virtual unsigned int deepness() const =0
Get deepness of colormap.
virtual void to_image(unsigned char *yuv422_planar_buffer, unsigned int level=0)
Create image from LUT.
virtual unsigned int depth() const =0
Get depth of colormap.
virtual unsigned int image_height() const
Height of conversion image.
virtual void scale()
Scale image.
virtual void set_scaled_dimensions(unsigned int width, unsigned int height)
Set dimenins of scaled image buffer.
virtual void set_original_dimensions(unsigned int width, unsigned int height)
Set original image dimensions.
virtual void set_original_buffer(unsigned char *buffer)
Set original image buffer.
virtual void set_scaled_buffer(unsigned char *buffer)
Set scaled image buffer.