Boost logo

Boost Users :

Subject: Re: [Boost-users] [GIL] Packing to 6 bytes
From: Lubomir Bourdev (lbourdev_at_[hidden])
Date: 2010-01-04 14:31:59


Hi Eloi,

Try calling copy_and_convert_pixels. I believe it does what you want.

Lubomir

From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Eloi Du Bois
Sent: Wednesday, December 16, 2009 2:18 AM
To: boost-users_at_[hidden]
Subject: [Boost-users] [GIL] Packing to 6 bytes

Hi,

I have a question:
I need to create a view that hold 12 bit channel data packed as follow:

0000R0000G0000B0000;0000R0000G0000B0000;0000R0000G0000B0000;....
Meaning that each channel is shifted by 4 bits.
The pixel is holden on 48 bits = 6 bytes.

I have created my view like as follow:
/// My 12 bits special rgb packed to 6 bytes
typedef const packed_channel_reference<uint64_t, 04, 12, true> rgb12_packed_channel0_t;
typedef const packed_channel_reference<uint64_t, 20, 12, true> rgb12_packed_channel1_t;
typedef const packed_channel_reference<uint64_t, 36, 12, true> rgb12_packed_channel2_t;
typedef mpl::vector3<rgb12_packed_channel0_t, rgb12_packed_channel1_t, rgb12_packed_channel2_t> rgb12_packed_channels_t;
typedef packed_pixel<packed_channel_value<48>, rgb12_packed_channels_t, rgb_layout_t> rgb12_packed_pixel_t;
typedef view_type_from_pixel<rgb12_packed_pixel_t>::type rgb12_packed_view_t;

The thing is that I would now like to copy data to another rgb16_view_t... But this is not working because, in my opinion, 48 bits is between 32 and 64.
I have been thinking of the solution that Christian gave me and that consist on doing something like this:
    T p( pData, 0 );

    for( typename DST_V::y_coord_t y = 0; y < height; ++y )
    {
        typename DST_V::x_iterator it = dst.row_begin( y );

        for( typename DST_V::x_coord_t x = 0; x < width; ++x )
        {
            color_convert( *p, *it );
            ++p;
            ++it;
        }
    }

where T is a bit_aligned_pixel_iterator and DST_V=rgb16_view_t but this can't be working on my case because channels are shifted by 4 bits !

If you could help me, I would really appreciate.
I think all those cases are a good robustness test for gil.

Regards,
Eloi.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net