当前位置: 首页>>代码示例>>C#>>正文


C# IHasImages.GetImageInfo方法代码示例

本文整理汇总了C#中IHasImages.GetImageInfo方法的典型用法代码示例。如果您正苦于以下问题:C# IHasImages.GetImageInfo方法的具体用法?C# IHasImages.GetImageInfo怎么用?C# IHasImages.GetImageInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHasImages的用法示例。


在下文中一共展示了IHasImages.GetImageInfo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetImageCacheTag

        public static string GetImageCacheTag(this IImageProcessor processor, IHasImages item, ImageType imageType, int imageIndex)
        {
            var imageInfo = item.GetImageInfo(imageType, imageIndex);

            if (imageInfo == null)
            {
                return null;
            }

            return processor.GetImageCacheTag(item, imageInfo);
        }
开发者ID:jabbera,项目名称:MediaBrowser,代码行数:11,代码来源:ImageProcessorExtensions.cs

示例2: GetEnhancedImage

        /// <summary>
        /// Gets the enhanced image.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="imageType">Type of the image.</param>
        /// <param name="imageIndex">Index of the image.</param>
        /// <returns>Task{System.String}.</returns>
        public async Task<string> GetEnhancedImage(IHasImages item, ImageType imageType, int imageIndex)
        {
            var enhancers = GetSupportedEnhancers(item, imageType).ToList();

            var imageInfo = item.GetImageInfo(imageType, imageIndex);

            var result = await GetEnhancedImage(imageInfo, item, imageIndex, enhancers);

            return result.Item1;
        }
开发者ID:loose-wardrobe,项目名称:Emby,代码行数:17,代码来源:ImageProcessor.cs

示例3: GetCurrentImage

 /// <summary>
 /// Gets the current image path.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="type">The type.</param>
 /// <param name="imageIndex">Index of the image.</param>
 /// <returns>System.String.</returns>
 /// <exception cref="System.ArgumentNullException">
 /// imageIndex
 /// or
 /// imageIndex
 /// </exception>
 private ItemImageInfo GetCurrentImage(IHasImages item, ImageType type, int imageIndex)
 {
     return item.GetImageInfo(type, imageIndex);
 }
开发者ID:loose-wardrobe,项目名称:Emby,代码行数:16,代码来源:ImageSaver.cs

示例4: GetPrimaryImageAspectRatio

        public double? GetPrimaryImageAspectRatio(IHasImages item)
        {
            var imageInfo = item.GetImageInfo(ImageType.Primary, 0);

            if (imageInfo == null || !imageInfo.IsLocalFile)
            {
                return null;
            }

            ImageSize size;

            try
            {
                size = _imageProcessor.GetImageSize(imageInfo);
            }
            catch (Exception ex)
            {
                //_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
                return null;
            }

            var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary).ToList();

            foreach (var enhancer in supportedEnhancers)
            {
                try
                {
                    size = enhancer.GetEnhancedImageSize(item, ImageType.Primary, 0, size);
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error in image enhancer: {0}", ex, enhancer.GetType().Name);
                }
            }

            var width = size.Width;
            var height = size.Height;

            if (width == 0 || height == 0)
            {
                return null;
            }

            var photo = item as Photo;
            if (photo != null && photo.Orientation.HasValue)
            {
                switch (photo.Orientation.Value)
                {
                    case ImageOrientation.LeftBottom:
                    case ImageOrientation.LeftTop:
                    case ImageOrientation.RightBottom:
                    case ImageOrientation.RightTop:
                        var temp = height;
                        height = width;
                        width = temp;
                        break;
                }
            }

            return width / height;
        }
开发者ID:loose-wardrobe,项目名称:Emby,代码行数:61,代码来源:DtoService.cs

示例5: MergeImages

        public bool MergeImages(IHasImages item, List<LocalImageInfo> images)
        {
            var changed = false;

            foreach (var type in _singularImages)
            {
                var image = images.FirstOrDefault(i => i.Type == type);

                if (image != null)
                {
                    var currentImage = item.GetImageInfo(type, 0);

                    if (currentImage == null)
                    {
                        item.SetImagePath(type, image.FileInfo);
                        changed = true;
                    }
                    else if (!string.Equals(currentImage.Path, image.FileInfo.FullName,
                            StringComparison.OrdinalIgnoreCase))
                    {
                        item.SetImagePath(type, image.FileInfo);
                        changed = true;
                    }
                    else
                    {
                        currentImage.DateModified = _fileSystem.GetLastWriteTimeUtc(image.FileInfo);
                    }
                }
            }

            if (UpdateMultiImages(item, images, ImageType.Backdrop))
            {
                changed = true;
            }

            var hasScreenshots = item as IHasScreenshots;
            if (hasScreenshots != null)
            {
                if (UpdateMultiImages(item, images, ImageType.Screenshot))
                {
                    changed = true;
                }
            }

            return changed;
        }
