From 91f95b44c3bfa8edf8585ffbc54ceb920d278406 Mon Sep 17 00:00:00 2001 From: Andrew Silver Date: Sat, 3 Feb 2024 03:17:00 +1100 Subject: [PATCH 1/3] [PATCH] Added offsets to GenericImageView to compensate for the now-deprecated bounds call. Fixes #2118 --- src/image.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/image.rs b/src/image.rs index 738ad41258..bc86dcf027 100644 --- a/src/image.rs +++ b/src/image.rs @@ -1025,6 +1025,11 @@ pub trait GenericImageView { h } + /// The offsets of this image view relative to the underlying image buffer. + fn offsets(&self) -> (u32, u32) { + (0, 0) + } + /// The bounding rectangle of this image. #[deprecated = "This method has inconsistent behavior between implementations (#1829). Use `dimensions` instead"] fn bounds(&self) -> (u32, u32, u32, u32); @@ -1419,6 +1424,10 @@ where (self.xstride, self.ystride) } + fn offsets(&self) -> (u32, u32) { + (self.xoffset, self.yoffset) + } + fn bounds(&self) -> (u32, u32, u32, u32) { (self.xoffset, self.yoffset, self.xstride, self.ystride) } From 34df52abb5005cfaf2ed4fa36d28c9ae2ffa7314 Mon Sep 17 00:00:00 2001 From: brykgroup-andrews <153681020+brykgroup-andrews@users.noreply.github.com> Date: Tue, 20 Feb 2024 03:51:15 +1100 Subject: [PATCH 2/3] Moved offsets() from GenericImageView to SubImage --- src/image.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/image.rs b/src/image.rs index bc86dcf027..4df94afef9 100644 --- a/src/image.rs +++ b/src/image.rs @@ -1025,11 +1025,6 @@ pub trait GenericImageView { h } - /// The offsets of this image view relative to the underlying image buffer. - fn offsets(&self) -> (u32, u32) { - (0, 0) - } - /// The bounding rectangle of this image. #[deprecated = "This method has inconsistent behavior between implementations (#1829). Use `dimensions` instead"] fn bounds(&self) -> (u32, u32, u32, u32); @@ -1306,6 +1301,11 @@ impl SubImage { self.inner.ystride = height; } + /// The offsets of this subimage relative to the underlying image. + fn offsets(&self) -> (u32, u32) { + (self.inner.xoffset, self.inner.yoffset) + } + /// Convert this subimage to an ImageBuffer pub fn to_image(&self) -> ImageBuffer, Vec>> where @@ -1424,10 +1424,6 @@ where (self.xstride, self.ystride) } - fn offsets(&self) -> (u32, u32) { - (self.xoffset, self.yoffset) - } - fn bounds(&self) -> (u32, u32, u32, u32) { (self.xoffset, self.yoffset, self.xstride, self.ystride) } From 96f9c2ad15434a47cb608e3fa6733e51eccf4eae Mon Sep 17 00:00:00 2001 From: brykgroup-andrews <153681020+brykgroup-andrews@users.noreply.github.com> Date: Tue, 20 Feb 2024 03:54:52 +1100 Subject: [PATCH 3/3] Made offsets public due to being in a non-trait impl --- src/image.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image.rs b/src/image.rs index 4df94afef9..3fa81092d5 100644 --- a/src/image.rs +++ b/src/image.rs @@ -1302,7 +1302,7 @@ impl SubImage { } /// The offsets of this subimage relative to the underlying image. - fn offsets(&self) -> (u32, u32) { + pub fn offsets(&self) -> (u32, u32) { (self.inner.xoffset, self.inner.yoffset) }