23 #include "colormap_viewer_widget.h" 24 #include <fvutils/colormap/colormap.h> 25 #include <fvutils/scalers/lossy.h> 26 #include <fvutils/color/conversions.h> 40 m_scl_layer_selector = 0;
41 m_colormap_img_buf = 0;
47 free(m_colormap_img_buf);
58 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;
86 { max = m_cm->deepness(); }
89 m_scl_layer_selector->set_range(0.0, max);
90 m_scl_layer_selector->set_increments(1.0, 1.0);
91 m_scl_layer_selector->set_value(0.0);
93 m_scl_layer_selector->signal_change_value().connect( sigc::mem_fun(*
this, &ColormapViewerWidget::on_layer_selected) );
97 ColormapViewerWidget::on_layer_selected(Gtk::ScrollType scroll,
double value)
99 unsigned int layer = (
unsigned int) rint(value);
111 if (m_cm == 0 || m_img_colormap == 0)
114 if (layer >= m_cm->deepness() )
116 if (!m_scl_layer_selector)
return;
117 else layer = (
unsigned int) rint(m_scl_layer_selector->get_value());
120 unsigned int cm_layer = (layer * m_cm->depth()) / m_cm->deepness();
122 unsigned char* colormap_buffer = (
unsigned char*) malloc( colorspace_buffer_size(YUV422_PLANAR, m_cm->image_width(), m_cm->image_height()) );
123 m_cm->to_image(colormap_buffer, cm_layer);
125 unsigned int img_width = (
unsigned int) m_img_colormap->get_width();
126 unsigned int img_height = (
unsigned int) m_img_colormap->get_height();
128 img_width = (img_width < img_height) ? img_width : img_height;
129 img_height = (img_width < img_height) ? img_width : img_height;
138 unsigned char* scaled_colormap_buffer = (
unsigned char*) malloc( colorspace_buffer_size(YUV422_PLANAR, img_width, img_height) );
142 free(m_colormap_img_buf);
143 m_colormap_img_buf = (
unsigned char*) malloc( colorspace_buffer_size(RGB, img_width, img_height) );
144 convert(YUV422_PLANAR, RGB, scaled_colormap_buffer, m_colormap_img_buf, img_width, img_height);
146 Glib::RefPtr<Gdk::Pixbuf> colormap_image =
147 Gdk::Pixbuf::create_from_data( m_colormap_img_buf,
151 img_width, img_height,
153 m_img_colormap->set(colormap_image);
155 free(colormap_buffer);
156 free(scaled_colormap_buffer);
virtual void set_scaled_buffer(unsigned char *buffer)
Set scaled image buffer.
virtual void set_original_buffer(unsigned char *buffer)
Set original image buffer.
virtual void set_original_dimensions(unsigned int width, unsigned int height)
Set original image dimensions.
virtual void set_scaled_dimensions(unsigned int width, unsigned int height)
Set dimenins of scaled image buffer.
virtual unsigned int deepness() const =0
Get deepness of colormap.
virtual void scale()
Scale image.