Skip to content

Commit e2e9294

Browse files
committed
flip Image data, fixes #1, fixes #2
1 parent 125e328 commit e2e9294

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

CvPlot/inc/CvPlot/imp/Image.ipp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ public:
7070
int _interpolation = cv::INTER_AREA;
7171
cv::Scalar _nanColor;
7272

73-
cv::Mat3b _flipped;
74-
bool _flipVert = false;
73+
cv::Mat _flippedMat;
74+
cv::Mat3b _flippedBgr;
75+
bool _flipVert = false;
7576
bool _flipHorz = false;
7677

7778
void updateFlipped() {
@@ -80,9 +81,17 @@ public:
8081
}
8182
if (_flipVert || _flipHorz) {
8283
int code = (_flipVert&&_flipHorz) ? -1 : (_flipVert ? 0 : +1);
83-
cv::flip(_matBgr, _flipped, code);
84-
}else {
85-
_flipped = _matBgr;
84+
if (_flippedMat.data == _mat.data) {
85+
_flippedMat = _flippedMat.clone();
86+
}
87+
if (_flippedBgr.data == _matBgr.data) {
88+
_flippedBgr = _matBgr.clone();
89+
}
90+
cv::flip(_mat, _flippedMat, code);
91+
cv::flip(_matBgr, _flippedBgr, code);
92+
}else {
93+
_flippedMat = _mat;
94+
_flippedBgr = _matBgr;
8695
}
8796
}
8897
void render(RenderTarget & renderTarget) {
@@ -103,7 +112,7 @@ public:
103112
_flipVert = flipVert;
104113
updateFlipped();
105114
}
106-
Internal::paint(_flipped, innerMat, matRectDst, _interpolation, _mat);
115+
Internal::paint(_flippedBgr, innerMat, matRectDst, _interpolation, _flippedMat);
107116
}
108117
void updateAutoPosition() {
109118
if (_autoPosition) {

0 commit comments

Comments
 (0)