/// gets suitability rating for format and takes preferred format into account
        public int GetFormatRating(GliFormat format, GliFormat preferredFormat)
        {
            var  rating             = GetFormatRating(format);
            var  preferredPixelType = preferredFormat.GetDataType();
            var  pixelType          = format.GetDataType();
            bool isSrgb             = preferredPixelType == PixelDataType.Srgb;
            bool hasRgb             = preferredFormat.HasRgb();

            if (format == preferredFormat)
            {
                rating += 150;
            }

            // keep srgb specifier
            if (isSrgb == (format.GetDataType() == PixelDataType.Srgb))
            {
                rating += 200;
            }
            else
            {
                rating -= 200;
            }

            // small bonus for same datatype
            if (preferredPixelType == pixelType)
            {
                rating += 5;
            }

            // small bonus for rgb match
            if (hasRgb == format.HasRgb())
            {
                rating += 15;
            }

            // small bonus for high precision
            if (!preferredFormat.IsLessThan8Bit() && !format.IsLessThan8Bit())
            {
                rating += 20;
            }

            // small bonus for kept compression
            if (preferredFormat.IsCompressed() && format.IsCompressed())
            {
                rating += 10;
            }

            return(rating);
        }
Exemple #2
0
        /// gets suitability rating for format and takes preferred format into account
        public int GetFormatRating(GliFormat format, GliFormat preferredFormat)
        {
            var  rating             = GetFormatRating(format);
            var  preferredPixelType = preferredFormat.GetDataType();
            var  pixelType          = format.GetDataType();
            bool isSrgb             = preferredPixelType == PixelDataType.Srgb;
            bool hasRgb             = preferredFormat.HasRgb();

            if (format == preferredFormat)
            {
                rating += 150;
            }

            // keep srgb specifier
            if (isSrgb == (pixelType == PixelDataType.Srgb))
            {
                rating += 200;
            }
            else
            {
                // prefer srgb formats over unorm etc. when converting from hdr to ldr
                if (!preferredFormat.IsAtMost8bit() && !preferredPixelType.IsUnormed() && pixelType == PixelDataType.Srgb)
                {
                    rating -= 50;
                }
                else
                {
                    rating -= 200;
                }
            }

            // small bonus for same datatype
            if (preferredPixelType == pixelType)
            {
                rating += 5;
            }

            // small bonus for rgb match
            if (hasRgb == format.HasRgb())
            {
                rating += 15;
            }

            // small bonus for high precision
            if (!preferredFormat.IsLessThan8Bit() && !format.IsLessThan8Bit())
            {
                rating += 20;
            }

            // small bonus for kept compression
            if (preferredFormat.IsCompressed() && format.IsCompressed())
            {
                rating += 10;
            }

            // try to keep hdr formats
            if (!preferredFormat.IsAtMost8bit() && !format.IsAtMost8bit())
            {
                // keep unorm property
                if (preferredPixelType.IsUnormed() == pixelType.IsUnormed())
                {
                    rating += 50;
                }
            }



            return(rating);
        }