Westwood PAL to photoshop ACT converter

Information and discussion for custom maps and mods.
Post Reply
User avatar
katzsmile
Posts: 39
Joined: Mon Sep 06, 2010 7:03 am
Location: Arkhangelsk
Contact:

Westwood PAL to photoshop ACT converter

Post by katzsmile »

Westwood PAL palette to photoshop ACT palette converter.

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace westwoodPALtoACT
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Westwood PAL to Photoshop ACT converter\n");
                Console.WriteLine("Usage: westwoodPALtoACT.exe westwood.pal\n");
                Console.WriteLine("westwoodPALtoACT.exe westwood.pal");
                return;
            }
            if (args != null && args.Length > 0)
            {
                if (File.Exists(args[0]))
                {
                    string ACTfile = Path.GetFileNameWithoutExtension(args[0])+ ".act";
                    Console.WriteLine("Output file: " + ACTfile);
                    using (MemoryStream palette = new MemoryStream(File.ReadAllBytes(args[0])))
                    {

                        using (BinaryReader reader = new BinaryReader(palette))
                        {
                            FileStream act = File.Create(ACTfile, 768, FileOptions.None);
                            using (BinaryWriter writer = new BinaryWriter(act))
                            {
                                for &#40;int i = 0; i < 256; i++&#41;
                                &#123;
                                    byte r = &#40;byte&#41;&#40;reader.ReadByte&#40;&#41; << 2&#41;;
                                    byte g = &#40;byte&#41;&#40;reader.ReadByte&#40;&#41; << 2&#41;;
                                    byte b = &#40;byte&#41;&#40;reader.ReadByte&#40;&#41; << 2&#41;;
                                    byte&#91;&#93; color = new byte&#91;3&#93; &#123;r,g,b&#125;;
                                    writer.Write&#40;color&#41;;
                                &#125;
                                writer.Close&#40;&#41;;
                            &#125;
                            reader.Close&#40;&#41;;
                        &#125;
                    &#125;
                &#125;
            &#125;
        &#125;
    &#125;
&#125;
Attachments
westwoodPALtoACT.zip
(16.2 KiB) Downloaded 233 times
westwoodPALtoACT.png
westwoodPALtoACT.png (25.88 KiB) Viewed 2491 times
ps_act.png
ps_act.png (28.59 KiB) Viewed 2489 times

Matt
Posts: 1144
Joined: Tue May 01, 2012 12:21 pm
Location: Germany

Post by Matt »

Looks similar to the PaintShop and GIMP palette file formats. I tried to add support for them in: https://github.com/OpenRA/OpenRA/pull/13913

Post Reply