Example #1
0
 public Wave(string fileName)
 {
     RiffParser parser = new RiffParser();
     RiffDecodeHeader decoder = new RiffDecodeHeader(parser);
     parser.OpenFile(fileName);
     if (RiffParser.ckidAVI == parser.FileType)
     {
         decoder.ProcessMainAVI();
         decoder.ProcessMainWAVE();
         parser.CloseFile();
     }
 }
Example #2
0
        public Wave(string fileName)
        {
            RiffParser       parser  = new RiffParser();
            RiffDecodeHeader decoder = new RiffDecodeHeader(parser);

            parser.OpenFile(fileName);
            if (RiffParser.ckidAVI == parser.FileType)
            {
                decoder.ProcessMainAVI();
                decoder.ProcessMainWAVE();
                parser.CloseFile();
            }
        }
Example #3
0
        public async void CheckFile()
        {
            StorageFolder storageFolder = KnownFolders.MusicLibrary;
            var           checkFile     = await storageFolder.TryGetItemAsync(this.Recorder.FileName);

            if (checkFile == null)
            {
                this.Info.Text = "Wav not recorded ...";
            }
            else
            {
                StorageFile storageFile = await storageFolder.GetFileAsync(this.Recorder.FileName);

                var parser = new RiffParser();

                // read file
                await Windows.System.Threading.ThreadPool.RunAsync(
                    async (workItem) =>
                {
                    IRandomAccessStream stream = await storageFile.OpenAsync(FileAccessMode.Read);
                    Stream sstream             = stream.AsStream();
                    parser.OpenFile(sstream);
                    // Define the processing delegates
                    RiffParser.ProcessChunkElement pc = ProcessChunk;

                    // Read all top level elements and chunks
                    int size = parser.DataSize;
                    while (size > 0)
                    {
                        // Prefix the line with the current top level type
                        var info = (RiffParser.FromFourCC(parser.FileType) + " (" + size.ToString() + "): ");
                        // Get the next element (if there is one)
                        if (false == parser.ReadElement(ref size, pc, null))
                        {
                            break;
                        }
                    }

                    // Close the stream
                    parser.CloseFile();
                });
            }
        }
Example #4
0
        private void CheckFile(string filename)
        {
            rp.OpenFile(filename);
            txtFileFormat.Text = RiffParser.FromFourCC(rp.FileRIFF);
            txtFileType.Text   = RiffParser.FromFourCC(rp.FileType);
            if (txtFileType.Text.StartsWith("CDR"))
            {
            }
            // Is this a type we are familiar with?
            if (RiffParser.ckidAVI == rp.FileType)
            {
                dh.ProcessMainAVI();
                lbl1a.Text = dh.FrameSize;
                lbl2a.Text = dh.FrameRate;
                lbl3a.Text = dh.TotalFrames;
                lbl4a.Text = dh.TotalTime;
                lbl5a.Text = dh.NumStreams;

                lbl1b.Text = dh.ISFT;
                lbl2b.Text = dh.VideoHandler;
                lbl3b.Text = dh.VideoDataRate;
                lbl4b.Text = dh.AudioHandler;
                lbl5b.Text = dh.AudioDataRate;

                pnlAVI.Visible = true;
            }
            else if (RiffParser.ckidWAV == rp.FileType)
            {
                dh.ProcessMainWAVE();
                lbl1a.Text = dh.NumChannels;
                lbl2a.Text = dh.BitsPerSample;
                lbl3a.Text = dh.BitsPerSec;
                lbl4a.Text = dh.SamplesPerSec;

                pnlAVI.Visible = true;
            }
            else if (RiffParser.ckidRMID == rp.FileType)
            {
            }

            rp.CloseFile();
        }
Example #5
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            String riffFile = String.Empty;
            String name     = (String)e.Argument;
            bool   m14      = false;

            if (!File.Exists(name))
            {
                return;
            }
            FileStream   fs = File.OpenRead(name);
            BinaryReader br = new BinaryReader(fs);

            byte[] hd = new byte[2];
            br.Read(hd, 0, 2);
            if (Encoding.UTF8.GetString(hd) == "RI")
            {
                riffFile = name;
            }
            else if (Encoding.UTF8.GetString(hd) == "PK")
            {
                m14 = true;
                ZipInputStream zis = new ZipInputStream(File.OpenRead(name));
                ZipEntry       theEntry;
                bool           d = false;
                while ((theEntry = zis.GetNextEntry()) != null)
                {
                    String fileName;
                    if (theEntry.Name == "content/riffData.cdr" || theEntry.Name == "content/root.dat")
                    {
                        fileName = Path.GetFileName(theEntry.Name);
                        String tmp = Path.GetTempPath();
                        riffFile = tmp + fileName;
                        FileStream   fs1  = File.Open(tmp + fileName, FileMode.OpenOrCreate);
                        BinaryWriter bw   = new BinaryWriter(fs1);
                        int          size = 2048;
                        byte[]       data = new byte[2048];
                        while (true)
                        {
                            size = zis.Read(data, 0, data.Length);
                            if (size > 0)
                            {
                                bw.Write(data, 0, size);
                            }
                            else
                            {
                                break;
                            }
                        }
                        bw.Close();
                        fs1.Close();
                        zis.Close();
                        d = true;
                        break;
                    }
                }
                if (!d)
                {
                    MessageBox.Show("文件格式错误!");
                    return;
                }
            }
            else
            {
                MessageBox.Show("文件格式错误!");
                return;
            }
            br.Close();
            fs.Close();
            if (m14)
            {
            }
            RiffParser rp = new RiffParser();

            rp.OpenFile(riffFile);
            CDRReader cr = new CDRReader(rp);

            cr.Read();

            /*CDRWriter cw = new CDRWriter();
             * CDRFile cf = cr.CDRFile;
             * cf.list = RiffConn.DelRiff<CDRbmkt>(cf.list);
             * //cf.list = RiffConn.DelRiff<CDRcolo>(cf.list);
             * cf.list = RiffConn.DelRiff<CDRsyst>(cf.list);
             * cw.SetCDRFile(cf);
             * cw.Write(name + "_1");*/
            listBox1.Items.Clear();
            listBox1.Items.Add("文件名:");
            listBox1.Items.Add("    " + Path.GetFileName(name));
            listBox1.Items.Add("文件版本:");
            listBox1.Items.Add(String.Format("    CorelDraw {0:d}", cr.CDRFile.Version));
            listBox1.Items.Add("保存版本:");
            listBox1.Items.Add(String.Format("    CorelDraw {0:d} 子版本:{1:d}", cr.CDRFile.SVersion, cr.CDRFile.BuildID));
            listBox1.Items.Add("位图数量:");
            listBox1.Items.Add(String.Format("    {0:d}", cr.CDRFile.BMPCount));
            listBox1.Items.Add("视图样式数量:");
            listBox1.Items.Add(String.Format("    {0:d}", cr.CDRFile.ViewCount));
            listBox1.Items.Add(String.Format("使用字体:数量:{0:d}", cr.CDRFile.fonts.Count));
            foreach (CDRFile.Fonts f in cr.CDRFile.fonts)
            {
                listBox1.Items.Add(String.Format("    {0:1}", f.name));
            }
            rp.CloseFile();
        }