AmaroK86.ImageFormat.ImageMipMapHandler.ImageDataSize C# (CSharp) Метод

ImageDataSize() приватный Метод

private ImageDataSize ( ImageSize imgsize, string format, float BytesPerPixel ) : long
imgsize ImageSize
format string
BytesPerPixel float
Результат long
        private long ImageDataSize(ImageSize imgsize, string format, float BytesPerPixel)
        {
            uint w = imgsize.width;
            uint h = imgsize.height;
            if (CprFormat(format))
            {
                if (w < 4)
                    w = 4;
                if (h < 4)
                    h = 4;
            }
            return (long)(w * h * BytesPerPixel);

            /*long totalBytes = (long)((float)(imgsize.width * imgsize.height) * BytesPerPixel);
            switch (format)
            {
                case "DXT1":
                    if (imgsize.width <= 4 && imgsize.height <= 4)
                        return 8;
                    else
                        return totalBytes;
                case "ATI2":
                case "DXT5":
                    if (imgsize.width <= 4 && imgsize.height <= 4)
                        return 16;
                    else
                        return totalBytes;
                case "V8U8":
                    if (imgsize.width <= 4 && imgsize.height <= 4)
                        return 32;
                    else
                        return totalBytes;
                case "G8":
                case "R8G8B8":
                case "A8R8G8B8":
                    return totalBytes;
                default:
                    throw new FormatException("Invalid image format");
            } */
        }