Exemple #1
0
        public Color[] ColorConvert(ColorCovMode colorMode, byte[] input)
        {
            Color[] output;
            switch (colorMode)
            {
            case ColorCovMode.Gray:
                break;

            case ColorCovMode.Rainbow:
                RainbowGradation       colormaprain = new RainbowGradation();
                System.Drawing.Color[] clrmaprain   = colormaprain.GetGradation(255, false);
                output = new Color[input.GetLength(0)];
                for (int i = 0; i < input.GetLength(0); i++)
                {
                    output[i] = clrmaprain[input[i] == 255 ? 254 : input[i]];
                }
                return(output);

            case ColorCovMode.HSV:
                HSVGradation           colormaphsv = new HSVGradation();
                System.Drawing.Color[] clrmaphsv   = colormaphsv.GetGradation(255, false);
                output = new Color[input.GetLength(0)];
                for (int i = 0; i < input.GetLength(0); i++)
                {
                    output[i] = clrmaphsv[input [i] == 255 ? 254 : input [i]];
                }
                return(output);
            }
            return(null);
        }
Exemple #2
0
        public Func <byte[], Color[]> ConvertColor(ColorCovMode colorMode)
        {
            ColorConvertMethod     cv            = new PLImgViewer.ColorConvertMethod();
            Func <byte[], Color[]> convertmethod = input => cv.ColorConvert(colorMode, input);

            return(convertmethod);
        }
        BitmapSource Arr2Source(byte[,] input, ColorCovMode colomod)
        {
            ColorConvertMethod cv = new ColorConvertMethod();

            byte[]       flatMatrix = input.Flatten <byte>();
            Color[]      rainbowArr = cv.ConvertColor(colomod)(flatMatrix);
            ArrayToImage convertor  = new ArrayToImage(input.GetLength(1), input.GetLength(0));

            System.Drawing.Bitmap imgbit = new System.Drawing.Bitmap(input.GetLength(1), input.GetLength(0));
            convertor.Convert(rainbowArr, out imgbit);
            return(CreateBitmapSourceClass.ToWpfBitmap(imgbit));
        }
Exemple #4
0
        BitmapSource CreateColoredImg(byte[,] byteMatrix, int width, int height, ColorCovMode colormod)
        {
            ColorConvertMethod cv = new ColorConvertMethod();

            byte[]       flatMatrix = byteMatrix.Flatten <byte>();
            Color[]      colorArr   = cv.ConvertColor(colormod)(flatMatrix);
            ArrayToImage convertor  = new ArrayToImage(width, height);

            System.Drawing.Bitmap imgbit = new System.Drawing.Bitmap(width, height);
            convertor.Convert(colorArr, out imgbit);
            return(CreateBitmapSourceClass.ToWpfBitmap(imgbit));
        }
        public void ZoomColorChange(System.Windows.Controls.Image imgpanel, ColorCovMode colormod)
        {
            var stackSource2ZoomPanel = ZoomImgSourceSet(imgpanel);

            switch (colormod)
            {
            case ColorCovMode.Gray:
                stackSource2ZoomPanel(ZoomGray);
                break;

            case ColorCovMode.Rainbow:
                stackSource2ZoomPanel(ZoomRain);
                break;

            case ColorCovMode.HSV:
                stackSource2ZoomPanel(ZoomHsv);
                break;
            }
        }