Dicom.Imaging.ColorTable.LoadLUT C# (CSharp) Method

LoadLUT() public static method

public static LoadLUT ( string file ) : Color[]
file string
return Color[]
        public static Color[] LoadLUT(string file)
        {
            try {
                byte[] data = File.ReadAllBytes(file);
                if (data.Length != (256 * 3))
                    return null;

                Color[] LUT = new Color[256];
                for (int i = 0; i < 256; i++) {
                    LUT[i] = Color.FromArgb(0xff, data[i], data[i + 256], data[i + 512]);
                }
                return LUT;
            } catch {
                return null;
            }
        }

Usage Example

Beispiel #1
0
        public void LoadLut_SavedMonochrome2_ReproduceMonochrome2Field()
        {
            var path = @".\Test Data\monochrome2.lut";

            ColorTable.SaveLUT(path, ColorTable.Monochrome2);

            var expected = ColorTable.Monochrome2;
            var actual   = ColorTable.LoadLUT(path);

            for (var i = 0; i < actual.Length; ++i)
            {
                Assert.Equal(expected[i].A, actual[i].A);
                Assert.Equal(expected[i].R, actual[i].R);
                Assert.Equal(expected[i].G, actual[i].G);
                Assert.Equal(expected[i].B, actual[i].B);
            }
        }