O'Reilly logo

Boost C++ Application Development Cookbook by Antony Polukhin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Manipulating images

I've left you something really tasty for dessert – Boost's Generic Image Library (GIL), which allows you to manipulate images and not care much about image formats.

Let's do something simple and interesting with it; let's make a program that negates any picture.

Getting ready

This recipe requires basic knowledge of C++, templates, and Boost.Variant. The example requires linking against the PNG library.

How to do it...

For simplicity, we'll be working with only PNG images.

  1. Let's start with including the header files:
    #include <boost/gil/gil_all.hpp>
    #include <boost/gil/extension/io/png_dynamic_io.hpp>
    #include <string>
  2. Now we need to define the image types that we wish to work with:
     typedef boost::mpl::vector< boost::gil::gray8_image_t, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required