
A few reviewers have remarked on whether GIL can handle more complex formats, such as packed RGB565 format, (i.e. 5 bits red, 6 bits green, 5 bits blue). Since we can handle even images representing syntethic functions, we can certainly handle packed pixels. We took a stab at providing a model for packed pixel formats and posted it here: http://opensource.adobe.com/gil/packed_pixel.hpp This just serves as an example. The code could be improved and made more generic. Here is how you can define a packed pixel of three channels: typedef packed3_pixel<rgb_t,boost::uint16_t,boost::uint8_t,5,11> rgb565_pixel_t; This defines an RGB pixel over 16-bit data. The first channel always starts at bit 0. The second channel starts at bit 5, and the third at bit 11. Of course, you can define a whole range of packed pixels. Here is an LAB pixel that fits in a byte: typedef packed3_pixel<lab_t,boost::uint8_t,boost::uint8_t,2,2> lab223_pixel_t; Here is example code of using packed pixels: boost::function_requires<HeterogeneousPixelValueConcept<rgb565_pixel_t>
(); boost::function_requires<ChannelConcept<rgb565_pixel_t::kth_channel_t<0> ::reference> >();
typedef type_from_x_iterator<rgb565_pixel_t*>::view_t rgb565_view_t; typedef image<rgb565_view_t> rgb565_image_t; // Read a test image rgb8_image_t unpacked_image; jpeg_read_image("test.jpg",unpacked_image); // copy it into packed 565 form rgb565_image_t packed565_image(get_dimensions(unpacked_image)); copy_pixels(color_converted_view<rgb565_pixel_t>(view(unpacked_image),pa cked3_color_converter()),view(packed565_image)); // save it back unpacked. You will see dithering artifacts, especially for channels of low bit depth jpeg_write_view("test2.jpg",color_converted_view<rgb8_pixel_t>(view(pack ed565_image),packed3_color_converter())); // Invoke gradient on the packed data directly. Note: You need the most // generic version of x_gradient that supports heterogeneous pixels rgb8_image_t gradient(get_dimensions(unpacked_image)); x_gradient(view(packed565_image), view(gradient)); Note that everything you can do with GIL already automatically extends to packed pixels. You can run GIL heterogeneous algorithms on them. You can color convert them. You can include them in runtime types... Most importantly, GIL core does not need to change. Lubomir