pub fn compute_chunk_count(compression: Compression, data_size: Vec2<usize>, blocks: BlockDescription) -> usize {

    if let BlockDescription::Tiles(tiles) = blocks {
        let round = tiles.rounding_mode;
        let Vec2(tile_width, tile_height) = tiles.tile_size;

        // TODO cache all these level values??
        use crate::meta::attribute::LevelMode::*;
        match tiles.level_mode {
            Singular => {
                let tiles_x = compute_block_count(data_size.width(), tile_width);
                let tiles_y = compute_block_count(data_size.height(), tile_height);
                tiles_x * tiles_y
            }

            MipMap => {
                mip_map_levels(round, data_size).map(|(_, Vec2(level_width, level_height))| {
                    compute_block_count(level_width, tile_width) * compute_block_count(level_height, tile_height)
                }).sum()
            },

            RipMap => {
                rip_map_levels(round, data_size).map(|(_, Vec2(level_width, level_height))| {
                    compute_block_count(level_width, tile_width) * compute_block_count(level_height, tile_height)
                }).sum()
            }
        }
    }

    // scan line blocks never have mip maps
    else {
        compute_block_count(data_size.height(), compression.scan_lines_per_block())
    }
}
/// Compute the number of chunks that an image is divided into. May be an expensive operation.
// If not multilayer and chunkCount not present,
// the number of entries in the chunk table is computed
// using the dataWindow and tileDesc attributes and the compression format
Compute the number of chunks that an image is divided into. May be an expensive operation.
If not multilayer and chunkCount not present,
the number of entries in the chunk table is computed
using the dataWindow and tileDesc attributes and the compression format
Compute the number of chunks that an image is divided into . May be an expensive operation . If not multilayer and chunkCount not present the number of entries in the chunk table is computed using the dataWindow and tileDesc attributes and the compression format
pub fn compute_chunk_count(compression: Compression, data_size: Vec2<usize>, blocks: BlockDescription) -> usize {
    if let BlockDescription::Tiles(tiles) = blocks {
        let round = tiles.rounding_mode;
        let Vec2(tile_width, tile_height) = tiles.tile_size;
        // TODO cache all these level values??
        use crate::meta::attribute::LevelMode::*;
        match tiles.level_mode {
            Singular => {
                let tiles_x = compute_block_count(data_size.width(), tile_width);
                let tiles_y = compute_block_count(data_size.height(), tile_height);
                tiles_x * tiles_y
            }
            MipMap => {
                mip_map_levels(round, data_size).map(|(_, Vec2(level_width, level_height))| {
                    compute_block_count(level_width, tile_width) * compute_block_count(level_height, tile_height)
                }).sum()
            },
            RipMap => {
                rip_map_levels(round, data_size).map(|(_, Vec2(level_width, level_height))| {
                    compute_block_count(level_width, tile_width) * compute_block_count(level_height, tile_height)
                }).sum()
            }
        }
    }
    // scan line blocks never have mip maps
    else {
        compute_block_count(data_size.height(), compression.scan_lines_per_block())
    }
}
pub fn compute_chunk_count ( compression : Compression , data_size : Vec2 < usize > , blocks : BlockDescription ) -> usize { if let BlockDescription :: Tiles ( tiles ) = blocks { let round = tiles . rounding_mode ; let Vec2 ( tile_width , tile_height ) = tiles . tile_size ; // TODO cache all these level values?? use crate :: meta :: attribute :: LevelMode :: * ; match tiles . level_mode { Singular => { let tiles_x = compute_block_count ( data_size . width ( ) , tile_width ) ; let tiles_y = compute_block_count ( data_size . height ( ) , tile_height ) ; tiles_x * tiles_y } MipMap => { mip_map_levels ( round , data_size ) . map ( | ( _ , Vec2 ( level_width , level_height ) ) | { compute_block_count ( level_width , tile_width ) * compute_block_count ( level_height , tile_height ) } ) . sum ( ) } , RipMap => { rip_map_levels ( round , data_size ) . map ( | ( _ , Vec2 ( level_width , level_height ) ) | { compute_block_count ( level_width , tile_width ) * compute_block_count ( level_height , tile_height ) } ) . sum ( ) } } } // scan line blocks never have mip maps else { compute_block_count ( data_size . height ( ) , compression . scan_lines_per_block ( ) ) } }
Compute the number of chunks that an image is divided into.
Compute the number of chunks that an image is divided into .
compression
Compression
data_size
Vec2<usize>
blocks
BlockDescription
compression
Compression
data_size
Vec2<usize>
blocks
BlockDescription