Пример #1
0
        public static ImageInfo?FromStream(Stream stream)
        {
            ImageInfo?info = null;

            if (JpgDecoder.Test(stream))
            {
                info = JpgDecoder.Info(stream);
            }
            else if (PngDecoder.Test(stream))
            {
                info = PngDecoder.Info(stream);
            }
            else if (BmpDecoder.Test(stream))
            {
                info = BmpDecoder.Info(stream);
            }
            else if (GifDecoder.Test(stream))
            {
                info = GifDecoder.Info(stream);
            }
            else if (PsdDecoder.Test(stream))
            {
                info = PsdDecoder.Info(stream);
            }
            else if (TgaDecoder.Test(stream))
            {
                info = TgaDecoder.Info(stream);
            }

            return(info);
        }
Пример #2
0
        public static ImageResult FromStream(Stream stream, ColorComponents?requiredComponents = null,
                                             bool use8BitsPerChannel = true)
        {
            ImageResult result = null;

            if (JpgDecoder.Test(stream))
            {
                result = JpgDecoder.Decode(stream, requiredComponents);
            }
            else if (PngDecoder.Test(stream))
            {
                result = PngDecoder.Decode(stream, requiredComponents);
            }
            else if (BmpDecoder.Test(stream))
            {
                result = BmpDecoder.Decode(stream, requiredComponents);
            }
            else if (GifDecoder.Test(stream))
            {
                result = GifDecoder.Decode(stream, requiredComponents);
            }
            else if (PsdDecoder.Test(stream))
            {
                result = PsdDecoder.Decode(stream, requiredComponents);
            }
            else if (TgaDecoder.Test(stream))
            {
                result = TgaDecoder.Decode(stream, requiredComponents);
            }

            if (result == null)
            {
                Decoder.stbi__err("unknown image type");
            }

            if (use8BitsPerChannel && result.BitsPerChannel != 8)
            {
                result.Data = Conversion.stbi__convert_16_to_8(result.Data, result.Width, result.Height,
                                                               (int)result.ColorComponents);
            }

            return(result);
        }
Пример #3
0
        public static ImageInfo?FromStream(Stream stream)
        {
            var info = JpgDecoder.Info(stream);

            if (info != null)
            {
                return(info);
            }

            info = PngDecoder.Info(stream);
            if (info != null)
            {
                return(info);
            }

            info = GifDecoder.Info(stream);
            if (info != null)
            {
                return(info);
            }

            info = BmpDecoder.Info(stream);
            if (info != null)
            {
                return(info);
            }

            info = PsdDecoder.Info(stream);
            if (info != null)
            {
                return(info);
            }

            info = TgaDecoder.Info(stream);
            if (info != null)
            {
                return(info);
            }

            return(null);
        }