MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / imageForActiveFrame

Function imageForActiveFrame

pj_widgets/src/RasterFrame.cpp:10–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8namespace PJ {
9
10QImage imageForActiveFrame(const unsigned char* data, int size_bytes) {
11 using namespace pj_raster;
12 if (data == nullptr || size_bytes < static_cast<int>(sizeof(ShmHeader))) {
13 return {};
14 }
15 const auto* hdr = reinterpret_cast<const ShmHeader*>(data);
16 if (hdr->magic != kShmMagic || hdr->version != kShmVersion || hdr->bytes_per_pixel != kBytesPerPixel ||
17 hdr->width == 0 || hdr->height == 0 || hdr->active_index >= hdr->buffer_count) {
18 return {};
19 }
20 const uint32_t need = shmTotalSize(hdr->width, hdr->height, hdr->bytes_per_pixel);
21 if (size_bytes < static_cast<int>(need)) {
22 return {};
23 }
24 const uint32_t off = bufferOffset(hdr->active_index, hdr->width, hdr->height, hdr->bytes_per_pixel);
25 const uchar* pixels = data + off;
26 return QImage(
27 pixels, static_cast<int>(hdr->width), static_cast<int>(hdr->height),
28 static_cast<int>(hdr->width * hdr->bytes_per_pixel), QImage::Format_RGB32);
29}
30
31} // namespace PJ

Callers 2

onSocketReadyReadMethod · 0.85
TESTFunction · 0.85

Calls 3

shmTotalSizeFunction · 0.85
bufferOffsetFunction · 0.85
QImageClass · 0.50

Tested by 1

TESTFunction · 0.68