From previous questions 1 and 2, I have the following codes:
How to capture screen:
int width = glutGet(GLUT_WINDOW_WIDTH);
int height = glutGet(GLUT_WINDOW_HEIGHT);
std::vector< unsigned char > rgbdata(4*width*height);
glReadPixels(0, 0, width, height,GL_RGBA,GL_UNSIGNED_BYTE, &rgbdata[0]);
int save_result = SOIL_save_image
(
filename,
SOIL_SAVE_TYPE_PNG,
width, height, 4,
rgbdata.data()
);
and how to store in PNG:
#define png_infopp_NULL (png_infopp)NULL
#define int_p_NULL (int*)NULL
#include <boost/gil/gil_all.hpp>
#include <boost/gil/extension/io/png_dynamic_io.hpp>
using namespace boost::gil;
int main()
{
rgb8_image_t img(512, 512);
rgb8_pixel_t red(255, 0, 0);
fill_pixels(view(img), red);
png_write_view("redsquare.png", const_view(img));
}
I want to save the captured screen into a png
file.
Now, the question is how to cascade these codes to each other? Are these arrays convertible to each other?