1

I'm trying to create a mini tool for my job. I'm using C# with Visual Studio 2010 to do that. Now I need to export an image to an act file.

Following here, http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmappalette.aspx

I wrote

class Palette : List<Color>
{
    public static Palette GetFromImage(String PathToImage)
    {
        //Load imgae
        BitmapImage image = new BitmapImage();
        image.BeginInit();
        image.UriSource = new Uri(PathToImage, UriKind.RelativeOrAbsolute);
        image.EndInit();

        //Load palette
        BitmapPalette BitmapPalette = new BitmapPalette(image, 256);


        //Convert it to list of Color
        Palette pal = new Palette();
        for (int i = 0; i < BitmapPalette.Colors.Count; i++)
        {
            pal.Add(Color.FromArgb(BitmapPalette.Colors[i].R, BitmapPalette.Colors[i].G, BitmapPalette.Colors[i].B));
        }
        //Return the palette has been creatted
        return pal;
    }

This code has effected, but the order of all colors in the result did not same as the order of all colors when I export by photoshop. So, when I write all colors to a act file, the act file is not correct.

Anybody can help me.

Many thank

Võ Quang Hòa
  • 2,688
  • 3
  • 27
  • 31
  • Would it be possible to share a snippet of an act file that you are producting, compared to a snippet of one that you are expecting? – Wonko the Sane Jul 25 '12 at 17:28

1 Answers1

-1

Act file is compilated binary file.

You cannot encode an act file.

Perhaps Photoshop can import a css file (as like palet)

Keith Stein
  • 6,235
  • 4
  • 17
  • 36