Ejemplo n.º 1
0
        private int AllocateMipMaps(DdsLoadInfo info)
        {
            var len = CalcSize(info);

            if (Header.MipMapCount <= 1)
            {
                return(len);
            }

            _mipMaps = new MipMapOffset[Header.MipMapCount - 1];
            var totalLen = len;

            for (int i = 0; i < Header.MipMapCount - 1; i++)
            {
                int width  = (int)Math.Max(info.DivSize, (int)(Header.Width / Math.Pow(2, i + 1)));
                int height = (int)Math.Max(info.DivSize, Header.Height / Math.Pow(2, i + 1));
                int stride = Util.Stride(width, BitsPerPixel);
                len = stride * height;

                _mipMaps[i] = new MipMapOffset(width, height, stride, totalLen, len);
                totalLen   += len;
            }

            return(totalLen);
        }
Ejemplo n.º 2
0
        /// <summary>Calculates the number of bytes to hold image data</summary>
        private int CalcSize(DdsLoadInfo info)
        {
            var widthBytes = Util.Stride((int)Header.Width, BitsPerPixel);
            int width      = (int)Math.Max(info.DivSize * BytesPerPixel, widthBytes);
            int height     = (int)Math.Max(info.DivSize, Header.Height);

            return((int)(width * (height / info.DivSize)));
        }
Ejemplo n.º 3
0
        /// <summary>Calculates the number of bytes to hold image data</summary>
        private int CalcSize(DdsLoadInfo info)
        {
            int height = (int)Math.Max(info.DivSize, Header.Height);

            return(Stride * height);
        }