Transfer PixelBox data with boost
I get an image from an Ogre rendertaget.
I get the pixelbox of the image :
Ogre::RenderTarget *rt = _window;
rt->update();
int width = rt->getWidth();
int height = rt->getHeight();
std::cout << "width=" << width << std::endl;
std::cout << "height=" << heig开发者_如何学Pythonht << std::endl;
uchar *data = new uchar[width * height * 3];
PixelBox pb(width, height, 1, PF_BYTE_RGB, data);
rt->copyContentsToMemory(pb);
After doing that, i want to get the pb.data (that's Ogre::uchar), write it in a buffer, and send it via a socket using boost. And don't see how to.
thanks.
Look at the http sync client for an example. The code you want is going to look like:
boost::asio::streambuf request;
std::ostream request_stream(&request);
request_stream << pb;
boost::asio::write(socket, request);
精彩评论