mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Node editor - Add SKBitmap preview to cables
This commit is contained in:
parent
c597d62c77
commit
567f6098d3
@ -83,6 +83,9 @@
|
||||
<DataTemplate DataType="core:Numeric">
|
||||
<TextBlock Text="{Binding}" FontFamily="Consolas"/>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="skiaSharp:SKBitmap">
|
||||
<SKBitmapControl Bitmap="{Binding}"></SKBitmapControl>
|
||||
</DataTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}" FontFamily="Consolas"/>
|
||||
</DataTemplate>
|
||||
|
||||
@ -5,7 +5,7 @@ using SkiaSharp;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Image;
|
||||
|
||||
[Node("Capture Screen", "Captures a region of the screen", "Image", OutputType = typeof(SKImage))]
|
||||
[Node("Capture Screen", "Captures a region of the screen", "Image", OutputType = typeof(SKBitmap))]
|
||||
public class CaptureScreenNode : Node<object, CaptureScreenNodeCustomViewModel>
|
||||
{
|
||||
#region Properties & Fields
|
||||
@ -30,7 +30,7 @@ public class CaptureScreenNode : Node<object, CaptureScreenNodeCustomViewModel>
|
||||
|
||||
private CaptureZone _captureZone;
|
||||
|
||||
public OutputPin<SKImage> Output { get; set; }
|
||||
public OutputPin<SKBitmap> Output { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -39,9 +39,9 @@ public class CaptureScreenNode : Node<object, CaptureScreenNodeCustomViewModel>
|
||||
public CaptureScreenNode()
|
||||
: base("Capture Screen", "Captures a region of the screen")
|
||||
{
|
||||
Output = CreateOutputPin<SKImage>("Image");
|
||||
Output = CreateOutputPin<SKBitmap>("Image");
|
||||
|
||||
_captureZone = _screenCapture.RegisterCaptureZone(4500, 700, 256, 256, 1);
|
||||
_captureZone = _screenCapture.RegisterCaptureZone(20, 20, 256, 256, 1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -56,7 +56,7 @@ public class CaptureScreenNode : Node<object, CaptureScreenNodeCustomViewModel>
|
||||
if (capture.IsEmpty) return;
|
||||
|
||||
fixed (byte* ptr = capture)
|
||||
Output.Value = SKImage.FromPixels(new SKImageInfo(_captureZone.Width, _captureZone.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), new IntPtr(ptr), _captureZone.Stride);
|
||||
Output.Value = SKBitmap.FromImage(SKImage.FromPixels(new SKImageInfo(_captureZone.Width, _captureZone.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), new IntPtr(ptr), _captureZone.Stride));
|
||||
|
||||
//TODO DarthAffe 18.08.2022: Dispose Output or better reuse it
|
||||
}
|
||||
|
||||
@ -6,12 +6,12 @@ using SkiaSharp;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Image;
|
||||
|
||||
[Node("Quantize", "Quantizes the image into key-colors", "Image", InputType = typeof(SKImage), OutputType = typeof(SKColor))]
|
||||
[Node("Quantize", "Quantizes the image into key-colors", "Image", InputType = typeof(SKBitmap), OutputType = typeof(SKColor))]
|
||||
public class QuantizeNode : Node
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPin<SKImage> Image { get; set; }
|
||||
public InputPin<SKBitmap> Image { get; set; }
|
||||
|
||||
public OutputPin<SKColor> Vibrant { get; set; }
|
||||
public OutputPin<SKColor> Muted { get; set; }
|
||||
@ -27,7 +27,7 @@ public class QuantizeNode : Node
|
||||
public QuantizeNode()
|
||||
: base("Quantize", "Quantizes the image into key-colors")
|
||||
{
|
||||
Image = CreateInputPin<SKImage>("Image");
|
||||
Image = CreateInputPin<SKBitmap>("Image");
|
||||
|
||||
Vibrant = CreateOutputPin<SKColor>("Vibrant");
|
||||
Muted = CreateOutputPin<SKColor>("Muted");
|
||||
@ -45,8 +45,7 @@ public class QuantizeNode : Node
|
||||
{
|
||||
if (Image.Value == null) return;
|
||||
|
||||
using SKBitmap bitmap = SKBitmap.FromImage(Image.Value);
|
||||
SKColor[] colorPalette = ColorQuantizer.Quantize(bitmap.Pixels, 32); //TODO DarthAffe 18.08.2022: Palette-Size as input
|
||||
SKColor[] colorPalette = ColorQuantizer.Quantize(Image.Value.Pixels, 32); //TODO DarthAffe 18.08.2022: Palette-Size as input
|
||||
ColorSwatch swatch = ColorQuantizer.FindAllColorVariations(colorPalette, true);
|
||||
|
||||
Vibrant.Value = swatch.Vibrant;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user