private bool RangeIsOK(GeoDo.RSS.Core.DF.enumDataType dataType, BandValueColorPair[] values) { if (values == null) { MsgBox.ShowInfo("选择索引空间不能应用与当前显示影像,请重新选择或者选择\"调色板填色\"功能进行填色。"); return(false); } // int minValue = int.MaxValue; int maxValue = int.MinValue; foreach (BandValueColorPair v in values) { if (v.MinValue < minValue) { minValue = v.MinValue; } if (v.MaxValue > maxValue) { maxValue = v.MaxValue; } } // int limitSmallValue = -1; int limitLargeValue = -1; GetLimitValueOfEditingImage(dataType, out limitSmallValue, out limitLargeValue); // if (maxValue < limitSmallValue || minValue > limitLargeValue) { MsgBox.ShowInfo("选择的\"索引空间\"不能应用与当前显示影像,请重新选择或者选择\"调色板填色\"功能进行填色。"); return(false); } return(true); }
public void GetLimitValueOfEditingImage(GeoDo.RSS.Core.DF.enumDataType dataType, out int limitSmallValue, out int limitLargeValue) { limitSmallValue = limitLargeValue = -1; switch (dataType) { case enumDataType.Byte: limitSmallValue = 0; limitLargeValue = 255; break; case enumDataType.Float: case enumDataType.Double: limitSmallValue = int.MinValue; limitLargeValue = int.MaxValue; break; case enumDataType.Int16: limitSmallValue = Int16.MinValue; limitLargeValue = Int16.MaxValue; break; case enumDataType.Int32: limitSmallValue = Int32.MinValue; limitLargeValue = Int32.MaxValue; break; case enumDataType.UInt16: limitSmallValue = UInt16.MinValue; limitLargeValue = UInt16.MaxValue; break; case enumDataType.UInt32: limitSmallValue = (int)UInt32.MinValue; limitLargeValue = int.MaxValue; break; default: break; } }