Implement writing image and half the platte information
This commit is contained in:
@@ -75,7 +75,7 @@ impl TIMInfo {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn change_palette_size(&mut self, width: u32, height: u32) -> Result<Option<slint::Image>, Error> {
|
||||
pub fn change_palette_size(&mut self, width: u16, height: u16) -> Result<Option<slint::Image>, Error> {
|
||||
if let Some(palette) = &mut self.palette {
|
||||
if width == 0 || height == 0 {
|
||||
return Err(Error::from_text(format!("{}px x {}px is not a valid size for palette", width, height)));
|
||||
@@ -119,6 +119,16 @@ impl TIMInfo {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_palette_size(&self) -> Option<(u16, u16)> {
|
||||
if let Some(palette_info) = &self.palette {
|
||||
Some((palette_info.width, palette_info.height))
|
||||
}
|
||||
|
||||
else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_path(&self) -> std::path::PathBuf {
|
||||
self.path.clone()
|
||||
}
|
||||
@@ -127,8 +137,8 @@ impl TIMInfo {
|
||||
#[derive(Clone)]
|
||||
struct PaletteInfo {
|
||||
data: Vec<Rgba8Pixel>,
|
||||
width: u32,
|
||||
height: u32,
|
||||
width: u16,
|
||||
height: u16,
|
||||
}
|
||||
|
||||
impl PaletteInfo {
|
||||
@@ -138,7 +148,7 @@ impl PaletteInfo {
|
||||
}
|
||||
|
||||
pub fn get_image(&self) -> slint::Image {
|
||||
let mut image_data = SharedPixelBuffer::new(self.width, self.height);
|
||||
let mut image_data = SharedPixelBuffer::new(self.width as u32, self.height as u32);
|
||||
let dst_pixels = image_data.make_mut_slice();
|
||||
|
||||
for (idx, byte) in dst_pixels.iter_mut().enumerate() {
|
||||
|
||||
Reference in New Issue
Block a user