@@ -47,6 +47,11 @@ void SolumIGTL::setNodeName(const QString &name)
47
47
nodeName_ = name.toStdString ();
48
48
}
49
49
50
+ void SolumIGTL::setFlip (bool flip)
51
+ {
52
+ flip_ = flip;
53
+ }
54
+
50
55
void SolumIGTL::sendImage (const SolumImage& img, double micronsPerPixel)
51
56
{
52
57
if (!isClientConnected ())
@@ -74,9 +79,25 @@ void SolumIGTL::sendImage(const SolumImage& img, double micronsPerPixel)
74
79
const auto spacing = (micronsPerPixel / 1000.0 );
75
80
msg_->SetSpacing (spacing, spacing, 1 .0f );
76
81
77
- // Even C++23 does not have output ranges anyway...
78
- // (https://thephd.dev/output-ranges)
79
- memcpy (msg_->GetScalarPointer (), img.img_ .data (), img.img_ .size_bytes ());
82
+ if (flip_)
83
+ {
84
+ // Copy the image upside down
85
+ const auto stride = (img.width_ * (img.bpp_ / 8 ));
86
+ auto * dst_row = reinterpret_cast <std::byte *>(msg_->GetScalarPointer ());
87
+ auto * src_row = (img.img_ .data () + img.img_ .size_bytes () - stride);
88
+ for (int y = 0 ; y < img.height_ ; y++)
89
+ {
90
+ memcpy (dst_row, src_row, stride);
91
+ dst_row += stride;
92
+ src_row -= stride;
93
+ }
94
+ }
95
+ else
96
+ {
97
+ // Even C++23 does not have output ranges anyway...
98
+ // (https://thephd.dev/output-ranges)
99
+ memcpy (msg_->GetScalarPointer (), img.img_ .data (), img.img_ .size_bytes ());
100
+ }
80
101
81
102
msg_->Pack ();
82
103
if (client_->Send (msg_->GetPackPointer (), msg_->GetPackSize ()) == 0 )
0 commit comments