writing out layers
parent
b65ea2ca66
commit
f789d5cd7e
|
@ -21,10 +21,16 @@ namespace Palettizer
|
||||||
public GMSpriteCompositeImage CompositeImage { get; set; }
|
public GMSpriteCompositeImage CompositeImage { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct GMSpriteLayer
|
||||||
|
{
|
||||||
|
public string Name { get; set; } // this is actually a GUID lol
|
||||||
|
}
|
||||||
|
|
||||||
public struct GMSprite
|
public struct GMSprite
|
||||||
{
|
{
|
||||||
public GMTextureGroupID TextureGroupID { get; set; }
|
public GMTextureGroupID TextureGroupID { get; set; }
|
||||||
public GMSpriteFrame[] Frames { get; set; }
|
public GMSpriteFrame[] Frames { get; set; }
|
||||||
|
public GMSpriteLayer[] Layers { get; set; }
|
||||||
public string ResourceType { get; set; }
|
public string ResourceType { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,9 @@ namespace Palettizer
|
||||||
if (GrayscaleToColorMap.ContainsKey((byte)average))
|
if (GrayscaleToColorMap.ContainsKey((byte)average))
|
||||||
{
|
{
|
||||||
var increment = 1;
|
var increment = 1;
|
||||||
for (var i = 0; i < 256 - GrayscaleCount; i += 1)
|
for (var i = 0; i < 256; i += 1)
|
||||||
{
|
{
|
||||||
average += increment;
|
average = (average + increment) % 256;
|
||||||
|
|
||||||
if (!GrayscaleToColorMap.ContainsKey((byte)average))
|
if (!GrayscaleToColorMap.ContainsKey((byte)average))
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,6 @@ namespace Palettizer
|
||||||
|
|
||||||
increment = ((increment > 0) ? (increment + 1) : (increment - 1)) * -1; // up by 1, down by 2, up by 3, etc
|
increment = ((increment > 0) ? (increment + 1) : (increment - 1)) * -1; // up by 1, down by 2, up by 3, etc
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GrayscaleToColorMap.Add((byte)average, color);
|
GrayscaleToColorMap.Add((byte)average, color);
|
||||||
|
|
|
@ -46,10 +46,6 @@ namespace Palettizer
|
||||||
|
|
||||||
console.Out.Write("Parsing: " + gmProject.Name + "\n");
|
console.Out.Write("Parsing: " + gmProject.Name + "\n");
|
||||||
|
|
||||||
if (Directory.Exists("output"))
|
|
||||||
{
|
|
||||||
Directory.Delete("output", true);
|
|
||||||
}
|
|
||||||
var outputDir = Directory.CreateDirectory("output");
|
var outputDir = Directory.CreateDirectory("output");
|
||||||
|
|
||||||
var palette = new Palette();
|
var palette = new Palette();
|
||||||
|
@ -75,8 +71,9 @@ namespace Palettizer
|
||||||
{
|
{
|
||||||
console.Out.Write(sprite.Name + "\n");
|
console.Out.Write(sprite.Name + "\n");
|
||||||
|
|
||||||
foreach (var spriteFrame in sprite.Frames)
|
for (var i = 0; i < sprite.Frames.Length; i += 1)
|
||||||
{
|
{
|
||||||
|
var spriteFrame = sprite.Frames[i];
|
||||||
ImageResult image;
|
ImageResult image;
|
||||||
byte[] grayscaleImage;
|
byte[] grayscaleImage;
|
||||||
|
|
||||||
|
@ -98,6 +95,13 @@ namespace Palettizer
|
||||||
{
|
{
|
||||||
writer.WritePng(grayscaleImage, image.Width, image.Height, StbImageWriteSharp.ColorComponents.RedGreenBlueAlpha, stream);
|
writer.WritePng(grayscaleImage, image.Width, image.Height, StbImageWriteSharp.ColorComponents.RedGreenBlueAlpha, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now write out the layer
|
||||||
|
// There's just 1 always because nobody uses GM's shit ass sprite editor
|
||||||
|
var layerSpriteWriteDir = Path.Combine(spriteWriteDir, "layers", sprite.Frames[i].CompositeImage.FrameID.Name);
|
||||||
|
Directory.CreateDirectory(layerSpriteWriteDir);
|
||||||
|
var layerSpriteWritePath = Path.Combine(layerSpriteWriteDir, sprite.Layers[0].Name + ".png");
|
||||||
|
File.Copy(spriteWritePath, layerSpriteWritePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,6 +140,7 @@ namespace Palettizer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// build the alternate rows
|
||||||
for (var j = 1; j < paletteImage.Width; j += 1)
|
for (var j = 1; j < paletteImage.Width; j += 1)
|
||||||
{
|
{
|
||||||
var colorPalette = new Color[256];
|
var colorPalette = new Color[256];
|
||||||
|
|
Loading…
Reference in New Issue