Skip to content

Commit a568eec

Browse files
improve documentation and struct name typo
1 parent 3564e7d commit a568eec

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/image/crop.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,17 @@ pub trait Crop: Sized {
3131
/// The type of this image after cropping (probably the same as before)
3232
type Cropped;
3333

34-
/// Reduce your image to a smaller part, usually to save memory.
34+
/// Crop the image to exclude unwanted pixels.
3535
/// Panics for invalid (larger than previously) bounds.
3636
/// The bounds are specified in absolute coordinates.
37-
/// Does not necessarily reduce allocation size of the current image:
38-
/// An rgba image will only be viewed in a smaller window instead of reallocating.
37+
/// Does not reduce allocation size of the current image, but instead only adjust a few boundary numbers.
38+
/// Use `reallocate_cropped()` on the return value to actually reduce the memory footprint.
3939
fn crop(self, bounds: IntegerBounds) -> Self::Cropped;
4040

4141
/// Reduce your image to a smaller part, usually to save memory.
4242
/// Crop if bounds are specified, return the original if no bounds are specified.
43+
/// Does not reduce allocation size of the current image, but instead only adjust a few boundary numbers.
44+
/// Use `reallocate_cropped()` on the return value to actually reduce the memory footprint.
4345
fn try_crop(self, bounds: Option<IntegerBounds>) -> CropResult<Self::Cropped, Self> {
4446
match bounds {
4547
Some(bounds) => CropResult::Cropped(self.crop(bounds)),
@@ -71,11 +73,15 @@ pub trait CropWhere<Sample>: Sized {
7173
/// The type of the cropped image (probably the same as the original image).
7274
type Cropped;
7375

74-
/// Crop away unwanted pixels from the border if they match the specified rule , usually to save memory.
76+
/// Crop away unwanted pixels from the border if they match the specified rule.
77+
/// Does not reduce allocation size of the current image, but instead only adjust a few boundary numbers.
78+
/// Use `reallocate_cropped()` on the return value to actually reduce the memory footprint.
7579
fn crop_where(self, discard_if: impl Fn(Sample) -> bool) -> CropResult<Self::Cropped, Self>;
7680

77-
/// Crop away unwanted pixels from the border if they match the specified color , usually to save memory.
81+
/// Crop away unwanted pixels from the border if they match the specified color.
7882
/// If you want discard based on a rule, use `crop_where` with a closure instead.
83+
/// Does not reduce allocation size of the current image, but instead only adjust a few boundary numbers.
84+
/// Use `reallocate_cropped()` on the return value to actually reduce the memory footprint.
7985
fn crop_where_eq(self, discard_color: impl Into<Sample>) -> CropResult<Self::Cropped, Self> where Sample: PartialEq;
8086

8187
/// Convert this data to cropped data without discarding any pixels.
@@ -209,19 +215,22 @@ impl InspectSample for Layer<AnyChannels<FlatSamples>> {
209215
// ALGORITHM IDEA: for arbitrary channels, find the most desired channel,
210216
// and process that first, keeping the processed bounds as starting point for the other layers
211217

212-
/// Realize a cropped view of the original data, by actually removing the unwanted original pixels,
218+
/// Realize a cropped view of the original data,
219+
/// by actually removing the unwanted original pixels,
213220
/// reducing the memory consumption.
214-
pub trait ApplyCropedView {
221+
/// Currently not supported for rgba images.
222+
pub trait ApplyCroppedView {
215223

216224
/// The simpler type after cropping is realized
217225
type Reallocated;
218226

219227
/// Make the cropping real by reallocating the underlying storage,
220-
/// with the goal of reducing total memory usage
228+
/// with the goal of reducing total memory usage.
229+
/// Currently not supported for rgba images.
221230
fn reallocate_cropped(self) -> Self::Reallocated;
222231
}
223232

224-
impl ApplyCropedView for Layer<CroppedChannels<AnyChannels<FlatSamples>>> {
233+
impl ApplyCroppedView for Layer<CroppedChannels<AnyChannels<FlatSamples>>> {
225234
type Reallocated = Layer<AnyChannels<FlatSamples>>;
226235

227236
fn reallocate_cropped(self) -> Self::Reallocated {

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub mod prelude {
6060
image::ReadImage, layers::ReadChannels,
6161
};
6262

63-
pub use crate::image::crop::{Crop, CropWhere, CropResult, InspectSample, CroppedChannels, ApplyCropedView};
63+
pub use crate::image::crop::{Crop, CropWhere, CropResult, InspectSample, CroppedChannels, ApplyCroppedView};
6464
}
6565

6666
pub use traits::*;

0 commit comments

Comments
 (0)