use super::super::{
header::{BlpHeader, BlpVersion},
locator::MipmapLocator,
};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct BlpRaw3 {
pub cmap: Vec<u32>,
pub images: Vec<Raw3Image>,
}
impl BlpRaw3 {
pub fn mipmap_locator(&self, version: BlpVersion) -> MipmapLocator {
let mut offsets = [0; 16];
let mut sizes = [0; 16];
let mut cur_offset = BlpHeader::size(version) + self.cmap.len() * 4;
for (i, image) in self.images.iter().take(16).enumerate() {
offsets[i] = cur_offset as u32;
sizes[i] = image.len() as u32;
cur_offset += image.len();
}
MipmapLocator::Internal { offsets, sizes }
}
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Raw3Image {
pub pixels: Vec<u32>,
}
impl Raw3Image {
pub fn len(&self) -> usize {
self.pixels.len() * 4
}
pub fn is_empty(&self) -> bool {
self.pixels.is_empty()
}
}