[gil] bit_aligned_pixel_iterator

Hi there, I have a problem with extracting the correct values out of a 3bit gray image. The test code below displays my problem. Here, there is a vector of unsigned chars which create a particular bit pattern though all pixels in the image should have the same values. The bit pattern is: 1011 0110 0110 1101 1101 1011 0000 0000. On my machine ( x86 ) this should be read out in values of 110b ( which is 6 ) for all pixels. Instead my code reads out: 6, 6, 2, 6, 6, 0, 6, 6, 0. Here is the code: #include <cassert> #include <vector> #include <boost/gil/gil_all.hpp> using namespace std; using namespace boost; using namespace gil; int main() { typedef bit_aligned_image1_type< 3, gray_layout_t >::type gray3_image_t; typedef gray3_image_t image_t; typedef image_t::view_t view_t; typedef view_t::reference ref_t; typedef view_t::value_type pixel_t; typedef bit_aligned_pixel_iterator< ref_t > iterator_t; vector< unsigned char > buf( 4 ); buf[0] = 182; buf[1] = 109; buf[2] = 219; buf[3] = 0; iterator_t it( &buf[0], 0 ); ref_t p1 = *it; it++; ref_t p2 = *it; it++; ref_t p3 = *it; it++; ref_t p4 = *it; it++; ref_t p5 = *it; it++; ref_t p6 = *it; it++; ref_t p7 = *it; it++; ref_t p8 = *it; it++; ref_t p9 = *it; it++; unsigned char v1 = get_color( p1, gray_color_t() ); unsigned char v2 = get_color( p2, gray_color_t() ); unsigned char v3 = get_color( p3, gray_color_t() ); unsigned char v4 = get_color( p4, gray_color_t() ); unsigned char v5 = get_color( p5, gray_color_t() ); unsigned char v6 = get_color( p6, gray_color_t() ); unsigned char v7 = get_color( p7, gray_color_t() ); unsigned char v8 = get_color( p8, gray_color_t() ); unsigned char v9 = get_color( p9, gray_color_t() ); return 0; } The first two values are correct since they covered by the first byte. The third value doesn't seem to take in account the first bit of the second byte. I think this is incorrect. The stepping of the bits of by the iterator seems correct. Each value that is covered by one byte completely is correct but when a value is stretched over two bytes there seems to be a problem. Regards, Christian

Hi there, I have found a bug in gil's channel.hpp. I'll commit the fix plus some test code later today. Regards, Christian
participants (1)
-
Christian Henning