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; }
static public IImage FromFile(string nicFile) { IImage ii = null; StreamReader sr = null; XmlReader r = null; ImageTypes it = ImageTypes.Indexed; Color nan = Color.Empty; try { sr = new StreamReader(nicFile); r = XmlReader.Create(sr.BaseStream); r.ReadToFollowing("ImageConfig"); it = (ImageTypes)Enum.Parse(typeof(ImageTypes), r["Type"]); nan = Color.FromArgb(int.Parse(r["NaNColor"])); r.Close(); r = null; sr.Close(); sr = null; IColorTable ct = ColorTableFactory.FromFile(nicFile); IColorMap cm = ColorMapFactory.FromFile(nicFile); ii = ImageFactory.Create(it); if (ii != null) { ii.ColorTable = ct; ii.ColorMap = cm; ii.InvalidPixelValueColor = nan; } } finally { if (r != null) { r.Close(); } if (sr != null) { sr.Close(); } } return(ii); }