Пример #1
0
            public void Read(FileReader reader, Header header, string EmitterName)
            {
                CanReplace      = true;
                CanRename       = false;
                PlatformSwizzle = PlatformSwizzle.Platform_3DS;

                if (header.Version <= 11)
                {
                    Width  = reader.ReadUInt16();
                    Height = reader.ReadUInt16();
                    ushort Format = reader.ReadUInt16();
                    ushort unk4   = reader.ReadUInt16();
                    SurfFormatOld = (CTR_3DS.PICASurfaceFormat)Format;
                    uint unk = reader.ReadUInt32();
                    ImageSize = reader.ReadUInt32();
                    DataPos   = reader.ReadUInt32();
                    uint unk2 = reader.ReadUInt32();
                    uint unk3 = reader.ReadUInt32();
                }
                else
                {
                    Width   = reader.ReadUInt16();
                    Height  = reader.ReadUInt16();
                    Swizzle = reader.ReadUInt32();
                    uint Alignment = reader.ReadUInt32();
                    uint Pitch     = reader.ReadUInt32();
                    WrapMode = reader.ReadByte(); //11 = repeat, 22 = mirror
                    byte unk      = reader.ReadByte();
                    byte unk2     = reader.ReadByte();
                    byte unk3     = reader.ReadByte();
                    uint mipCount = reader.ReadUInt32();
                    CompSel = reader.ReadUInt32();
                    uint[] MipOffsets = reader.ReadUInt32s(13);
                    uint[] unk4       = reader.ReadUInt32s(4);

                    uint originalDataFormat = reader.ReadUInt32();
                    uint originalDataPos    = reader.ReadUInt32();
                    uint originalDataSize   = reader.ReadUInt32();
                    SurfFormat = reader.ReadEnum <SurfaceFormat>(false);
                    ImageSize  = reader.ReadUInt32();
                    DataPos    = reader.ReadUInt32();
                    uint handle = reader.ReadUInt32();
                }


                ArrayCount = 1;

                if (Width != 0 && Height != 0)
                {
                    using (reader.TemporarySeek(header.TextureBlockTableOffset + DataPos, SeekOrigin.Begin))
                    {
                        data = reader.ReadBytes((int)ImageSize);
                    }
                }

                if (data != null && data.Length > 0)
                {
                    ConvertFormat(header.Version);
                }
            }
        public void LoadDDS(string FileName, byte[] FileData = null)
        {
            TexName = STGenericTexture.SetNameFromPath(FileName);

            DDS dds = new DDS();

            if (FileData != null)
            {
                dds.Load(new FileReader(new MemoryStream(FileData)));
            }
            else
            {
                dds.Load(new FileReader(FileName));
            }
            MipCount    = dds.header.mipmapCount;
            TexWidth    = dds.header.width;
            TexHeight   = dds.header.height;
            arrayLength = 1;
            if (dds.header.caps2 == (uint)DDS.DDSCAPS2.CUBEMAP_ALLFACES)
            {
                arrayLength = 6;
            }
            DataBlockOutput.Add(dds.bdata);

            Format = (CTR_3DS.PICASurfaceFormat)CTR_3DS.ConvertToPICAFormat(dds.Format);
        }
        public void LoadBitMap(Image Image, string FileName)
        {
            DecompressedData.Clear();

            TexName = STGenericTexture.SetNameFromPath(FileName);

            Format = CTR_3DS.PICASurfaceFormat.RGBA8;

            GenerateMipmaps = true;
            LoadImage(new Bitmap(Image));
        }
        public void LoadBitMap(Image Image, string FileName)
        {
            DecompressedData.Clear();

            TexName = STGenericTexture.SetNameFromPath(FileName);

            Format = CTR_3DS.ConvertToPICAFormat(Runtime.PreferredTexFormat);

            GenerateMipmaps = true;
            LoadImage(new Bitmap(Image));
        }
Пример #5
0
            public Texture(FileReader reader)
            {
                ImageSize = reader.ReadUInt32();
                MaxLevel  = reader.ReadUInt16();
                Unknown   = reader.ReadUInt16();
                Width     = reader.ReadUInt16();
                Height    = reader.ReadUInt16();
                TextureFormat Format = reader.ReadEnum <TextureFormat>(true);

                DataOffset = reader.ReadUInt32();
                Name       = reader.ReadString(16).TrimEnd('\0');

                PicaFormat = ToPica(Format);
            }
        public void LoadBitMap(string FileName)
        {
            DecompressedData.Clear();

            TexName = STGenericTexture.SetNameFromPath(FileName);

            Format          = CTR_3DS.PICASurfaceFormat.RGBA8;
            GenerateMipmaps = true;

            //If a texture is .tga, we need to convert it
            Bitmap Image = null;

            if (Utils.GetExtension(FileName) == ".tga")
            {
                Image = Paloma.TargaImage.LoadTargaImage(FileName);
            }
            else
            {
                Image = new Bitmap(FileName);
            }

            LoadImage(Image);
        }
Пример #7
0
 public CTRSwizzle(CTR_3DS.PICASurfaceFormat format)
 {
     Format = format;
 }