Пример #1
0
        public ImageType DetectImageType(Stream stream)
        {
            ImageType whatIs = ImageType.none;

            if (ImagePNG.itsMyFormat(stream))
            {
                whatIs = ImageType.png;
            }
            else if (ImageBMP.itsMyFormat(stream))
            {
                whatIs = ImageType.bmp;
            }
            else if (ImageGIF.itsMyFormat(stream))
            {
                whatIs = ImageType.gif;
            }
            else
            {
                throw new Exception("тут шото не так");
            }

            return(whatIs);
        }
Пример #2
0
        public ImageObject makeImageObject(ImageType imageType, Stream stream)
        {
            ImageObject res;

            switch (imageType)
            {
            case ImageType.png:
                res = new ImagePNG(stream);
                break;

            case ImageType.bmp:
                res = new ImageBMP(stream);
                break;

            case ImageType.gif:
                res = new ImageGIF(stream);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(imageType), imageType, null);
            }

            return(res);
        }