示例#1
0
        public IImageFormat DetectFormat(Stream stream)
        {
            var internalFormat = Image.DetectFormat(stream);

            if (internalFormat != null)
            {
                return(ImageSharpUtility.CreateFormat(internalFormat));
            }

            return(null);
        }
示例#2
0
        public async Task <IImageFormat> DetectFormatAsync(Stream stream)
        {
            var internalFormat = await Image.DetectFormatAsync(stream);

            if (internalFormat != null)
            {
                return(ImageSharpUtility.CreateFormat(internalFormat));
            }

            return(null);
        }
示例#3
0
        public IImageFormat FindFormatByExtension(string extension)
        {
            var internalFormat = FindInternalImageFormat(extension);

            if (internalFormat != null)
            {
                return(ImageSharpUtility.CreateFormat(internalFormat));
            }

            return(null);
        }
示例#4
0
        public override IImageEncoder CreateEncoder()
        {
            if (QuantizationMethod != null || ColorTableMode != null)
            {
                return(new GifEncoder
                {
                    ColorTableMode = (SharpGifColorTableMode?)ColorTableMode,
                    Quantizer = ImageSharpUtility.CreateQuantizer(QuantizationMethod)
                });
            }

            return(base.CreateEncoder());
        }
示例#5
0
        public override IImageEncoder CreateEncoder()
        {
            if (BitDepth != null ||
                ColorType != null ||
                CompressionLevel != null ||
                Gamma != null ||
                Threshold != null ||
                QuantizationMethod != null ||
                InterlaceMode != null ||
                ChunkFilter != null ||
                TransparentColorMode != null ||
                IgnoreMetadata)
            {
                var encoder = new PngEncoder
                {
                    BitDepth        = (SharpPngBitDepth?)BitDepth,
                    ColorType       = (SharpPngColorType?)ColorType,
                    Gamma           = Gamma,
                    InterlaceMethod = (SharpPngInterlaceMode?)InterlaceMode,
                    ChunkFilter     = (SharpPngChunkFilter?)ChunkFilter,
                    Quantizer       = ImageSharpUtility.CreateQuantizer(QuantizationMethod),
                    IgnoreMetadata  = IgnoreMetadata
                };

                if (TransparentColorMode != null)
                {
                    encoder.TransparentColorMode = (SharpPngTransparentColorMode)TransparentColorMode.Value;
                }

                if (CompressionLevel != null)
                {
                    encoder.CompressionLevel = (SharpPngCompressionLevel)CompressionLevel;
                }

                if (Threshold != null)
                {
                    encoder.Threshold = Threshold.Value;
                }

                return(encoder);
            }

            return(base.CreateEncoder());
        }
示例#6
0
 public SharpImage(Image image, SharpFormat sharpFormat)
     : this(image, ImageSharpUtility.CreateFormat(sharpFormat))
 {
 }
示例#7
0
 public SharpImageInfo(SixLabors.ImageSharp.IImageInfo info, SixLabors.ImageSharp.Formats.IImageFormat format)
 {
     _info   = info;
     _format = ImageSharpUtility.CreateFormat(format);
 }