Example #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            frame++;
            if (frame >= File.Header.NrFrames)
            {
                frame = 0;
            }
            IO.Misc.THP.THPFrame f = File.GetFrame(frame);            //t.Dequeue();
            pictureBox1.Image = f.ToBitmap();

            /*if (audio)
             * {
             *      byte[] a;
             *      f.ToPCM16(out a);
             *      //t.Enqueue(a);
             *      //w.Size = f.ToPCM16(out w.Data);
             *
             *      //unsafe
             *      //{
             *      //WaveLib.WaveNative.waveOutPrepareHeader(WaveOut, ref h, sizeof(WaveLib.WaveNative.WaveHdr));
             *      //WaveLib.WaveNative.waveOutWrite(WaveOut, ref h, sizeof(WaveLib.WaveNative.WaveHdr));
             *      //}
             *      //byte[] s = f.ToPCM16();
             *      bb.AddSamples(a, 0, a.Length);
             * }*/
        }
Example #2
0
        /*internal void BufferFiller(IntPtr data, int size)
         * {
         *      if (t.Count != 0)
         *      {
         *              byte[] b = t.Dequeue();
         *              //size = b.Length;
         *              System.Runtime.InteropServices.Marshal.Copy(b, 0, data, b.Length);
         *              //data = t.Dequeue();
         *              //size = t2.Dequeue();
         *      }
         * }*/
        //WaveLib.WaveNative.WaveHdr h = new WaveLib.WaveNative.WaveHdr();
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == 0x113)
            {
                frame++;
                if (frame >= File.Header.NrFrames)
                {
                    frame = 0;
                }
                IO.Misc.THP.THPFrame f = File.GetFrame(frame);                //t.Dequeue();

                if (audio)
                {
                    byte[] a;
                    f.ToPCM16(out a);
                    //t.Enqueue(a);
                    //w.Size = f.ToPCM16(out w.Data);

                    //unsafe
                    //{
                    //WaveLib.WaveNative.waveOutPrepareHeader(WaveOut, ref h, sizeof(WaveLib.WaveNative.WaveHdr));
                    //WaveLib.WaveNative.waveOutWrite(WaveOut, ref h, sizeof(WaveLib.WaveNative.WaveHdr));
                    //}
                    //byte[] s = f.ToPCM16();
                    bb.AddSamples(a, 0, a.Length);
                }
                pictureBox1.Image = f.ToBitmap();
                //backgroundWorker1.RunWorkerAsync();
            }
            base.WndProc(ref m);
        }
Example #3
0
 private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
 {
     //System.Diagnostics.Stopwatch w = new System.Diagnostics.Stopwatch();
     while (!e.Cancel)
     {
         //w.Reset();
         //w.Start();
         System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch();
         s.Start();
         frame++;
         if (frame >= File.Header.NrFrames)
         {
             frame = 0;
         }
         IO.Misc.THP.THPFrame f = File.GetFrame(frame);
         pictureBox1.Image = f.ToBitmap();
         s.Stop();
         if ((int)(1000f / File.Header.FPS - (1000f / File.Header.FPS / 20f)) - s.ElapsedMilliseconds > 0)
         {
             System.Threading.Thread.Sleep((int)(1000f / File.Header.FPS - (1000f / File.Header.FPS / 20f)) - (int)s.ElapsedMilliseconds);
         }
     }
 }