I've left you something really tasty for dessert - Boost's Generic Image Library or just Boost.GIL
, which allows you to manipulate images without worrying too much about image formats.
Let's do something simple and interesting with it. For example, let's make a program that negates any picture.
This recipe requires basic knowledge of C++, templates, and Boost.Variant
. The example requires linking against the png
library.
For simplicity of the example, we'll be working only with PNG images.
- Let's start by including the header files:
#include <boost/gil/gil_all.hpp> #include <boost/gil/extension/io/png_dynamic_io.hpp> #include <string>
- Now, we need to define the image types that we wish to work with:
int main(nt argc, char *argv[]) { typedef boost::mpl::vector< boost::gil::gray8_image_t, boost::gil::gray16_image_t, boost::gil::rgb8_image_t > img_types;
- Opening an existing PNG image...