Example #1
0
        protected override void OnOpen(EndianBinaryReader reader)
        {
            ImageWidth    = reader.ReadUInt16();
            ImageHeight   = reader.ReadUInt16();
            ColorCount    = reader.ReadUInt16();
            Unknown0x06   = reader.ReadUInt16();
            PaletteWidth  = reader.ReadUInt16();
            PaletteHeight = reader.ReadUInt16();
            Padding       = reader.ReadUInt32();

            PaletteData = new byte[PaletteHeight][];
            for (int py = 0; py < PaletteHeight; py++)
            {
                PaletteData[py] = PS2.ReadPaletteData(reader, (ColorCount == 256 ? PS2PixelFormat.PSMT8 : PS2PixelFormat.PSMT4), PS2PixelFormat.PSMCT32);
            }

            PixelData = reader.ReadBytes((ImageWidth * ImageHeight) / (ColorCount == 256 ? 1 : 2));

            /* Initialize ImageBinary */
            imageBinary                    = new ImageBinary();
            imageBinary.Width              = ImageWidth;
            imageBinary.Height             = ImageHeight;
            imageBinary.InputPaletteFormat = PixelDataFormat.FormatBgra8888;
            imageBinary.InputPixelFormat   = (ColorCount == 256 ? PixelDataFormat.FormatIndexed8 : PixelDataFormat.FormatIndexed4);
            imageBinary.InputEndianness    = Endian.LittleEndian;

            foreach (byte[] palette in PaletteData)
            {
                imageBinary.AddInputPalette(palette);
            }
            imageBinary.AddInputPixels(PixelData);
        }
Example #2
0
 /// <summary>
 /// Initialize a new instance of <see cref="RWRaster"/> using a width, height, palette, pixel indices and pixel format.
 /// </summary>
 /// <param name="width">Width of the texture.</param>
 /// <param name="height">Height of the texture.</param>
 /// <param name="palette">Palette colors of the texture.</param>
 /// <param name="indices">Per-pixel palette color indices of the texture.</param>
 /// <param name="pixelFormat">PS2 pixel format of the given data.</param>
 /// <param name="parent">Parent of this <see cref="RWRaster"/> node. Value is null if not specified.</param>
 public RWRaster(int width, int height, Color[] palette, byte[] indices, 
     PS2.Graphics.PS2PixelFormat pixelFormat, RWNode parent = null)
     : base(RWNodeType.Struct, parent)
 {
     Info = new RWRasterInfo(width, height, pixelFormat);
     Data = new RWRasterData(palette, indices, pixelFormat);
 }
Example #3
0
        public IGame FactoryMethod(Games gameType)
        {
            IGame game = null;

            switch (gameType)
            {
            case Games.Atari:
                game = new Atari2();
                break;

            case Games.PC:
                game = new PC2();
                break;

            case Games.PS:
                game = new PS2();
                break;
            }
            return(game);
        }
Example #4
0
        protected override void OnOpen(EndianBinaryReader reader)
        {
            Unknown0x00   = reader.ReadUInt16();
            ID            = reader.ReadUInt16();
            FileSize      = reader.ReadUInt32();
            MagicNumber   = Encoding.ASCII.GetString(reader.ReadBytes(4), 0, 4);
            Unknown0x0C   = reader.ReadUInt32();
            Unknown0x10   = reader.ReadByte();
            PaletteFormat = (PS2PixelFormat)reader.ReadByte();
            Width         = reader.ReadUInt16();
            Height        = reader.ReadUInt16();
            PixelFormat   = (PS2PixelFormat)reader.ReadByte();
            MipmapCount   = reader.ReadByte();
            MipmapKValue  = reader.ReadByte();
            MipmapLValue  = reader.ReadByte();
            TextureWrap   = (PS2WrapMode)reader.ReadUInt16();
            TextureID     = reader.ReadUInt32();
            CLUTID        = reader.ReadUInt32();
            Comment       = Encoding.ASCII.GetString(reader.ReadBytes(0x1C), 0, 0x1C);

            if (PS2.IsFormatIndexed(PixelFormat))
            {
                PaletteData = PS2.ReadPaletteData(reader, PixelFormat, PaletteFormat);
            }

            PixelData = reader.ReadBytes(CalculatePixelDataSize(Width, Height, PixelFormat));

            imageBinary                    = new ImageBinary();
            imageBinary.Width              = (int)Width;
            imageBinary.Height             = (int)Height;
            imageBinary.InputPaletteFormat = PS2.GetPixelDataFormat(PaletteFormat);
            imageBinary.InputPixelFormat   = PS2.GetPixelDataFormat(PixelFormat);
            imageBinary.InputEndianness    = Endian.LittleEndian;

            imageBinary.AddInputPalette(PaletteData);
            imageBinary.AddInputPixels(PixelData);
        }
