| 28 | } |
| 29 | |
| 30 | void write_shared_frame(std::span<std::byte> sharedFrame, HWND hwnd, UINT width, UINT height, const void *source, |
| 31 | int sourceRows, int sourceCols, int rowPitch, int format) { |
| 32 | // 使用 span 明确区分帧头和像素区,避免共享内存裸指针偏移散落在捕获逻辑里。 |
| 33 | auto frameInfoBytes = sharedFrame.first(sizeof(FrameInfo)); |
| 34 | auto pixelBytes = sharedFrame.subspan(sizeof(FrameInfo)); |
| 35 | |
| 36 | reinterpret_cast<FrameInfo *>(frameInfoBytes.data())->format(hwnd, width, height); |
| 37 | CopyImageData(reinterpret_cast<char *>(pixelBytes.data()), static_cast<const char *>(source), sourceRows, |
| 38 | sourceCols, rowPitch, format); |
| 39 | } |
| 40 | |
| 41 | } // namespace |
| 42 |
no test coverage detected