Example #1
0
    static TextureFormat GetFormatOfDdsBytes(byte[] bytes)
    {
        Stream       ms     = new MemoryStream(bytes);
        BinaryReader Stream = new BinaryReader(ms);

        LoadDDsHeader = BinaryStreamDdsHeader(Stream);

        return(ReadFourcc());
    }
Example #2
0
        public IDictionary <string, string> GetHeadersByClass(HeaderClass hclass)
        {
            var types = HeaderType.GetAll().Where(x => x.Class == hclass).Select(x => x.Value).ToArray();

            if (types == null || types.Length < 1)
            {
                return(null);
            }

            return(this.Where(x => types.Contains(x.Key)).ToDictionary(x => x.Key, y => y.Value));
        }
Example #3
0
    public static TextureFormat GetFormatOfDds(string FinalImagePath)
    {
        if (!File.Exists(FinalImagePath))
        {
            Debug.LogWarning("File not exist!");
            return(TextureFormat.DXT5);
        }

        System.IO.FileStream fs     = new System.IO.FileStream(FinalImagePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
        BinaryReader         Stream = new BinaryReader(fs);

        LoadDDsHeader = BinaryStreamDdsHeader(Stream);

        return(ReadFourcc());
    }
Example #4
0
    static HeaderClass BinaryStreamDdsHeader(BinaryReader Stream)
    {
        HeaderClass DDsHeader = new HeaderClass();

        DDsHeader.Magic       = Stream.ReadUInt32();
        DDsHeader.size        = Stream.ReadUInt32();
        DDsHeader.flags       = Stream.ReadUInt32();
        DDsHeader.height      = Stream.ReadUInt32();
        DDsHeader.width       = Stream.ReadUInt32();
        DDsHeader.sizeorpitch = Stream.ReadUInt32();
        DDsHeader.depth       = Stream.ReadUInt32();
        DDsHeader.mipmapcount = Stream.ReadUInt32();

        DDsHeader.alphabitdepth = Stream.ReadUInt32();

        /*DDsHeader.reserved = new uint[10];
         * for (int i = 0; i < 10; i++)
         * {
         *      DDsHeader.reserved[i] = Stream.ReadUInt32();
         * }*/

        DDsHeader.reserved0 = Stream.ReadUInt32();
        DDsHeader.reserved1 = Stream.ReadUInt32();
        DDsHeader.reserved2 = Stream.ReadUInt32();
        DDsHeader.reserved3 = Stream.ReadUInt32();
        DDsHeader.reserved4 = Stream.ReadUInt32();
        DDsHeader.reserved5 = Stream.ReadUInt32();
        DDsHeader.reserved6 = Stream.ReadUInt32();
        DDsHeader.reserved7 = Stream.ReadUInt32();
        DDsHeader.reserved8 = Stream.ReadUInt32();
        DDsHeader.reserved9 = Stream.ReadUInt32();

        DDsHeader.pixelformatSize        = Stream.ReadUInt32();
        DDsHeader.pixelformatflags       = Stream.ReadUInt32();
        DDsHeader.pixelformatFourcc      = Stream.ReadUInt32();
        DDsHeader.pixelformatRgbBitCount = Stream.ReadUInt32();
        DDsHeader.pixelformatRbitMask    = Stream.ReadUInt32();
        DDsHeader.pixelformatGbitMask    = Stream.ReadUInt32();
        DDsHeader.pixelformatBbitMask    = Stream.ReadUInt32();
        DDsHeader.pixelformatAbitMask    = Stream.ReadUInt32();

        DDsHeader.caps1 = Stream.ReadUInt32();
        DDsHeader.caps2 = Stream.ReadUInt32();
        DDsHeader.caps3 = Stream.ReadUInt32();
        DDsHeader.caps4 = Stream.ReadUInt32();

        return(DDsHeader);
    }
Example #5
0
        public static void ConvertToMIDI(string outputFile, Stream inputStream, byte chunk, bool restrict)
        {
            Settings.LimitChunks = chunk;
            Settings.Restrict    = restrict;

            // Dim fileStream1 As New FileStream(file, FileMode.Open, FileAccess.Read)
            var fileStream2 = new FileStream(outputFile, FileMode.Create, FileAccess.ReadWrite);
            var br          = new BinaryReader(inputStream);
            var bw          = new BinaryWriter(fileStream2);

            ReadHeader(br);
            if (!HeaderData.Valid)
            {
                throw new FormatException("Header of .m64 file is invalid!");
            }
            else
            {
                StartMIDIHeader(bw);
                StartMIDISettings(bw);
                long position = bw.BaseStream.Position;
                byte track    = 0;
                while (Conversions.ToInteger(track) < 16)
                {
                    byte layer = 0;
                    while (Conversions.ToInteger(layer) < 16)
                    {
                        HeaderData.TotalTimestamp = 0;
                        br.BaseStream.Position    = 0L;
                        StartMIDITrack(bw, track);
                        ConvertHeader(br, bw, track, layer);
                        FinishMIDITrack(bw, track);
                        TrackData = new TrackClass();
                        LayerData = new LayerClass();
                        NoteData  = new NoteClass();
                        layer    += 1;
                    }

                    track += 1;
                }

                if (position == bw.BaseStream.Position)
                {
                    br.Close();
                    bw.Flush();
                    bw.Close();
                    // fileStream1.Close()
                    fileStream2.Close();
                    HeaderData = new HeaderClass();
                    File.Delete(fileStream2.Name);
                    throw new FormatException(".m64 file is invalid!");
                }
                else
                {
                    FinishMIDIHeader(bw);
                    FinishMIDISettings(bw);
                    br.Close();
                    bw.Flush();
                    bw.Close();
                    // fileStream1.Close()
                    fileStream2.Close();
                    HeaderData = new HeaderClass();
                }
            }
        }
	public TextureFormat GetFormatOfDds(string FinalImagePath){

		if(!File.Exists(FinalImagePath)){
			Debug.LogError("File not exist!");
			return TextureFormat.DXT5;
		}

		// Load DDS Header
		System.IO.FileStream fs = new System.IO.FileStream(FinalImagePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
		BinaryReader Stream = new BinaryReader(fs);
		LoadDDsHeader = new HeaderClass();
		
		byte[] signature = Stream.ReadBytes(4);
		LoadDDsHeader.size = Stream.ReadUInt32();
		LoadDDsHeader.flags = Stream.ReadUInt32();
		LoadDDsHeader.height = Stream.ReadUInt32();
		LoadDDsHeader.width = Stream.ReadUInt32();
		LoadDDsHeader.sizeorpitch = Stream.ReadUInt32();
		LoadDDsHeader.depth = Stream.ReadUInt32();
		LoadDDsHeader.mipmapcount = Stream.ReadUInt32();
		LoadDDsHeader.alphabitdepth = Stream.ReadUInt32();
		
		
		LoadDDsHeader.reserved = new uint[10];
		for (int i = 0; i < 10; i++)
		{
			LoadDDsHeader.reserved[i] = Stream.ReadUInt32();
		}
		
		LoadDDsHeader.pixelformatSize = Stream.ReadUInt32();
		LoadDDsHeader.pixelformatflags = Stream.ReadUInt32();
		LoadDDsHeader.pixelformatFourcc = Stream.ReadUInt32();
		LoadDDsHeader.pixelformatRgbBitCount = Stream.ReadUInt32();
		LoadDDsHeader.pixelformatRbitMask = Stream.ReadUInt32();
		LoadDDsHeader.pixelformatGbitMask = Stream.ReadUInt32();
		LoadDDsHeader.pixelformatBbitMask = Stream.ReadUInt32();
		LoadDDsHeader.pixelformatAbitMask = Stream.ReadUInt32();

		return ReadFourcc(LoadDDsHeader.pixelformatFourcc);

	}
 public MainForm()
 {
     HeaderClass = new HeaderClass(this);
 }
	public static HeaderClass BinaryStreamDdsHeader(BinaryReader Stream){
		HeaderClass DDsHeader = new HeaderClass();

		DDsHeader.Magic = Stream.ReadUInt32();				
		DDsHeader.size = Stream.ReadUInt32();
		DDsHeader.flags = Stream.ReadUInt32();
		DDsHeader.height = Stream.ReadUInt32();
		DDsHeader.width = Stream.ReadUInt32();
		DDsHeader.sizeorpitch = Stream.ReadUInt32();
		DDsHeader.depth = Stream.ReadUInt32();
		DDsHeader.mipmapcount = Stream.ReadUInt32();

		DDsHeader.alphabitdepth = Stream.ReadUInt32();
		DDsHeader.reserved = new uint[10];
		for (int i = 0; i < 10; i++)
		{
			DDsHeader.reserved[i] = Stream.ReadUInt32();
		}

		DDsHeader.pixelformatSize = Stream.ReadUInt32();
		DDsHeader.pixelformatflags = Stream.ReadUInt32();
		DDsHeader.pixelformatFourcc = Stream.ReadUInt32();
		DDsHeader.pixelformatRgbBitCount = Stream.ReadUInt32();
		DDsHeader.pixelformatRbitMask = Stream.ReadUInt32();
		DDsHeader.pixelformatGbitMask = Stream.ReadUInt32();
		DDsHeader.pixelformatBbitMask = Stream.ReadUInt32();
		DDsHeader.pixelformatAbitMask = Stream.ReadUInt32();

		DDsHeader.caps1 = Stream.ReadUInt32();
		DDsHeader.caps2 = Stream.ReadUInt32();
		DDsHeader.caps3 = Stream.ReadUInt32();
		DDsHeader.caps4 = Stream.ReadUInt32();

		return DDsHeader;
	}
	public TextureFormat GetFormatOfDds(string FinalImagePath){

		if(!File.Exists(FinalImagePath)){
			Debug.LogError("File not exist!");
			return TextureFormat.DXT5;
		}
			
		System.IO.FileStream fs = new System.IO.FileStream(FinalImagePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
		BinaryReader Stream = new BinaryReader(fs);
		LoadDDsHeader = BinaryStreamDdsHeader(Stream);

		return ReadFourcc(LoadDDsHeader.pixelformatFourcc);
	}
	public static TextureFormat GetFormatOfDdsBytes(byte[] bytes){

		Stream ms = new MemoryStream(bytes);
		BinaryReader Stream = new BinaryReader(ms);
		LoadDDsHeader = BinaryStreamDdsHeader(Stream);

		return ReadFourcc(LoadDDsHeader.pixelformatFourcc);
	}
Example #11
0
 private HeaderType(string value, HeaderClass hclass) : base(value, value)
 {
     this.Class = hclass;
 }
Example #12
0
 public HeaderableList(string name = "")
 {
     _header = new HeaderClass(name);
     _list   = new List <T>();
 }