Example #5
0
 /// <summary>
 /// Initialize a new instance of <see cref="RWRaster"/> using a bitmap to encode using the given pixel format.
 /// </summary>
 /// <param name="bitmap">Bitmap to encode to the specified pixel format.</param>
 /// <param name="pixelFormat">Pixel format to encode the bitmap to.</param>
 /// <param name="parent">Parent of this <see cref="RWRaster"/> node. Value is null if not specified.</param>
 public RWRaster(Bitmap bitmap, PS2.Graphics.PS2PixelFormat pixelFormat, RWNode parent = null)
     : base(RWNodeType.Struct, parent)
 {
     Info = new RWRasterInfo(bitmap.Width, bitmap.Height, pixelFormat);
     Data = new RWRasterData(bitmap, pixelFormat);
 }
Example #6
0
        protected override void OnOpen(EndianBinaryReader reader)
        {
            /* Read header(?) */
            Unknown0x00         = reader.ReadUInt32();
            Unknown0x04         = reader.ReadUInt32();
            FrameDataOffset     = reader.ReadUInt32();
            PixelDataOffset     = reader.ReadUInt32();
            RawImageWidth       = reader.ReadUInt16();
            RawImageHeight      = reader.ReadUInt16();
            NumImageInformation = reader.ReadUInt16();
            BlockWidth          = reader.ReadByte();
            BlockHeight         = reader.ReadByte();
            Unknown0x18         = reader.ReadUInt16();
            Unknown0x1A         = reader.ReadUInt16();
            Unknown0x1C         = reader.ReadUInt32();
            Unknown0x20         = reader.ReadUInt32();
            Unknown0x24         = reader.ReadUInt32();
            Unknown0x28         = reader.ReadUInt32();
            Unknown0x2C         = reader.ReadUInt32();
            Unknown0x30         = reader.ReadUInt32();
            Unknown0x34         = reader.ReadUInt32();
            Unknown0x38         = reader.ReadUInt32();
            Unknown0x3C         = reader.ReadUInt32();

            /* Get image information */
            ImageInfos = new TIPSImageInfo[NumImageInformation];
            for (int i = 0; i < NumImageInformation; i++)
            {
                ImageInfos[i] = new TIPSImageInfo(reader);
            }

            /* Get rect information */
            RectInfos = new Dictionary <TIPSImageInfo, TIPSRectangleInfo[]>();
            for (int i = 0; i < NumImageInformation; i++)
            {
                TIPSImageInfo imageInfo = ImageInfos[i];

                long position = reader.BaseStream.Position;
                reader.BaseStream.Seek(imageInfo.RectOffset, SeekOrigin.Begin);

                RectInfos.Add(imageInfo, new TIPSRectangleInfo[imageInfo.NumRects]);
                for (int j = 0; j < imageInfo.NumRects; j++)
                {
                    RectInfos[imageInfo][j] = new TIPSRectangleInfo(reader);
                }

                reader.BaseStream.Seek(position, SeekOrigin.Begin);
            }

            /* Get all image permutations (eyes, mouths, etc) */
            ImagePermutations = new List <int[]>();
            int maxType = (int)(ImageInfos.Max(x => x.Index) + 1);

            int[] indices = new int[maxType];
            for (int t = maxType - 1; t >= 0; t--)
            {
                GetImagePermutations(ref indices, t);
            }

            /* Get pixel data */
            reader.BaseStream.Seek(PixelDataOffset, SeekOrigin.Begin);
            PixelData = reader.ReadBytes((int)(reader.BaseStream.Length - PixelDataOffset));

            /* Scale alpha */
            for (int i = 0; i < PixelData.Length; i += 4)
            {
                PixelData[i + 3] = PS2.ScaleAlpha(PixelData[i + 3]);
            }

            /* Create raw image bitmap */
            ImageBinary rawImageBinary = new ImageBinary();

            if (RawImageWidth != 0 && RawImageHeight != 0)
            {
                rawImageBinary.Width            = RawImageWidth;
                rawImageBinary.Height           = RawImageHeight;
                rawImageBinary.InputPixelFormat = PixelDataFormat.FormatAbgr8888;
                rawImageBinary.AddInputPixels(PixelData);
                rawImage = rawImageBinary.GetBitmap();
            }
        }