From 8703dac09adc10ddcf5fa411a2f512c31212449c Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Tue, 17 Mar 2020 16:46:23 +0100 Subject: [PATCH] Remove cropping options --- src/ImageSharp/Formats/WebP/Vp8Io.cs | 12 ------- .../Formats/WebP/WebPLossyDecoder.cs | 32 +++++++------------ 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/ImageSharp/Formats/WebP/Vp8Io.cs b/src/ImageSharp/Formats/WebP/Vp8Io.cs index feb763129f..527ef02f05 100644 --- a/src/ImageSharp/Formats/WebP/Vp8Io.cs +++ b/src/ImageSharp/Formats/WebP/Vp8Io.cs @@ -9,14 +9,12 @@ namespace SixLabors.ImageSharp.Formats.WebP { /// /// Gets or sets the picture width in pixels (invariable). - /// Original, uncropped dimensions. /// The actual area passed to put() is stored in /> field. /// public int Width { get; set; } /// /// Gets or sets the picture height in pixels (invariable). - /// Original, uncropped dimensions. /// The actual area passed to put() is stored in /> field. /// public int Height { get; set; } @@ -61,16 +59,6 @@ namespace SixLabors.ImageSharp.Formats.WebP /// public int UvStride { get; set; } - public bool UseCropping { get; set; } - - public int CropLeft { get; set; } - - public int CropRight { get; set; } - - public int CropTop { get; set; } - - public int CropBottom { get; set; } - public bool UseScaling { get; set; } public int ScaledWidth { get; set; } diff --git a/src/ImageSharp/Formats/WebP/WebPLossyDecoder.cs b/src/ImageSharp/Formats/WebP/WebPLossyDecoder.cs index db1e254fae..4de0beaf83 100644 --- a/src/ImageSharp/Formats/WebP/WebPLossyDecoder.cs +++ b/src/ImageSharp/Formats/WebP/WebPLossyDecoder.cs @@ -632,19 +632,15 @@ namespace SixLabors.ImageSharp.Formats.WebP yEnd -= extraYRows; } - if (yEnd > io.CropBottom) + if (yEnd > io.Height) { - yEnd = io.CropBottom; // make sure we don't overflow on last row. + yEnd = io.Height; // make sure we don't overflow on last row. } if (yStart < yEnd) { - io.Y = io.Y.Slice(io.CropLeft); - io.U = io.U.Slice(io.CropLeft); - io.V = io.V.Slice(io.CropLeft); - - io.MbY = yStart - io.CropTop; - io.MbW = io.CropRight - io.CropLeft; + io.MbY = yStart; + io.MbW = io.Width; io.MbH = yEnd - yStart; this.EmitRgb(dec, io); } @@ -705,7 +701,7 @@ namespace SixLabors.ImageSharp.Formats.WebP // Move to last row. curY = curY.Slice(io.YStride); - if (io.CropTop + yEnd < io.CropBottom) + if (yEnd < io.Height) { // Save the unfinished samples for next call (as we're not done yet). curY.Slice(0, mbw).CopyTo(tmpYBuffer); @@ -1315,11 +1311,6 @@ namespace SixLabors.ImageSharp.Formats.WebP var io = default(Vp8Io); io.Width = (int)pictureHeader.Width; io.Height = (int)pictureHeader.Height; - io.UseCropping = false; - io.CropTop = 0; - io.CropLeft = 0; - io.CropRight = io.Width; - io.CropBottom = io.Height; io.UseScaling = false; io.ScaledWidth = io.Width; io.ScaledHeight = io.ScaledHeight; @@ -1340,11 +1331,10 @@ namespace SixLabors.ImageSharp.Formats.WebP } else { - // For simple filter, we can filter only the cropped region. We include 'extraPixels' on - // the other side of the boundary, since vertical or horizontal filtering of the previous - // macroblock can modify some abutting pixels. - dec.TopLeftMbX = (io.CropLeft - extraPixels) >> 4; - dec.TopLeftMbY = (io.CropTop - extraPixels) >> 4; + // For simple filter, we include 'extraPixels' on the other side of the boundary, + // since vertical or horizontal filtering of the previous macroblock can modify some abutting pixels. + dec.TopLeftMbX = (-extraPixels) >> 4; + dec.TopLeftMbY = (-extraPixels) >> 4; if (dec.TopLeftMbX < 0) { dec.TopLeftMbX = 0; @@ -1357,8 +1347,8 @@ namespace SixLabors.ImageSharp.Formats.WebP } // We need some 'extra' pixels on the right/bottom. - dec.BottomRightMbY = (io.CropBottom + 15 + extraPixels) >> 4; - dec.BottomRightMbX = (io.CropRight + 15 + extraPixels) >> 4; + dec.BottomRightMbY = (io.Height + 15 + extraPixels) >> 4; + dec.BottomRightMbX = (io.Width + 15 + extraPixels) >> 4; if (dec.BottomRightMbX > dec.MbWidth) { dec.BottomRightMbX = dec.MbWidth;