Esempio n. 1
0
        public static void LinearRampDemo(string dir)
        {
            Report.BeginTimed("linear ramp demo");
            var width     = 1920;
            var height    = 1080;
            var barHeight = height / 4;

            var line = new byte[width].SetByIndex(
                i => Col.ByteFromDouble((double)i / (double)(width - 1)));

            // write an image with linear red, green, blue, and gray ramps
            var linearImage = new PixImage <byte>(Col.Format.RGB, new V2i(width, height));
            var linVol      = linearImage.Volume;

            linVol.SubVolume(0, 0, 0, width, barHeight, 1).AsMatrixWindow().SetByCoord((x, y) => line[x]);
            linVol.SubVolume(0, barHeight, 1, width, barHeight, 1).AsMatrixWindow().SetByCoord((x, y) => line[x]);
            linVol.SubVolume(0, 2 * barHeight, 2, width, barHeight, 1).AsMatrixWindow().SetByCoord((x, y) => line[x]);
            linVol.SubVolume(0, 3 * barHeight, 0, width, barHeight, 3).SetByCoord((x, y, c) => line[x]);

            linearImage.SaveAsImage(Path.Combine(dir, "linear-ramp.tiff"));
            Report.End();
        }