mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-25 05:07:24 +08:00
Add support to import softpal pgd image as normal ge image
This commit is contained in:
@@ -65,6 +65,7 @@ pub struct Pgd3 {
|
|||||||
base_header: PgdGeHeader,
|
base_header: PgdGeHeader,
|
||||||
base: ImageData,
|
base: ImageData,
|
||||||
diff: ImageData,
|
diff: ImageData,
|
||||||
|
fake_compress: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Pgd3 {
|
impl Pgd3 {
|
||||||
@@ -72,7 +73,7 @@ impl Pgd3 {
|
|||||||
mut reader: R,
|
mut reader: R,
|
||||||
filename: &str,
|
filename: &str,
|
||||||
encoding: Encoding,
|
encoding: Encoding,
|
||||||
_config: &ExtraConfig,
|
config: &ExtraConfig,
|
||||||
archive: Option<&Box<dyn Script>>,
|
archive: Option<&Box<dyn Script>>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let mut sig = [0u8; 4];
|
let mut sig = [0u8; 4];
|
||||||
@@ -110,6 +111,7 @@ impl Pgd3 {
|
|||||||
base_header,
|
base_header,
|
||||||
base,
|
base,
|
||||||
diff,
|
diff,
|
||||||
|
fake_compress: config.pgd_fake_compress,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,6 +149,44 @@ impl Script for Pgd3 {
|
|||||||
)?;
|
)?;
|
||||||
Ok(base)
|
Ok(base)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn import_image<'a>(
|
||||||
|
&'a self,
|
||||||
|
data: ImageData,
|
||||||
|
mut file: Box<dyn WriteSeek + 'a>,
|
||||||
|
) -> Result<()> {
|
||||||
|
let mut header = PgdGeHeader {
|
||||||
|
offset_x: self.base_header.offset_x,
|
||||||
|
offset_y: self.base_header.offset_y,
|
||||||
|
width: self.base_header.width,
|
||||||
|
height: self.base_header.height,
|
||||||
|
canvas_height: self.base_header.canvas_height,
|
||||||
|
canvas_width: self.base_header.canvas_width,
|
||||||
|
mode: self.base_header.mode,
|
||||||
|
_unk: self.base_header._unk,
|
||||||
|
};
|
||||||
|
if data.height != header.height {
|
||||||
|
return Err(anyhow::anyhow!(
|
||||||
|
"Image height does not match: expected {}, got {}",
|
||||||
|
header.height,
|
||||||
|
data.height
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if data.width != header.width {
|
||||||
|
return Err(anyhow::anyhow!(
|
||||||
|
"Image width does not match: expected {}, got {}",
|
||||||
|
header.width,
|
||||||
|
data.width
|
||||||
|
));
|
||||||
|
}
|
||||||
|
header.mode = 3;
|
||||||
|
file.write_all(b"GE \0")?;
|
||||||
|
header.pack(&mut file, false, Encoding::Utf8)?;
|
||||||
|
PgdWriter::new(data, self.fake_compress)
|
||||||
|
.with_method(3)
|
||||||
|
.pack_ge(&mut file)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_on_img(base: &mut ImageData, diff: &ImageData, left: u32, top: u32) -> Result<()> {
|
fn draw_on_img(base: &mut ImageData, diff: &ImageData, left: u32, top: u32) -> Result<()> {
|
||||||
|
|||||||
Reference in New Issue
Block a user