MCPcopy Create free account
hub / github.com/WallBreaker2/op / CopyImageData

Function CopyImageData

libop/hook/DxCaptureCommon.cpp:8–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6namespace op::hook {
7
8void CopyImageData(char *dst_, const char *src_, int rows_, int cols_, int rowPitch, int fmt_) {
9 // assert(rowsPitch >= cols_ * 4);
10 if (rowPitch == cols_ * (fmt_ == IBF_R8G8B8 ? 3 : 4)) {
11 if (fmt_ == IBF_B8G8R8A8) {
12 ::memcpy(dst_, src_, rows_ * cols_ * 4);
13 } else if (fmt_ == IBF_R8G8B8A8) {
14 // pixels count
15 int n = rows_ * cols_;
16
17 for (int i = 0; i < n; ++i) {
18 dst_[0] = src_[2]; // b
19 dst_[1] = src_[1]; // g
20 dst_[2] = src_[0]; // r
21 dst_[3] = src_[3]; // a
22 dst_ += 4;
23 src_ += 4;
24 }
25 } else {
26 // pixels count
27 int n = rows_ * cols_;
28 for (int i = 0; i < n; ++i) {
29 *dst_++ = *src_++;
30 *dst_++ = *src_++;
31 *dst_++ = *src_++;
32 *dst_++ = (char)0xff; // dst is 4 B
33 }
34 }
35 } else {
36 const int dstPitch = cols_ * 4;
37 if (fmt_ == IBF_B8G8R8A8) {
38 for (int i = 0; i < rows_; ++i) {
39 ::memcpy(dst_, src_, dstPitch);
40 dst_ += dstPitch;
41 src_ += rowPitch;
42 }
43
44 } else if (fmt_ == IBF_R8G8B8A8) {
45 // pixels count
46
47 for (int i = 0; i < rows_; ++i) {
48 for (int j = 0; j < cols_; ++j) {
49 const char *p = src_ + j * 4; // offset
50 dst_[0] = p[2]; // b
51 dst_[1] = p[1]; // g
52 dst_[2] = p[0]; // r
53 dst_[3] = p[3]; // a
54 dst_ += 4; // notirc that dst ptr is increasing
55 }
56 src_ += rowPitch; // row increase
57 }
58
59 } else {
60 for (int i = 0; i < rows_; ++i) {
61 for (int j = 0; j < cols_; ++j) {
62 const char *p = src_ + j * 3; // offset
63 dst_[0] = p[0]; // b
64 dst_[1] = p[1]; // g
65 dst_[2] = p[2]; // r

Callers 4

write_shared_frameFunction · 0.85
CaptureFrameMethod · 0.85
write_shared_frameFunction · 0.85
dx9_captureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected