10{
11
12
13
14
15
16
17
18
19 int totalWidth = 0;
20 int maxHeight = 0;
21 int channels = 0;
22
23 struct ImageData {
24 unsigned char* data;
25 int width;
26 int height;
27 int channels;
28 };
29 std::vector<ImageData> images;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 int outWidth = totalWidth;
56 int outHeight = maxHeight;
57 int outChannels = channels;
58 size_t outSize = (size_t)outWidth * outHeight * outChannels;
59
60
61 std::vector<unsigned char> output(outSize, 0);
62
63
64 int xOffset = 0;
65 for (const auto& img : images) {
66 for (int y = 0; y < img.height; ++y) {
67
68 unsigned char* dstRow = &output[(y * outWidth + xOffset) * outChannels];
69
70 const unsigned char* srcRow = &img.data[y * img.width * img.channels];
71
72 std::memcpy(dstRow, srcRow, (size_t)img.width * outChannels);
73 }
74 xOffset += img.width;
75 }
76
77
78
79
80
81
82
83}