2using System.Threading.Tasks;
40 : base(
Variables, DefaultWidth, DefaultHeight)
50 : base(
Variables, Pixels.Width, Pixels.Height)
61 : base(
Settings, Pixels.Width, Pixels.Height)
77 if (!(this.pixels is
null))
79 Settings.Width = this.pixels.
Width;
80 Settings.Height = this.pixels.
Height;
84 SKSamplingOptions Options =
new SKSamplingOptions(SKCubicResampler.Mitchell);
86 using (SKSurface Surface = SKSurface.Create(
new SKImageInfo(Math.Max(Pixels.
Width,
this.pixels?.Width ?? 0),
87 Math.Max(Pixels.
Height,
this.pixels?.Height ?? 0), SKImageInfo.PlatformColorType, SKAlphaType.Premul)))
89 SKCanvas Canvas = Surface.Canvas;
93 Canvas.DrawImage(Bmp, 0, 0, Options);
96 if (!(this.pixels is
null))
100 Canvas.DrawImage(Image, 0, 0, Options);
104 using (SKImage Result = Surface.Snapshot())
122 if (!(this.pixels is
null))
124 Settings.Width = this.pixels.
Width;
125 Settings.Height = this.pixels.
Height;
129 SKSamplingOptions Options =
new SKSamplingOptions(SKCubicResampler.Mitchell);
131 using (SKSurface Surface = SKSurface.Create(
new SKImageInfo(Math.Max(Pixels.
Width,
this.pixels?.Width ?? 0),
132 Math.Max(Pixels.
Height,
this.pixels?.Height ?? 0), SKImageInfo.PlatformColorType, SKAlphaType.Premul)))
134 SKCanvas Canvas = Surface.Canvas;
136 if (!(this.pixels is
null))
140 Canvas.DrawImage(Image, 0, 0, Options);
146 Canvas.DrawImage(Bmp, 0, 0, Options);
149 using (SKImage Result = Surface.Snapshot())
165 States = Array.Empty<
object>();
176 return new Tuple<int, int>(this.pixels?.Width ?? 0, this.pixels?.Height ?? 0);
195 return (obj is
GraphBitmap B && (this.pixels?.
Equals(B.pixels) ?? (B.pixels is
null)));
201 return this.pixels?.GetHashCode() ?? 0;
217 if (!(this.pixels is
null))
219 Output.WriteStartElement(
"GraphBitmap");
220 Output.WriteAttributeString(
"width", this.pixels.
Width.ToString());
221 Output.WriteAttributeString(
"height", this.pixels.
Height.ToString());
223 Output.WriteElementString(
"Png", Convert.ToBase64String(
this.pixels.EncodeAsPng()));
225 Output.WriteEndElement();
235 int Width =
int.Parse(Xml.GetAttribute(
"width"));
236 int Height =
int.Parse(Xml.GetAttribute(
"height"));
238 foreach (XmlNode N
in Xml.ChildNodes)
240 if (N is XmlElement E && E.LocalName ==
"Png")
242 byte[] Data = Convert.FromBase64String(E.InnerText);
248 return Task.CompletedTask;
Base class for all types of elements.
Class managing a script expression.
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Handles bitmap-based graphs.
override bool Equals(object obj)
Compares the element to another. If elements are equal.
override Tuple< int, int > RecommendedBitmapSize
The recommended bitmap size of the graph, if such is available.
GraphBitmap(Variables Variables)
Handles bitmap-based graphs.
override ISemiGroupElement AddRight(ISemiGroupElement Element)
Tries to add an element to the current element, from the right.
GraphBitmap(Variables Variables, PixelInformation Pixels)
Handles bitmap-based graphs.
override void ExportGraph(XmlWriter Output)
Exports graph specifics to XML.
override int GetHashCode()
Calculates a hash code of the element. Hash code.
override Task ImportGraphAsync(XmlElement Xml)
Imports graph specifics from XML.
override ISemiGroupElement AddLeft(ISemiGroupElement Element)
Tries to add an element to the current element, from the left.
override bool UsesDefaultColor
If graph uses default color
GraphBitmap()
Handles bitmap-based graphs.
override bool TrySetDefaultColor(SKColor Color)
Tries to set the default color.
GraphBitmap(GraphSettings Settings, PixelInformation Pixels)
Handles bitmap-based graphs.
override string GetBitmapClickScript(double X, double Y, object[] States)
Gets script corresponding to a point in a generated bitmap representation of the graph.
override PixelInformation CreatePixels(GraphSettings Settings, out object[] States)
Creates a bitmap of the graph.
GraphBitmap(Variables Variables, int? DefaultWidth, int? DefaultHeight)
Handles bitmap-based graphs.
void Dispose()
IDisposable.Dispose
GraphSettings Settings
Graph settings available during creation.
Basic interface for all types of semigroup elements.