예제 #1
0
        static Guid[] GetAllPixelFormats()
        {
            List <Guid> res = new List <Guid>();

            IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactory();
            IEnumUnknown       eu      = factory.CreateComponentEnumerator(WICComponentType.WICPixelFormat, WICComponentEnumerateOptions.WICComponentEnumerateRefresh);
            int hr = 0;

            object[] o = new object[1];
            while (hr == 0)
            {
                uint fetched = 0;

                hr = eu.Next(1, o, ref fetched);
                if (fetched == 1)
                {
                    IWICPixelFormatInfo info = (IWICPixelFormatInfo)o[0];
                    Guid guid;
                    info.GetFormatGUID(out guid);
                    res.Add(guid);

                    info.ReleaseComObject();
                }
                o.ReleaseComObject();
            }

            return(res.ToArray());
        }
예제 #2
0
        public static uint GetBitPerPixel(Guid pixelFormat)
        {
            IWICImagingFactory  factory = (IWICImagingFactory) new WICImagingFactory();
            IWICPixelFormatInfo info    = null;

            try
            {
                info = (IWICPixelFormatInfo)factory.CreateComponentInfo(pixelFormat);

                return(info.GetBitsPerPixel());
            }
            finally
            {
                factory.ReleaseComObject();
                info.ReleaseComObject();
            }
        }