3

How to resize png image with alpha canal in boost::gil?

boost::gil::rgb8_image_t image;
boost::gil::rgb8_image_t newSize(640, 480);
boost::gil::png_read_and_convert_image("input.png",image);
boost::gil::resize_view(const_view(image), view(newSize), boost::gil::bilinear_sampler());
boost::gil::png_write_view("output.png",const_view(newSize));
mloskot
  • 37,086
  • 11
  • 109
  • 136
  • Is this a question or the answer? If it's question, what is the question? That code not working? Is it? Why not? etc. – sehe Nov 18 '15 at 13:59
  • Besides, `resize_view` is not in boost. What are you using? – sehe Nov 18 '15 at 14:14

1 Answers1

1

Your problem is not with resizing but with loading the original PNG in the first place, because boost::gil::rgb8_image_t is an image type without an alpha channel.

The solution is to simply use boost::gil::rgba8_image_t, which includes an alpha channel.

Christian Hackl
  • 27,051
  • 3
  • 32
  • 62