use super::Buffer;
use crate::graphics::{resize_buffer, u32_to_rgba_u8, InterpolationMode};
impl Buffer {
#[must_use]
pub fn to_u8_argb(&self) -> Vec<u8> {
let mut return_list = Vec::new();
for i in &self.data {
let temp = u32_to_rgba_u8(*i);
return_list.push(temp.0);
return_list.push(temp.1);
return_list.push(temp.2);
return_list.push(temp.3);
}
return_list
}
#[must_use]
pub fn to_u8_rgba(&self) -> Vec<u8> {
let mut return_list = Vec::new();
for i in &self.data {
let temp = u32_to_rgba_u8(*i);
return_list.push(temp.3);
return_list.push(temp.1);
return_list.push(temp.2);
return_list.push(temp.0);
}
return_list
}
#[must_use]
pub fn resize_content(
&self,
size: (usize, usize),
resizing_method: InterpolationMode,
) -> Self {
let mut new = Self::new_empty(size);
let b = resize_buffer(
self,
self.width,
self.height,
size.0,
size.1,
resizing_method,
);
new.data.copy_from_slice(&b);
new
}
}