Improving Image Converter
This commit is contained in:
parent
ac5f4ed2f9
commit
f4bfa7c9fd
5 changed files with 24 additions and 29 deletions
|
|
@ -315,10 +315,15 @@ namespace MatterHackers.MatterControl
|
|||
ComponentID = "4D9BD8DB-C544-4294-9C08-4195A409217A",
|
||||
SurfacedEditors = new List<string>
|
||||
{
|
||||
"$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Children<SmoothPathObject3D>.Children<ImageToPathObject3D_2>.Children<ImageObject3D>",
|
||||
"$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Children<SmoothPathObject3D>.Children<ImageToPathObject3D_2>.Children<ImageObject3D>.ImageSearch",
|
||||
"$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Children<SmoothPathObject3D>.Children<ImageToPathObject3D_2>.Image",
|
||||
"$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Children<SmoothPathObject3D>.Children<ImageToPathObject3D_2>.Children<ImageObject3D>.Invert",
|
||||
"$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Children<SmoothPathObject3D>.Children<ImageToPathObject3D_2>.Children<ImageObject3D>.AssetPath",
|
||||
"$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Children<SmoothPathObject3D>.Children<ImageToPathObject3D_2>.AnalysisType",
|
||||
"$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Children<SmoothPathObject3D>.Children<ImageToPathObject3D_2>.TransparencyMessage",
|
||||
"$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Children<SmoothPathObject3D>.Children<ImageToPathObject3D_2>.Histogram",
|
||||
"$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Height",
|
||||
"$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Children<SmoothPathObject3D>.SmoothDistance",
|
||||
"$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Children<SmoothPathObject3D>.Children<ImageToPathObject3D_2>",
|
||||
"$.Children<BaseObject3D>",
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -257,8 +257,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
byte[] sourceBuffer = sourceImage.GetBuffer();
|
||||
byte[] destBuffer = alphaImage.GetBuffer();
|
||||
//Parallel.For(0, sourceImage.Height, (y) =>
|
||||
for(int y = 0; y < sourceImage.Height; y++)
|
||||
Parallel.For(0, sourceImage.Height, (y) =>
|
||||
//for(int y = 0; y < sourceImage.Height; y++)
|
||||
{
|
||||
int imageOffset = sourceImage.GetBufferOffsetY(y);
|
||||
|
||||
|
|
@ -273,8 +273,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
destBuffer[imageBufferOffsetWithX + 2] = r;
|
||||
destBuffer[imageBufferOffsetWithX + 3] = GetAlphaFromHue(r, g, b, RangeStart, RangeEnd);
|
||||
}
|
||||
}
|
||||
//});
|
||||
//}
|
||||
});
|
||||
|
||||
alphaImage.MarkImageChanged();
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ either expressed or implied, of the FreeBSD Project.
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ClipperLib;
|
||||
|
|
@ -72,6 +71,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
/// <summary>
|
||||
/// This is the image after it has been processed into an alpha image
|
||||
/// </summary>
|
||||
[DisplayName("")]
|
||||
[JsonIgnore]
|
||||
[ImageDisplay(Margin = new int[] { 30, 3, 30, 3 }, MaxXSize = 400, Stretch = true)]
|
||||
public ImageBuffer Image
|
||||
|
|
@ -155,9 +155,11 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
public string TransparencyMessage { get; set; } = "Your image is processed as is with no modifications. Transparent pixels are ignored, only opaque pixels are considered in feature detection.";
|
||||
|
||||
|
||||
[DisplayName("")]
|
||||
[JsonIgnore]
|
||||
private ImageBuffer SourceImage => ((IImageProvider)this.Descendants().Where(i => i is IImageProvider).FirstOrDefault())?.Image;
|
||||
|
||||
[DisplayName("Select Range")]
|
||||
public Histogram Histogram { get; set; } = new Histogram();
|
||||
|
||||
public IVertexSource VertexSource { get; set; } = new VertexStorage();
|
||||
|
|
@ -252,6 +254,10 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
var _ = Image; // call this to make sure it is built
|
||||
Histogram.RebuildAlphaImage(SourceImage, alphaImage, Image, AnalysisType);
|
||||
}
|
||||
else
|
||||
{
|
||||
Image?.CopyFrom(SourceImage);
|
||||
}
|
||||
await Rebuild();
|
||||
}
|
||||
else if ((invalidateArgs.InvalidateType.HasFlag(InvalidateType.Properties) && invalidateArgs.Source == this))
|
||||
|
|
|
|||
|
|
@ -602,7 +602,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
GuiWidget imageWidget;
|
||||
if (imageDisplayAttribute?.Stretch == true)
|
||||
{
|
||||
imageWidget = new ResponsiveImageWidget(imageBuffer);
|
||||
var responsiveImageWidget = new ResponsiveImageWidget(imageBuffer);
|
||||
responsiveImageWidget.RenderCheckerboard = true;
|
||||
imageWidget = responsiveImageWidget;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -618,24 +620,6 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
imageWidget.Margin = new BorderDouble(0, 3);
|
||||
}
|
||||
|
||||
imageWidget.BeforeDraw += (s, e) =>
|
||||
{
|
||||
// render a checkerboard that can show through the alpha mask
|
||||
var g = e.Graphics2D;
|
||||
var w = (int)(10 * GuiWidget.DeviceScale);
|
||||
for (int x = 0; x < g.Width / w; x ++)
|
||||
{
|
||||
for (int y = 0; y < g.Height / w; y ++)
|
||||
{
|
||||
if (y % 2 == 0 && x % 2 == 1
|
||||
|| y % 2 == 1 && x % 2 == 0)
|
||||
{
|
||||
g.FillRectangle(x * w, y * w, x * w + w, y * w + w, Color.LightGray);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ImageBuffer GetImageCheckingForErrors()
|
||||
{
|
||||
var image = imageBuffer;
|
||||
|
|
@ -877,7 +861,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
if (property.PropertyInfo.GetCustomAttributes(true).OfType<GoogleSearchAttribute>().FirstOrDefault() != null)
|
||||
{
|
||||
rowContainer = GetImageSearchWidget(theme);
|
||||
rowContainer = NewImageSearchWidget(theme);
|
||||
}
|
||||
else if(object3D is AssetObject3D assetObject
|
||||
&& property.PropertyInfo.Name == "AssetPath")
|
||||
|
|
@ -1117,7 +1101,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return rowContainer;
|
||||
}
|
||||
|
||||
public static GuiWidget GetImageSearchWidget(ThemeConfig theme, string postPend = "silhouette")
|
||||
public static GuiWidget NewImageSearchWidget(ThemeConfig theme, string postPend = "silhouette")
|
||||
{
|
||||
var searchRow = new FlowLayoutWidget()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit e084f2a9b64b5e98827ee9929ff84f111a81a61c
|
||||
Subproject commit 07f063560762f7762553f6cd67de90ed89fd8463
|
||||
Loading…
Add table
Add a link
Reference in a new issue