Skip to content
Snippets Groups Projects
Commit 9b206ac4 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ENH: avoid setting negative index + warnings

parent b3996385
Branches
Tags
No related merge requests found
......@@ -195,13 +195,18 @@ ImageViewManipulator
// center the region on the position under the cursor
IndexType origin = currentRegion.GetIndex();
double centerX = origin[0] + currentRegion.GetSize()[0]/2.;
double centerY = origin[1] + currentRegion.GetSize()[1]/2.;
double centerX = (double)(origin[0]) + (double)(currentRegion.GetSize()[0])/2.;
double centerY = (double)(origin[1]) + (double)(currentRegion.GetSize()[1])/2.;
// new index
// new origin
IndexType newIndex;
newIndex[0] = centerX - currentRegion.GetSize()[0]/scale/2.;
newIndex[0] = centerX - currentRegion.GetSize()[0]/scale/2.;
if (newIndex[0] < 0) newIndex[0] = 0;
newIndex[1] = centerY - currentRegion.GetSize()[1]/scale/2.;
if (newIndex[1] < 0) newIndex[1] = 0;
// set the new origin
currentRegion.SetIndex(newIndex);
// Constraint this region to the LargestPossibleRegion
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment