public static ColorPalette DecodePalette(PLT0v1* palette)
 {
     int count = palette->_numEntries;
     ColorPalette pal = ColorPaletteExtension.CreatePalette(ColorPaletteFlags.HasAlpha, count);
     switch (palette->PaletteFormat)
     {
         case WiiPaletteFormat.IA8:
             {
                 IA8Pixel* sPtr = (IA8Pixel*)palette->PaletteData;
                 for (int i = 0; i < count; i++)
                     pal.Entries[i] = (Color)sPtr[i];
                 break;
             }
         case WiiPaletteFormat.RGB565:
             {
                 wRGB565Pixel* sPtr = (wRGB565Pixel*)palette->PaletteData;
                 for (int i = 0; i < count; i++)
                     pal.Entries[i] = (Color)sPtr[i];
                 break;
             }
         case WiiPaletteFormat.RGB5A3:
             {
                 wRGB5A3Pixel* sPtr = (wRGB5A3Pixel*)palette->PaletteData;
                 for (int i = 0; i < count; i++)
                     pal.Entries[i] = (Color)(ARGBPixel)sPtr[i];
                 break;
             }
     }
     return pal;
 }
 public static Bitmap DecodeIndexed(TEX0v1* texture, PLT0v1* palette, int mipLevel)
 {
     return Get(texture->PixelFormat).DecodeTextureIndexed(texture, palette, mipLevel);
 }
        public static FileMap EncodePLT0Palette(ColorPalette pal, WiiPaletteFormat format)
        {
            FileMap fileView = FileMap.FromTempFile((pal.Entries.Length * 2) + 0x40);
            try
            {
                PLT0v1* header = (PLT0v1*)fileView.Address;
                *header = new PLT0v1(pal.Entries.Length, format);

                EncodePalette(fileView.Address + 0x40, pal, format);
                return fileView;
            }
            catch (Exception x)
            {
                fileView.Dispose();
                throw x;
                //MessageBox.Show(x.ToString());
                //fileView.Dispose();
                //return null;
            }
        }
 public virtual Bitmap DecodeTextureIndexed(TEX0v1* texture, PLT0v1* palette, int mipLevel)
 {
     return DecodeTextureIndexed(texture, DecodePalette(palette), mipLevel);
 }
Ejemplo n.º 5
0
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            PLT0v1* header = (PLT0v1*)address;
            *header = new PLT0v1(Palette.Entries.Length, _format);

            TextureConverter.EncodePalette(address + 0x40, Palette, _format);
        }