Esempio n. 1
0
        /// <summary>
        /// Applies the filter on the image data.
        /// </summary>
        /// <param name="container">Input image container.</param>
        /// <returns>
        /// New instance of <see cref="ImageContainer"/> with the applied filter or <c>null</c> when the filter was not applied.
        /// </returns>
        public ImageContainer ApplyFilter(ImageContainer container)
        {
            using (var stream = container.OpenReadStream())
            {
                var metadata    = container.Metadata;
                var imageHelper = new ImageHelper(BinaryData.GetByteArrayFromStream(stream), metadata.Width, metadata.Height);

                // Resize image
                var resizedImage     = GetResizedImage(imageHelper);
                var resizedImageData = imageHelper.ImageToBytes(resizedImage);
                var resizedMetadata  = new ImageMetadata(resizedImage.Width, resizedImage.Height, metadata.MimeType, metadata.Extension);

                return(new ImageContainer(resizedImageData, resizedMetadata));
            }
        }