2 Commits

Author SHA1 Message Date
1203b25b63 0.2.14 release 2025-12-11 15:39:57 +08:00
3c49e9a991 Add support to import softpal pgd image as normal ge image 2025-12-11 15:39:14 +08:00
3 changed files with 43 additions and 3 deletions

2
Cargo.lock generated
View File

@@ -1329,7 +1329,7 @@ dependencies = [
[[package]]
name = "msg_tool"
version = "0.2.13"
version = "0.2.14"
dependencies = [
"adler",
"anyhow",

View File

@@ -1,6 +1,6 @@
[package]
name = "msg_tool"
version = "0.2.13"
version = "0.2.14"
edition = "2024"
repository = "https://github.com/lifegpc/msg-tool"
description = "A command-line tool for exporting, importing, packing, and unpacking script files."

View File

@@ -65,6 +65,7 @@ pub struct Pgd3 {
base_header: PgdGeHeader,
base: ImageData,
diff: ImageData,
fake_compress: bool,
}
impl Pgd3 {
@@ -72,7 +73,7 @@ impl Pgd3 {
mut reader: R,
filename: &str,
encoding: Encoding,
_config: &ExtraConfig,
config: &ExtraConfig,
archive: Option<&Box<dyn Script>>,
) -> Result<Self> {
let mut sig = [0u8; 4];
@@ -110,6 +111,7 @@ impl Pgd3 {
base_header,
base,
diff,
fake_compress: config.pgd_fake_compress,
})
}
}
@@ -147,6 +149,44 @@ impl Script for Pgd3 {
)?;
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<()> {