Exemple #1
0
        public Image(int id, ImageEntityType type, bool preferred = false, bool disabled = false) : this(id.ToString(), type, preferred, disabled)
        {
            if (type == ImageEntityType.Static)
            {
                throw new ArgumentException("Static Resources do not use an integer ID");
            }

            var imagePath = GetImagePath(type, id);

            if (string.IsNullOrEmpty(imagePath))
            {
                RelativeFilepath = null;
                Width            = null;
                Height           = null;
            }
            else
            {
                var info = new MagickImageInfo(imagePath);
                RelativeFilepath = imagePath.Replace(ImageUtils.GetBaseImagesPath(), "").Replace("\\", "/");
                if (!RelativeFilepath.StartsWith("/"))
                {
                    RelativeFilepath = "/" + RelativeFilepath;
                }
                Width  = info.Width;
                Height = info.Height;
            }
        }
Exemple #2
0
        public Image(int id, ImageEntityType type, bool preferred = false, bool disabled = false) : this(id.ToString(), type, preferred, disabled)
        {
            if (type == ImageEntityType.Static)
            {
                throw new ArgumentException("Static Resources do not use an integer ID");
            }

            RelativeFilepath = GetImagePath(type, id)?.Replace(ImageUtils.GetBaseImagesPath(), "")
                               .Replace("\\", "/");
            if (RelativeFilepath != null && !RelativeFilepath.StartsWith("/"))
            {
                RelativeFilepath = "/" + RelativeFilepath;
            }
        }