Exemplo n.º 1
0
        private void ReadPixels(BinaryReader reader)
        {
            if (UsesPalette)
            {
                byte[] temp;
                PS2PixelFormatHelper.ReadPixelData(PixelFormat, reader, Width, Height, out temp);
                PixelIndices = temp;

                MipMapPixelIndices = new byte[MipMapCount][];
                for (int i = 0; i < MipMapCount; i++)
                {
                    int div = 2 * (2 * i);
                    PS2PixelFormatHelper.ReadPixelData(PixelFormat, reader, Width / div, Height / div, out MipMapPixelIndices[i]);
                }
            }
            else
            {
                Color[] temp;
                PS2PixelFormatHelper.ReadPixelData(PixelFormat, reader, Width, Height, out temp);
                Pixels = temp;

                MipMapPixels = new Color[MipMapCount][];
                for (int i = 0; i < MipMapCount; i++)
                {
                    int div = 2 * (2 * i);
                    PS2PixelFormatHelper.ReadPixelData(PixelFormat, reader, Width / div, Height / div, out MipMapPixels[i]);
                }
            }
        }
Exemplo n.º 2
0
        private void ReadPalette(BinaryReader reader)
        {
            int paletteWH;

            if (PixelFormat == PS2PixelFormat.PSMT4 || PixelFormat == PS2PixelFormat.PSMT4HL || PixelFormat == PS2PixelFormat.PSMT4HH)
            {
                PaletteColorCount = 16;
                paletteWH         = 4;
            }
            else
            {
                PaletteColorCount = 256;
                paletteWH         = 16;
            }

            Palettes = new Color[PaletteCount][];

            for (int i = 0; i < PaletteCount; i++)
            {
                PS2PixelFormatHelper.ReadPixelData(PaletteFormat, reader, paletteWH, paletteWH, out Palettes[i]);

                if (PaletteColorCount == 256)
                {
                    PS2PixelFormatHelper.TilePalette(Palettes[i], out Palettes[i]);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Read the palette from the stream using given pixel format, untile it, and set the data as the palette member value.
        /// </summary>
        private void ReadPalette(BinaryReader reader)
        {
            int paletteWH = PS2PixelFormatHelper.GetPaletteDimension(RasterInfoStructNode.Tex0Register.TexturePixelFormat);

            PS2PixelFormatHelper.ReadPixelData(RasterInfoStructNode.Tex0Register.ClutPixelFormat, reader, paletteWH, paletteWH, out mPalette);

            if (paletteWH == 16)
            {
                PS2PixelFormatHelper.TilePalette(mPalette, out mPalette);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Read the pixel data from the stream using given info.
 /// </summary>
 /// <param name="reader"></param>
 private void ReadPixels(BinaryReader reader)
 {
     PS2PixelFormatHelper.ReadPixelData(RasterInfoStructNode.Tex0Register.TexturePixelFormat, reader, RasterInfoStructNode.Width, RasterInfoStructNode.Height, out mPixels);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Read the pixel indices from the stream using given info, unswizzle it, and set the data as the pixel indices member value.
 /// </summary>
 private void ReadIndices(BinaryReader reader)
 {
     PS2PixelFormatHelper.ReadPixelData(RasterInfoStructNode.Tex0Register.TexturePixelFormat, reader, RasterInfoStructNode.Width, RasterInfoStructNode.Height, out mIndices);
     PS2PixelFormatHelper.UnSwizzle8(RasterInfoStructNode.Width, RasterInfoStructNode.Height, mIndices, out mIndices);
 }