mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-07-08 01:31:53 +08:00
Fix dpng may contains zero size image
Use better message for scn
This commit is contained in:
@@ -601,7 +601,8 @@ impl Script for ScnScript {
|
|||||||
text[1][self.language_index][0].set_string(name);
|
text[1][self.language_index][0].set_string(name);
|
||||||
} else {
|
} else {
|
||||||
return Err(anyhow::anyhow!(
|
return Err(anyhow::anyhow!(
|
||||||
"Name is missing for message. (text {j} at scene {i})"
|
"Name is missing for message. (text {j} at scene {i}, message: {})",
|
||||||
|
m.message
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,16 +120,26 @@ impl Script for DpngImage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn export_image(&self) -> Result<ImageData> {
|
fn export_image(&self) -> Result<ImageData> {
|
||||||
let mut base = load_png(MemReaderRef::new(&self.img.tiles[0].png_data))?;
|
let (idx, tile) = self
|
||||||
|
.img
|
||||||
|
.tiles
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.find(|(_, t)| t.size != 0)
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("DPNG image has no valid tiles with PNG data"))?;
|
||||||
|
let mut base = load_png(MemReaderRef::new(&tile.png_data))?;
|
||||||
convert_to_rgba(&mut base)?;
|
convert_to_rgba(&mut base)?;
|
||||||
let mut base = draw_on_canvas(
|
let mut base = draw_on_canvas(
|
||||||
base,
|
base,
|
||||||
self.img.header.image_width,
|
self.img.header.image_width,
|
||||||
self.img.header.image_height,
|
self.img.header.image_height,
|
||||||
self.img.tiles[0].x,
|
tile.x,
|
||||||
self.img.tiles[0].y,
|
tile.y,
|
||||||
)?;
|
)?;
|
||||||
for tile in &self.img.tiles[1..] {
|
for tile in &self.img.tiles[idx + 1..] {
|
||||||
|
if tile.size == 0 {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let mut diff = load_png(MemReaderRef::new(&tile.png_data))?;
|
let mut diff = load_png(MemReaderRef::new(&tile.png_data))?;
|
||||||
convert_to_rgba(&mut diff)?;
|
convert_to_rgba(&mut diff)?;
|
||||||
draw_on_image(&mut base, &diff, tile.x, tile.y)?;
|
draw_on_image(&mut base, &diff, tile.x, tile.y)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user