/// <summary>
        /// Selects the internal pixel format.
        /// </summary>
        /// <param name="pixelFormat">The pixel format.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">Wrong pixel format " + pixelFormat.ToString()</exception>
        public static PixelInternalFormat SelectInternalPixelFormat(SysDraw.PixelFormat pixelFormat)
        {
            switch (pixelFormat)
            {
            case SysDraw.PixelFormat.Format8bppIndexed: return(PixelInternalFormat.R8);

            case SysDraw.PixelFormat.Format24bppRgb: return(PixelInternalFormat.Rgb8);

            case SysDraw.PixelFormat.Format32bppArgb: return(PixelInternalFormat.Rgba8);

            default: throw new ArgumentException("Wrong pixel format " + pixelFormat.ToString());
            }
        }
Пример #2
0
        private static PixelInternalFormat selectInternalPixelFormat(System.Drawing.Imaging.PixelFormat pixelFormat)
        {
            switch (pixelFormat)
            {
            case System.Drawing.Imaging.PixelFormat.Format8bppIndexed: return(PixelInternalFormat.Luminance);

            case System.Drawing.Imaging.PixelFormat.Format24bppRgb: return(PixelInternalFormat.Rgb);

            case System.Drawing.Imaging.PixelFormat.Format32bppArgb: return(PixelInternalFormat.Rgba);

            default: throw new FileLoadException("Wrong pixel format " + pixelFormat.ToString());
            }
        }
Пример #3
0
        public static PixelFormat SelectPixelFormat(SysDraw.PixelFormat pixelFormat)
        {
            switch (pixelFormat)
            {
            case SysDraw.PixelFormat.Format8bppIndexed: return(PixelFormat.Red);

            case SysDraw.PixelFormat.Format24bppRgb: return(PixelFormat.Bgr);

            case SysDraw.PixelFormat.Format32bppArgb: return(PixelFormat.Bgra);

            default: throw new FileLoadException("Wrong pixel format " + pixelFormat.ToString());
            }
        }
Пример #4
0
        private static OpenTK.Graphics.OpenGL.PixelFormat selectInputPixelFormat(System.Drawing.Imaging.PixelFormat pixelFormat)
        {
            switch (pixelFormat)
            {
            case System.Drawing.Imaging.PixelFormat.Format8bppIndexed: return(OpenTK.Graphics.OpenGL.PixelFormat.Red);

            case System.Drawing.Imaging.PixelFormat.Format24bppRgb: return(OpenTK.Graphics.OpenGL.PixelFormat.Bgr);

            case System.Drawing.Imaging.PixelFormat.Format32bppArgb: return(OpenTK.Graphics.OpenGL.PixelFormat.Bgra);

            default: throw new FileLoadException("Wrong pixel format " + pixelFormat.ToString());
            }
        }
        public static System.Windows.Media.PixelFormat Convert(this System.Drawing.Imaging.PixelFormat pixelFormat)
        {
            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format16bppGrayScale)
            {
                return(System.Windows.Media.PixelFormats.Gray16);
            }
            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format16bppRgb555)
            {
                return(System.Windows.Media.PixelFormats.Bgr555);
            }
            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format16bppRgb565)
            {
                return(System.Windows.Media.PixelFormats.Bgr565);
            }

            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Indexed)
            {
                return(System.Windows.Media.PixelFormats.Bgr101010);
            }
            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format1bppIndexed)
            {
                return(System.Windows.Media.PixelFormats.Indexed1);
            }
            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format4bppIndexed)
            {
                return(System.Windows.Media.PixelFormats.Indexed4);
            }
            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format8bppIndexed)
            {
                return(System.Windows.Media.PixelFormats.Indexed8);
            }

            //if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format16bppArgb1555)
            //    return System.Windows.Media.PixelFormats.Bgr101010;

            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format24bppRgb)
            {
                return(System.Windows.Media.PixelFormats.Bgr24);
            }

            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppArgb)
            {
                return(System.Windows.Media.PixelFormats.Bgra32);
            }
            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
            {
                return(System.Windows.Media.PixelFormats.Pbgra32);
            }
            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppRgb)
            {
                return(System.Windows.Media.PixelFormats.Bgr32);
            }

            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format48bppRgb)
            {
                return(System.Windows.Media.PixelFormats.Rgb48);
            }

            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format64bppArgb)
            {
                return(System.Windows.Media.PixelFormats.Prgba64);
            }

            // TODO :
            //if (pixelFormat == System.Drawing.Imaging.PixelFormat.Alpha)
            //    return System.Windows.Media.PixelFormats.;
            //if (pixelFormat == System.Drawing.Imaging.PixelFormat.Canonical)
            //    return System.Windows.Media.PixelFormats.;
            //if (pixelFormat == System.Drawing.Imaging.PixelFormat.DontCare)
            //    return System.Windows.Media.PixelFormats.;
            //if (pixelFormat == System.Drawing.Imaging.PixelFormat.Extended)
            //    return System.Windows.Media.PixelFormats.;
            //if (pixelFormat == System.Drawing.Imaging.PixelFormat.Gdi)
            //    return System.Windows.Media.PixelFormats.Default;
            //if (pixelFormat == System.Drawing.Imaging.PixelFormat.Max)
            //    return System.Windows.Media.PixelFormats.Default;
            //if (pixelFormat == System.Drawing.Imaging.PixelFormat.PAlpha)
            //    return System.Windows.Media.PixelFormats.Default;

            if (pixelFormat == System.Drawing.Imaging.PixelFormat.Undefined)
            {
                return(System.Windows.Media.PixelFormats.Default);
            }

            throw new NotSupportedException("Convertion not supported with " + pixelFormat.ToString());
        }