public void DictionarySearch() { List <int> pixelChannelList = new List <int> { 1, 3, 4 }; List <int> bitLengthList = new List <int> { 8, 16, 32, 64 }; List <IpcChannelDataType> DataTypeList = new List <IpcChannelDataType>() { IpcChannelDataType.Float, IpcChannelDataType.UInt }; foreach (var dataType in DataTypeList) { foreach (var bitLength in bitLengthList) { foreach (var pixelChannel in pixelChannelList) { try { IpcPixelFormats.GetMatchingFormat(pixelChannel, bitLength, dataType); Console.WriteLine("Success on Channel:" + pixelChannel + " bitsize: " + bitLength + " Datatype: " + dataType); } catch { Assert.Fail("Fail on Channel:" + pixelChannel + " bitsize: " + bitLength + " Datatype: " + dataType); } } } } }
public FitsData(Uri uri, bool isInterleave = false) { var fitsData = new nom.tam.fits.Fits(uri.OriginalString); PrimaryHdu = (ImageHDU)fitsData.ReadHDU(); if (Axes.Length == 2) { Channels = 1; Width = Axes[0]; Height = Axes[1]; } else if (Axes.Length == 3) { Channels = Axes[0]; Width = Axes[1]; Height = Axes[2]; } if (BufferSize > 4294967296) { throw new NotSupportedException("Image Size greater than 4GB aren't supported."); } IpcChannelDataType dataType; if (BitPix == 8 || BitPix == 16 || BitPix == 32) { dataType = IpcChannelDataType.UInt; } else if (BitPix == -32 || BitPix == -64) { dataType = IpcChannelDataType.Float; } else { throw new NotSupportedException("Bitpix field in pix is not 8,16,32,-32 or 64. BitSize " + BitPix + " is an unsupported value."); } BitsPerPixel = Math.Abs(BitPix); BytesPerPixel = BitsPerPixel / 8; IpcPixelFormat = isInterleave ? IpcPixelFormats.GetMatchingFormat(Channels, BitsPerPixel, dataType) : IpcPixelFormats.GetMatchingFormat(1, BitsPerPixel, dataType); //Construct header card dictionary. foreach (DictionaryEntry card in PrimaryHdu.Header) { HeaderCardDictionary.Add((HeaderCard)card.Value); } }