public static ConvolutionFilter FromXml(XElement xFilter) { var xMatrix = xFilter.RequiredElement("matrix"); var xReserved = xFilter.Attribute("reserved"); var filter = new ConvolutionFilter { Divisor = xFilter.RequiredDoubleAttribute("divisor"), Bias = xFilter.RequiredDoubleAttribute("bias") }; var xRows = xMatrix.Elements().ToList(); var height = xRows.Count; var width = xMatrix.Elements().First().Elements().Count(); filter.Matrix = new double[height, width]; for (var y = 0; y < filter.MatrixY; y++) { var xRow = xRows[y]; var xCols = xRow.Elements().ToList(); for (var x = 0; x < filter.MatrixX; x++) { var xCol = xCols[x]; filter.Matrix[y, x] = CommonFormatter.ParseDouble(xCol.Value); } } filter.DefaultColor = XColorRGBA.FromXml(xFilter.RequiredElement("color").Element("Color")); if (xReserved != null) { filter.Reserved = byte.Parse(xReserved.Value); } filter.Clamp = xFilter.RequiredBoolAttribute("clamp"); filter.PreserveAlpha = xFilter.RequiredBoolAttribute("preserveAlpha"); return(filter); }
public static ZoneData FromXml(XElement xZoneData) { var xPosition = xZoneData.Attribute("position"); var xSize = xZoneData.Attribute("size"); return(new ZoneData { Position = CommonFormatter.ParseDouble(xPosition.Value), Size = CommonFormatter.ParseDouble(xSize.Value) }); }
private static double GetFocalPoint(XElement xFillStyle) { var xFocalPoint = xFillStyle.Attribute("focalPoint"); return(CommonFormatter.ParseDouble(xFocalPoint.Value)); }