mirror of
https://gitlab.com/Syroot/Worms.git
synced 2025-05-05 19:29:34 +03:00
Fix IGD bitmap width.
This commit is contained in:
parent
ff76e5b9c0
commit
dac33e441a
@ -18,16 +18,19 @@ namespace Syroot.Worms.Scratchpad
|
|||||||
private static void ConvertIgdImages()
|
private static void ConvertIgdImages()
|
||||||
{
|
{
|
||||||
string igdFolder = @"C:\Games\WWP Aqua\Images";
|
string igdFolder = @"C:\Games\WWP Aqua\Images";
|
||||||
string pngFolder = @"D:\Pictures\LPD";
|
string pngFolder = @"D:\Pictures\IGD";
|
||||||
Directory.CreateDirectory(pngFolder);
|
Directory.CreateDirectory(pngFolder);
|
||||||
|
|
||||||
foreach (string igdFilePath in Directory.GetFiles(igdFolder, "*.igd", SearchOption.AllDirectories))
|
foreach (string igdFilePath in Directory.GetFiles(igdFolder, "*.igd", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
|
|
||||||
// Load the IGD and let it convert the images.
|
// Load the IGD and let it convert the images.
|
||||||
Igd igd = new Igd(igdFilePath);
|
Igd igd = new Igd(igdFilePath);
|
||||||
|
|
||||||
// Save the images in the output folder.
|
// Save the images in the output folder under a relative path.
|
||||||
string pngIgdFolder = Path.Combine(pngFolder, Path.GetFileName(igdFilePath));
|
string igdFileFolder = Path.GetDirectoryName(igdFilePath);
|
||||||
|
string relativePath = igdFileFolder.Substring(igdFolder.Length).TrimStart(Path.DirectorySeparatorChar);
|
||||||
|
string pngIgdFolder = Path.Combine(pngFolder, relativePath, Path.GetFileName(igdFilePath));
|
||||||
Directory.CreateDirectory(pngIgdFolder);
|
Directory.CreateDirectory(pngIgdFolder);
|
||||||
for (int i = 0; i < igd.Images.Count; i++)
|
for (int i = 0; i < igd.Images.Count; i++)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Syroot.BinaryData;
|
using Syroot.BinaryData;
|
||||||
@ -78,8 +77,6 @@ namespace Syroot.Worms.OnlineWorms
|
|||||||
|
|
||||||
// Load the images.
|
// Load the images.
|
||||||
int imageCount = stream.ReadInt32();
|
int imageCount = stream.ReadInt32();
|
||||||
Console.WriteLine(((FileStream)stream).Name);
|
|
||||||
Console.WriteLine(imageCount);
|
|
||||||
Images = new List<IgdImage>(imageCount);
|
Images = new List<IgdImage>(imageCount);
|
||||||
for (int i = 0; i < imageCount; i++)
|
for (int i = 0; i < imageCount; i++)
|
||||||
{
|
{
|
||||||
@ -90,14 +87,16 @@ namespace Syroot.Worms.OnlineWorms
|
|||||||
throw new InvalidDataException("Read index does not match image index.");
|
throw new InvalidDataException("Read index does not match image index.");
|
||||||
image.UnknownB = stream.ReadInt32();
|
image.UnknownB = stream.ReadInt32();
|
||||||
image.UnknownC = stream.ReadInt32();
|
image.UnknownC = stream.ReadInt32();
|
||||||
Size size = new Size(stream.ReadInt32(), stream.ReadInt32());
|
image.Size = new Size(stream.ReadInt32(), stream.ReadInt32());
|
||||||
image.Center = new Point(stream.ReadInt32(), stream.ReadInt32());
|
image.Center = new Point(stream.ReadInt32(), stream.ReadInt32());
|
||||||
|
|
||||||
// Decompress the data.
|
// Decompress the data.
|
||||||
int dataSize = stream.ReadInt32();
|
int dataSize = stream.ReadInt32();
|
||||||
int dataSizeCompressed = stream.ReadInt32();
|
int dataSizeCompressed = stream.ReadInt32();
|
||||||
byte[] data = Decompress(stream, dataSizeCompressed, dataSize);
|
byte[] data = Decompress(stream, dataSizeCompressed, dataSize);
|
||||||
image.Bitmap = BitmapTools.CreateIndexed(data, size, palette);
|
// The actual image width is a multiple of 4.
|
||||||
|
image.Bitmap = BitmapTools.CreateIndexed(data,
|
||||||
|
new Size((image.Size.Width + 4 - 1) / 4 * 4, image.Size.Height), palette);
|
||||||
|
|
||||||
Images.Add(image);
|
Images.Add(image);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ namespace Syroot.Worms.OnlineWorms
|
|||||||
public int UnknownA { get; set; }
|
public int UnknownA { get; set; }
|
||||||
public int UnknownB { get; set; }
|
public int UnknownB { get; set; }
|
||||||
public int UnknownC { get; set; }
|
public int UnknownC { get; set; }
|
||||||
|
public Size Size { get; set; }
|
||||||
public Point Center { get; set; }
|
public Point Center { get; set; }
|
||||||
public Bitmap Bitmap { get; set; }
|
public Bitmap Bitmap { get; set; }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user