Closed EMCP closed 2 years ago
I guess I am honing in on this example code now.. where we sort of extract the data for PNG creation.. ideally I'd like to make it a JPG within a buffer but.. a bit concerned I need to first
void ExtractAndConvertToIntVect(const SL::Screen_Capture::Image &img, std::vector<std::uint8_t> *dst, size_t dst_size)
{
assert(dst_size >= static_cast<size_t>(SL::Screen_Capture::Width(img) * SL::Screen_Capture::Height(img) * sizeof(SL::Screen_Capture::ImageBGRA)));
auto imgsrc = StartSrc(img);
std::cout << "image was contiguous, dst_size = " << std::to_string(dst_size) << std::endl;
for (auto h = 0; h < Height(img); h++) {
auto startimgsrc = imgsrc;
for (auto w = 0; w < Width(img); w++) {
dst->push_back(imgsrc->R);
dst->push_back(imgsrc->G);
dst->push_back(imgsrc->B);
imgsrc++;
}
imgsrc = SL::Screen_Capture::GotoNextRow(img, startimgsrc);
}
std::cout << "copied... " << std::to_string(dst_size) << std::endl;
}
This is still in progress as well, but looking how to translate the
SL::Screen_Capture::Image
tocv::Mat
.. purpose is so a client on the other side of the socket can read the bytes and display the frameIm sort of guessing it will be a sort of unisigned char array, using the dimensions sort of option.. but if anyone has already done this would appreciate to understand how to and share this example once finished