diff options
author | Tiago Conceição <Tiago_caza@hotmail.com> | 2021-02-16 01:30:26 +0300 |
---|---|---|
committer | Tiago Conceição <Tiago_caza@hotmail.com> | 2021-02-16 01:30:26 +0300 |
commit | f69a0f1175603e87558e0587e5a29ea882ef7e9b (patch) | |
tree | cd8534e3c6188c0cb5727697d8699bfc419b9d45 /UVtools.Core/Extensions/EmguExtensions.cs | |
parent | a78703662ec6bfb575df283c1e1b4e4776723b43 (diff) |
v2.4.6v2.4.6
* **(Improvement) Calibration - Elephant Foot:** (#145)
* Remove text from bottom layers to prevent islands from not adhering to plate
* Add a option to extrude text up to a height
* **(Improvement) Calibration - Exposure time finder:** (#144)
* Increase the left and right margin to 10mm
* Allow to iterate over pixel brightness and generate dimmed objects to test multiple times at once
* **(Fix) File format PWS:**
* Some files would produce black layers if pixels are not full whites, Antialiasing level was not inherit from source
* Antialiasing level was forced 1 and not read the value from file properties
* Antialiasing threshold pixel math was producing the wrong pixel value
* **(Fix) Raw images (jpg, png, etc):** (#146)
* Set layer height to be 0.01mm by default to allow the use of some tools
* When add layers by clone or other tool it don't update layers height, positions, indexes, leading to crashes
* **(Fix) Actions - Import Layers:** (#146, #147)
* ROI calculation error leading to not process images that can potential fit inside the volumes
* Out-of-bounds calculation for Stack type
* Replace type was calculating out-of-bounds calculation like Stack type when is not required to and can lead to skip images
* Better image ROI colection for Insert and Replace types instead of capture the center most
* (Fix) Settings window: Force a redraw on open to fix auto sizes
Diffstat (limited to 'UVtools.Core/Extensions/EmguExtensions.cs')
-rw-r--r-- | UVtools.Core/Extensions/EmguExtensions.cs | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/UVtools.Core/Extensions/EmguExtensions.cs b/UVtools.Core/Extensions/EmguExtensions.cs index b5ed369..2eaa12a 100644 --- a/UVtools.Core/Extensions/EmguExtensions.cs +++ b/UVtools.Core/Extensions/EmguExtensions.cs @@ -8,6 +8,7 @@ using System; using System.Drawing; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Emgu.CV; using Emgu.CV.CvEnum; @@ -275,15 +276,25 @@ namespace UVtools.Core.Extensions return mat; } - public static Mat RoiFromCenter(this Mat mat, Size size) + public static Mat RoiFromCenter(this Mat mat, Size targetSize, Rectangle roi) { - if (size == mat.Size) return mat; - return new Mat(mat, new Rectangle( - mat.Size.Width / 2 - size.Width / 2, - mat.Size.Height / 2 - size.Height / 2, - size.Width, - size.Height - )); + if (targetSize == mat.Size) return mat; + var newMat = InitMat(targetSize); + + var roiMat = new Mat(mat, roi); + + + //int xStart = mat.Width / 2 - targetSize.Width / 2; + //int yStart = mat.Height / 2 - targetSize.Height / 2; + + var newMatRoi = new Mat(newMat, new Rectangle( + targetSize.Width / 2 - roi.Width / 2, + targetSize.Height / 2 - roi.Height / 2, + roi.Width, + roi.Height + )); + roiMat.CopyTo(newMatRoi); + return newMat; } } |