static public IColorTable FromFile(string path) { IColorTable ct = null; XmlReader r = null; try { r = XmlReader.Create(path); r.ReadToFollowing("ColorTable"); ColorTableType ctt = (ColorTableType)Enum.Parse(typeof(ColorTableType), r["Type"]); int cts = int.Parse(r["Size"]); ScalingAlgorithms sa = (ScalingAlgorithms)Enum.Parse(typeof(ScalingAlgorithms), r["Scale"]); double min = double.Parse(r["Minimum"]); double max = double.Parse(r["Maximum"]); ct = ColorTableFactory.Create(ctt); if (ct != null) { ct.ScalingAlgorithm = ScalingAlgorithmFactory.Create(sa); ct.Initialize(cts, min, max); } } finally { if (r != null) { r.Close(); } } return(ct); }
private void ResetColorTable() { IColorTable ct = ColorTableFactory.Create(_modelState.ColorTable.Type); ct.Initialize(1 << _modelState.ColorTable.Depth, _modelState.PixelMinimum, _modelState.PixelMaximum); ct.ScalingAlgorithm = ScalingAlgorithmFactory.Create(_modelState.ColorTable.ScalingAlgorithmType); _colorTable = ct; }