mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-12-01 04:38:35 -05:00
Merge pull request #6404 from AJ0070/fix-stream-zoom-reset
fix: reset the stream crop when zoom returns to 100%
This commit is contained in:
2 files changed
+35
No files matched your search
@@ -220,6 +220,12 @@ Image *StreamBase::prepareImage(Image *image, int pre_scaled_by) {
|
||||
const unsigned short cur_x = x.load();
|
||||
const unsigned short cur_y = y.load();
|
||||
|
||||
if (cur_zoom == ZM_SCALE_BASE) {
|
||||
// Not zoomed, so a later zoom-in starts from the whole frame
|
||||
last_crop = Box();
|
||||
last_crop_width = last_crop_height = 0;
|
||||
}
|
||||
|
||||
if (cur_zoom != 100) {
|
||||
int base_image_width = image->Width(),
|
||||
base_image_height = image->Height(),
|
||||
|
||||
@@ -343,6 +343,35 @@ TEST_CASE("StreamBase::prepareImage keeps a zoom across a change of resolution")
|
||||
CHECK(sent->Height() == 480);
|
||||
}
|
||||
|
||||
TEST_CASE("StreamBase::prepareImage starts a new zoom from the whole frame", "[StreamBase]") {
|
||||
// Zooming out to 100% shows the whole frame again. A later zoom-in click is
|
||||
// in that whole-frame view, so it must not be mapped through the crop left
|
||||
// behind by the earlier zoom.
|
||||
EnsureImageInit();
|
||||
Image frame(640, 480, ZM_COLOUR_RGB32, ZM_SUBPIX_ORDER_RGBA);
|
||||
|
||||
TestStream fresh;
|
||||
fresh.setView(ZM_SCALE_BASE, 200);
|
||||
fresh.setClick(320, 240);
|
||||
fresh.prepare(&frame);
|
||||
const Box expected = fresh.crop();
|
||||
|
||||
TestStream used;
|
||||
used.setView(ZM_SCALE_BASE, 200);
|
||||
used.setClick(600, 440);
|
||||
used.prepare(&frame);
|
||||
used.setView(ZM_SCALE_BASE, 100);
|
||||
used.prepare(&frame);
|
||||
used.setView(ZM_SCALE_BASE, 200);
|
||||
used.setClick(320, 240);
|
||||
used.prepare(&frame);
|
||||
|
||||
CHECK(used.crop().Lo().x_ == expected.Lo().x_);
|
||||
CHECK(used.crop().Lo().y_ == expected.Lo().y_);
|
||||
CHECK(used.crop().Hi().x_ == expected.Hi().x_);
|
||||
CHECK(used.crop().Hi().y_ == expected.Hi().y_);
|
||||
}
|
||||
|
||||
TEST_CASE("StreamBase::preScaleDimensions") {
|
||||
const int kWidth = 640;
|
||||
const int kHeight = 480;
|
||||
|
||||
Reference in new issue
Block a user