Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PixelInformation.cs
1using SkiaSharp;
2
4{
8 public abstract class PixelInformation
9 {
10 private readonly byte[] binary;
11 private readonly int width;
12 private readonly int height;
13
20 public PixelInformation(byte[] Binary, int Width, int Height)
21 {
22 this.binary = Binary;
23 this.width = Width;
24 this.height = Height;
25 }
26
30 public byte[] Binary => this.binary;
31
35 public int Width => this.width;
36
40 public int Height => this.height;
41
47 public static PixelInformation FromImage(SKImage Image)
48 {
49 using (SKData Data = Image.Encode())
50 {
51 return new PixelInformationPng(Data.ToArray(), Image.Width, Image.Height);
52 }
53 }
54
64 public static PixelInformation FromRaw(SKColorType ColorType, byte[] Binary, int Width, int Height, int BytesPerRow)
65 {
66 return new PixelInformationRaw(ColorType, Binary, Width, Height, BytesPerRow);
67 }
68
73 public abstract SKImage CreateBitmap();
74
79 public virtual byte[] EncodeAsPng()
80 {
81 using (SKImage Image = this.CreateBitmap())
82 {
83 using (SKData Data = Image.Encode())
84 {
85 return Data.ToArray();
86 }
87 }
88 }
89
94 public abstract PixelInformationRaw GetRaw();
95
96 }
97}
Contains pixel information
PixelInformation(byte[] Binary, int Width, int Height)
Contains pixel information
abstract PixelInformationRaw GetRaw()
Gets raw pixel data.
static PixelInformation FromRaw(SKColorType ColorType, byte[] Binary, int Width, int Height, int BytesPerRow)
Gets the pixel information object from raw pixel data.
virtual byte[] EncodeAsPng()
Encodes the pixels into a binary PNG image.
abstract SKImage CreateBitmap()
Creates an SKImage image. It must be disposed by the caller.
byte[] Binary
Binary representation of pixels
static PixelInformation FromImage(SKImage Image)
Gets the pixel information from an SKImage.
Contains pixel information in PNG format
Contains pixel information in a raw unencoded format.