Beispiel #1
0
        private static void registerFromDoubleDepthConverters()
        {
            ColorDepthConverter.Add(new DepthConvertData
                                    (
                                        source: typeof(double),
                                        destination: typeof(byte),
                                        convertFunc: FromDoubleDepthConverters.ConvertDoubleToByte
                                    ));

            ColorDepthConverter.Add(new DepthConvertData
                                    (
                                        source: typeof(double),
                                        destination: typeof(short),
                                        convertFunc: FromDoubleDepthConverters.ConvertDoubleToShort
                                    ));

            ColorDepthConverter.Add(new DepthConvertData
                                    (
                                        source: typeof(double),
                                        destination: typeof(int),
                                        convertFunc: FromDoubleDepthConverters.ConvertDoubleToInt
                                    ));

            ColorDepthConverter.Add(new DepthConvertData
                                    (
                                        source: typeof(double),
                                        destination: typeof(float),
                                        convertFunc: FromDoubleDepthConverters.ConvertDoubleToFloat
                                    ));
        }
Beispiel #2
0
        /// <summary>
        /// Registers default color and depth conversions.
        /// </summary>
        public static void Initialize()
        {
            registerDepthConverters();

            #region Generic Colors

            ColorDepthConverter.Add(new Color2());
            ColorDepthConverter.Add(new Color3());
            ColorDepthConverter.Add(new Color4());

            #endregion

            #region Bgr <-> Bgra

            foreach (var spt in SupportedPrimitiveTypes)
            {
                ColorDepthConverter.Add(ColorConvertData.AsConvertData
                                        (
                                            source: ColorInfo.GetInfo(typeof(Bgra), spt),
                                            destination: ColorInfo.GetInfo(typeof(Bgr), spt),
                                            convertFunc: BgraBgrConverters.ConvertBgraToBgr,
                                            forceSequential: true
                                        ));
            }

            ColorDepthConverter.Add(ColorConvertData.AsConvertData
                                    (
                                        source: ColorInfo.GetInfo <Bgr, byte>(),
                                        destination: ColorInfo.GetInfo <Bgra, byte>(),
                                        convertFunc: BgraBgrConverters.ConvertBgrToBgra_Byte
                                    ));

            #endregion


            #region Bgr <-> Hsv

            ColorDepthConverter.Add(ColorConvertData.AsConvertData
                                    (
                                        source:      ColorInfo.GetInfo <Bgr, byte>(),
                                        destination: ColorInfo.GetInfo <Hsv, byte>(),
                                        convertFunc: BgrHsvConverters.ConvertBgrToHsv_Byte
                                    ));

            ColorDepthConverter.Add(ColorConvertData.AsConvertData
                                    (
                                        source:      ColorInfo.GetInfo <Hsv, byte>(),
                                        destination: ColorInfo.GetInfo <Bgr, byte>(),
                                        convertFunc: BgrHsvConverters.ConvertHsvToBgr_Byte
                                    ));

            #endregion

            #region Gray -> Complex

            ColorDepthConverter.Add(ColorConvertData.AsConvertData
                                    (
                                        source: ColorInfo.GetInfo <Gray, float>(),
                                        destination: ColorInfo.GetInfo <Complex, float>(),
                                        convertFunc: GrayComplexConverters.ConvertGrayToComplex,
                                        forceSequential: true
                                    ));

            ColorDepthConverter.Add(ColorConvertData.AsConvertData
                                    (
                                        source: ColorInfo.GetInfo <Gray, double>(),
                                        destination: ColorInfo.GetInfo <Complex, double>(),
                                        convertFunc: GrayComplexConverters.ConvertGrayToComplex,
                                        forceSequential: true
                                    ));

            //QUESTION: does it make sense for other depths ?
            #endregion

            #region Gray <-> Bgr

            foreach (var spt in SupportedPrimitiveTypes)
            {
                ColorDepthConverter.Add(ColorConvertData.AsConvertData
                                        (
                                            source: ColorInfo.GetInfo(typeof(Gray), spt),
                                            destination: ColorInfo.GetInfo(typeof(Bgr), spt),
                                            convertFunc: BgrGrayConverters.ConvertGrayToBgr,
                                            forceSequential: true
                                        ));
            }

            ColorDepthConverter.Add(ColorConvertData.AsConvertData
                                    (
                                        source: ColorInfo.GetInfo <Bgr, byte>(),
                                        destination: ColorInfo.GetInfo <Gray, byte>(),
                                        convertFunc: BgrGrayConverters.ConvertBgrToGray_Byte
                                    ));

            #endregion
        }