
Hi there, I'm playing around with indexed images in GIL. My starting point was an email from Lubomir during the review. Here is what I have: struct indexed_pixel_deref_fn { typedef pixel_traits<rgb8_pixel_t>::reference reference; typedef pixel_traits<rgb8_pixel_t>::const_reference const_reference; typedef const_reference const_t; typedef reference result_type; typedef rgb8_pixel_t value_type; static const bool is_mutable = false; indexed_pixel_deref_fn( rgb8_pixel_t* table ) : _table( table ) {} rgb8_pixel_t operator()( const gray8_pixel_t& index ) const { return _table[index[0]]; } rgb8_pixel_t* _table; }; typedef gray8_view_t::add_deref<indexed_pixel_deref_fn> indexed_factory_t; typedef indexed_factory_t::type rgb8_indexed_view_t; int _tmain(int argc, _TCHAR* argv[]) { // create color lookup table rgb8_pixel_t rgb_black( 0, 0, 0 ); rgb8_pixel_t rgb_red( 255, 0, 0 ); rgb8_pixel_t my_index_table[2]; my_index_table[0] = rgb_red; my_index_table[1] = rgb_black; // create indexed image gray8_image_t indexed_img( 10,10 ); fill_pixels( view( indexed_img ), unsigned char( 0 ) ); rgb8_indexed_view_t indexed_view= indexed_factory_t::make( view( indexed_img ) , indexed_pixel_deref_fn( &my_index_table[0] )); // color convert the indexed image into an rgb8 image rgb8_image_t rgb_img( indexed_img.dimensions() ); copy_pixels( color_converted_view<rgb8_pixel_t>( view( indexed_img )) , view( rgb_img ) ); // save image - it should be all red jpeg_write_view( "test.jpg", const_view( rgb_img )); return 0; } I'm not sure if all these typedefs in the deref functor class are correct. Esspecially, I don't know what the const_t is for. So, my problem is the operator() in my deref isn't called at all. That shows me there is something wrong. Anyone, any idea why? Thanks, Christian