Пример #1
0
        public static ImageInfo?Info(Stream stream)
        {
            var info = new stbi__bmp_data
            {
                all_a = 255
            };

            var decoder = new BmpDecoder(stream);

            try
            {
                decoder.stbi__bmp_parse_header(ref info);
            }
            catch (Exception)
            {
                return(null);
            }
            finally
            {
                stream.Rewind();
            }

            return(new ImageInfo
            {
                Width = decoder.img_x,
                Height = decoder.img_y,
                ColorComponents = info.ma != 0 ? ColorComponents.RedGreenBlueAlpha : ColorComponents.RedGreenBlue,
                BitsPerChannel = 8
            });
        }
Пример #2
0
        public static ImageResult Decode(Stream stream, ColorComponents?requiredComponents = null)
        {
            var decoder = new BmpDecoder(stream);

            return(decoder.InternalDecode(requiredComponents));
        }