36 static bool ended = false ;
37 if( !ended ) endwin() ;
45 m_mask(dx,dy,m_config.m_mask_file)
50 putenv( strdup(
"COLUMNS=" ) ) ;
51 putenv( strdup(
"LINES=" ) ) ;
58 init_pair( 1, COLOR_RED, COLOR_BLACK ) ;
59 init_pair( 2, COLOR_GREEN, COLOR_BLACK ) ;
60 init_pair( 3, COLOR_YELLOW, COLOR_BLACK ) ;
61 init_pair( 4, COLOR_BLUE, COLOR_BLACK ) ;
62 init_pair( 5, COLOR_MAGENTA, COLOR_BLACK ) ;
63 init_pair( 6, COLOR_CYAN, COLOR_BLACK ) ;
64 init_pair( 7, COLOR_WHITE, COLOR_BLACK ) ;
81 for(
Gr::Scaler y_scaler(LINES,data_dy) ; !!y_scaler ; ++y_scaler )
83 int display_y = y_scaler.first() ;
84 G_ASSERT( display_y < LINES ) ;
89 for(
Gr::Scaler x_scaler(COLS,data_dx) ; !!x_scaler ; ++x_scaler )
91 int display_x = x_scaler.first() ;
92 G_ASSERT( display_x < COLS ) ;
97 int data_x = x_scaler.second() ;
98 int data_y = y_scaler.second() ;
99 G_ASSERT( data_x < data_dx ) ;
100 G_ASSERT( data_y < data_dy ) ;
102 int data_offset = data_y * data_dx + data_x ;
103 if( data_channels != 1 )
104 data_offset *= data_channels ;
105 const unsigned char * p =
reinterpret_cast<const unsigned char *
>(data_p+data_offset) ;
107 const unsigned int r = *p++ ;
108 const unsigned int g = data_channels > 1 ? *p++ : r ;
109 const unsigned int b = data_channels > 2 ? *p++ : r ;
111 const unsigned int range = std::max(r,std::max(g,b)) ;
112 const unsigned int threshold = range/2U + range/4U ;
113 const unsigned int index = ((r>threshold)?1U:0U) | ((g>threshold)?2U:0U) | ((b>threshold)?4U:0U) ;
114 const chtype colour = m_mask.masked(data_x,data_y) ? COLOR_PAIR(1) : COLOR_PAIR(index) ;
117 static const char * luma_map =
" .,:;|(){}%%$@@##" ;
118 const chtype c = luma_map[(luma/16U)%16U] ;
120 move( display_y , display_x ) ;
121 addch( c | colour ) ;
125 if( !m_config.m_title.empty() )
128 for( std::string::iterator p = m_config.m_title.begin() ; p != m_config.m_title.end() ; ++p )
ViewerWindowCurses(ViewerWindowHandler &, ViewerWindowConfig, int dx, int dy)
Constructor.
virtual ~ViewerWindowCurses()
Destructor.
An empty structure that is used to indicate a signal-safe, reentrant implementation.
A class that allows for iterating over one integer range while accessing values from another...
virtual void init() override
Override from ViewerWindow.
A configuration structure for Gv::ViewerWindow.
virtual void display(int, int, int, const char *, size_t) override
Override from ViewerWindow.
virtual int dy() const override
Override from ViewerWindow.
triple< unsigned char > yuv_int(triple< unsigned char > rgb) g__noexcept
A fast conversion from rgb to yuv.
static void add(void(*fn)(SignalSafe, const char *), const char *arg)
Adds the given handler to the list of handlers that are to be called when the process terminates abno...
A callback interface for Gv::ViewerWindow.
virtual int dx() const override
Override from ViewerWindow.