mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-30 04:04:03 -05:00
fix: keep a zms zoomed view still instead of sliding to the top left
This commit is contained in:
1 parent
30dedee84d
commit
a4abc1eaa1
2 files changed
+20
-2
No files matched your search
+3
-2
@@ -306,8 +306,9 @@ Image *StreamBase::prepareImage(Image *image, int pre_scaled_by) {
|
||||
}
|
||||
|
||||
Debug(3, "Cropping to %d,%d -> %d,%d %dx%din blown up image", lo_x, lo_y, hi_x, hi_y, hi_x-lo_x, hi_y-lo_y);
|
||||
// Scaled back to base_image dimensions
|
||||
last_crop = Box({lo_x*ZM_SCALE_BASE/cur_zoom, lo_y*ZM_SCALE_BASE/cur_zoom}, {hi_x*ZM_SCALE_BASE/cur_zoom, hi_y*ZM_SCALE_BASE/cur_zoom});
|
||||
// Scaled back to base_image dimensions; kept while the view is unchanged, since redoing it rounds towards 0,0.
|
||||
if ((cur_zoom != last_zoom) || (cur_x != last_x) || (cur_y != last_y))
|
||||
last_crop = Box({lo_x*ZM_SCALE_BASE/cur_zoom, lo_y*ZM_SCALE_BASE/cur_zoom}, {hi_x*ZM_SCALE_BASE/cur_zoom, hi_y*ZM_SCALE_BASE/cur_zoom});
|
||||
last_crop_width = base_image_width;
|
||||
last_crop_height = base_image_height;
|
||||
|
||||
|
||||
@@ -372,6 +372,23 @@ TEST_CASE("StreamBase::prepareImage starts a new zoom from the whole frame", "[S
|
||||
CHECK(used.crop().Hi().y_ == expected.Hi().y_);
|
||||
}
|
||||
|
||||
TEST_CASE("StreamBase::prepareImage keeps a zoomed view still from frame to frame", "[StreamBase]") {
|
||||
EnsureImageInit();
|
||||
Image frame(640, 480, ZM_COLOUR_RGB32, ZM_SUBPIX_ORDER_RGBA);
|
||||
TestStream stream;
|
||||
stream.setView(ZM_SCALE_BASE, 150);
|
||||
stream.setClick(100, 100);
|
||||
stream.prepare(&frame);
|
||||
const Box first = stream.crop();
|
||||
|
||||
for (int i = 0; i < 30; i++) stream.prepare(&frame);
|
||||
|
||||
CHECK(stream.crop().Lo().x_ == first.Lo().x_);
|
||||
CHECK(stream.crop().Lo().y_ == first.Lo().y_);
|
||||
CHECK(stream.crop().Hi().x_ == first.Hi().x_);
|
||||
CHECK(stream.crop().Hi().y_ == first.Hi().y_);
|
||||
}
|
||||
|
||||
TEST_CASE("StreamBase::preScaleDimensions") {
|
||||
const int kWidth = 640;
|
||||
const int kHeight = 480;
|
||||
|
||||
Reference in new issue
Block a user