开发者ID:Ceten,项目名称:MediaBrowser,代码行数:46,代码来源:ItemImageProvider.cs

示例6: AttachPrimaryImageAspectRatio

        /// <summary>
        /// Attaches the primary image aspect ratio.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <param name="item">The item.</param>
        /// <param name="fields">The fields.</param>
        /// <returns>Task.</returns>
        public void AttachPrimaryImageAspectRatio(IItemDto dto, IHasImages item, List<ItemFields> fields)
        {
            var imageInfo = item.GetImageInfo(ImageType.Primary, 0);

            if (imageInfo == null || !imageInfo.IsLocalFile)
            {
                return;
            }

            ImageSize size;

            try
            {
                size = _imageProcessor.GetImageSize(imageInfo);
            }
            catch (Exception ex)
            {
                //_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
                return;
            }

            var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary).ToList();

            foreach (var enhancer in supportedEnhancers)
            {
                try
                {
                    size = enhancer.GetEnhancedImageSize(item, ImageType.Primary, 0, size);
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error in image enhancer: {0}", ex, enhancer.GetType().Name);
                }
            }

            if (size.Width > 0 && size.Height > 0)
            {
                dto.PrimaryImageAspectRatio = size.Width / size.Height;
            }
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:47,代码来源:DtoService.cs

示例7: HasImage

        private bool HasImage(IHasImages item, ImageType type)
        {
            var image = item.GetImageInfo(type, 0);

            // if it's a placeholder image then pretend like it's not there so that we can replace it
            return image != null && !image.IsPlaceholder;
        }
开发者ID:t-andre,项目名称:Emby,代码行数:7,代码来源:ItemImageProvider.cs

示例8: MergeImages

        public bool MergeImages(IHasImages item, List<LocalImageInfo> images)
        {
            var changed = false;

            foreach (var type in _singularImages)
            {
                var image = images.FirstOrDefault(i => i.Type == type);

                if (image != null)
                {
                    var currentImage = item.GetImageInfo(type, 0);

                    if (currentImage == null || !string.Equals(currentImage.Path, image.FileInfo.FullName, StringComparison.OrdinalIgnoreCase))
                    {
                        item.SetImagePath(type, image.FileInfo);
                        changed = true;
                    }
                }
            }

            var backdrops = images.Where(i => i.Type == ImageType.Backdrop).ToList();
            if (backdrops.Count > 0)
            {
                var foundImages = images.Where(i => i.Type == ImageType.Backdrop)
                    .Select(i => i.FileInfo)
                    .ToList();

                if (foundImages.Count > 0)
                {
                    if (item.AddImages(ImageType.Backdrop, foundImages))
                    {
                        changed = true;
                    }
                }
            }

            var hasScreenshots = item as IHasScreenshots;
            if (hasScreenshots != null)
            {
                var foundImages = images.Where(i => i.Type == ImageType.Screenshot)
                    .Select(i => i.FileInfo)
                    .ToList();

                if (foundImages.Count > 0)
                {
                    if (item.AddImages(ImageType.Screenshot, foundImages))
                    {
                        changed = true;
                    }
                }
            }

            return changed;
        }
开发者ID:Rycius,项目名称:MediaBrowser,代码行数:54,代码来源:ItemImageProvider.cs

示例9: AttachPrimaryImageAspectRatio

        /// <summary>
        /// Attaches the primary image aspect ratio.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <param name="item">The item.</param>
        /// <returns>Task.</returns>
        public void AttachPrimaryImageAspectRatio(IItemDto dto, IHasImages item)
        {
            var imageInfo = item.GetImageInfo(ImageType.Primary, 0);

            if (imageInfo == null)
            {
                return;
            }

            var path = imageInfo.Path;

            // See if we can avoid a file system lookup by looking for the file in ResolveArgs
            var dateModified = imageInfo.DateModified;

            ImageSize size;

            try
            {
                size = _imageProcessor.GetImageSize(path, dateModified);
            }
            catch (FileNotFoundException)
            {
                _logger.Error("Image file does not exist: {0}", path);
                return;
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
                return;
            }

            dto.OriginalPrimaryImageAspectRatio = size.Width / size.Height;

            var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary).ToList();

            foreach (var enhancer in supportedEnhancers)
            {
                try
                {
                    size = enhancer.GetEnhancedImageSize(item, ImageType.Primary, 0, size);
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error in image enhancer: {0}", ex, enhancer.GetType().Name);
                }
            }

            dto.PrimaryImageAspectRatio = size.Width / size.Height;
        }
开发者ID:Tensre,项目名称:MediaBrowser,代码行数:55,代码来源:DtoService.cs


注:本文中的IHasImages.GetImageInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。