Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 1 | #include "flip_image.h" |
| 2 | |
| 3 | #define cimg_display 0 |
| 4 | #define cimg_use_jpeg |
| 5 | #define cimg_plugin "plugins/jpeg_buffer.h" |
| 6 | #include "third_party/cimg/CImg.h" |
| 7 | |
| 8 | void flip_image(const char *input, const int input_size, JOCTET *buffer, |
Austin Schuh | 9c03a53 | 2019-03-17 18:14:45 -0700 | [diff] [blame] | 9 | unsigned int *buffer_size, bool flip) { |
Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 10 | ::cimg_library::CImg<unsigned char> image; |
| 11 | image.load_jpeg_buffer((JOCTET *)(input), input_size); |
Austin Schuh | 9c03a53 | 2019-03-17 18:14:45 -0700 | [diff] [blame] | 12 | if (flip) { |
Tyler Chatow | d3384c2 | 2019-04-04 16:38:32 -0700 | [diff] [blame] | 13 | image.rotate(90); |
| 14 | } else { |
| 15 | image.rotate(270); |
Austin Schuh | 9c03a53 | 2019-03-17 18:14:45 -0700 | [diff] [blame] | 16 | } |
Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 17 | |
| 18 | image.save_jpeg_buffer(buffer, *buffer_size, 80); |
| 19 | } |