Esempio n. 1
0
        /// <summary>
        /// Extract region from source image
        /// </summary>
        /// <param name="imageUri">The <see cref="Uri"/> of the source image</param>
        /// <param name="request">The <see cref="ImageRequest"/></param>
        /// <param name="allowSizeAboveFull">Allow the output size to exceed the original dimensions of the image</param>
        /// <param name="quality">The <see cref="ImageQuality"/> settings for encoding</param>
        /// <returns></returns>
        public async Task <(ProcessState, SKImage)> ExtractRegion(Uri imageUri, ImageRequest request, bool allowSizeAboveFull, TremendousIIIF.Common.Configuration.ImageQuality quality)
        {
            var sourceFormat = await GetSourceFormat(imageUri, request.RequestId);

            switch (sourceFormat)
            {
            case ImageFormat.jp2:
                return(J2KExpander.ExpandRegion(HttpClient, Log, imageUri, request, allowSizeAboveFull, quality));

            case ImageFormat.tif:
                return(TiffExpander.ExpandRegion(HttpClient, Log, imageUri, request, allowSizeAboveFull));

            default:
                throw new IOException("Unsupported source format");
            }
        }
        public void RegionScale()
        {
            var filename = @"C:\JP2Cache\vdc_0000000388E8.0x000008";
            var request  = new ImageRequest
                           (
                "",
                new ImageRegion(ImageRegionMode.Region, 2048f, 0f, 9f, 1024f),
                new ImageSize(ImageSizeMode.Distort, 1, 3, 0),
                new ImageRotation(0, false),
                ImageQuality.@default,
                TremendousIIIF.Common.ImageFormat.jpg
                           );
            var q = new C.ImageQuality();

            (var state, var img) = J2KExpander.ExpandRegion(null, Log, new Uri(filename), request, false, q);
            using (img)
            {
                Assert.AreEqual(3, img.Width);
                Assert.AreEqual(342, img.Height);
            }
        }