private void miOpenFile_Click(object sender, System.EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); if (dlg.ShowDialog() == DialogResult.OK) { try { fileName = dlg.FileName; this.Text = Path.GetFileName(dlg.FileName); //create the MediaDetClass and set its properties md = new DexterLib.MediaDet(); md.Filename = fileName; md.CurrentStream = 0; int len = (int)md.StreamLength; //fix a few Gui stuff label1.Text = "Length: " + len.ToString(); trackBar1.Minimum = 0; trackBar1.Maximum = len; trackBar1.Value = 0; //make sure we have a unique name then call WriteBitmapBits to //a file then use it to fill the picture box counter++; string fBitmapName = storagePath + counter.ToString() + ".bmp"; md.WriteBitmapBits(0, 1366, 768, fBitmapName); pictureBox1.Image = new Bitmap(fBitmapName); } catch (Exception) { MessageBox.Show("Coulnd't open movie file"); } } }
void Scan() { md = new DexterLib.MediaDet(); Image img; md.Filename = fileName; md.CurrentStream = 0; int len = (int)md.StreamLength; for (float i = 0.0f; i < len; i = i + interval) { counter++; string fBitmapName = storagePath + Path.GetFileNameWithoutExtension(fileName) + "_" + counter.ToString(); md.WriteBitmapBits(i, 1366, 768, fBitmapName + ".bmp"); img = Image.FromFile(fBitmapName + ".bmp"); img.Save(fBitmapName + ".jpg", ImageFormat.Jpeg); img.Dispose(); System.IO.File.Delete(fBitmapName + ".bmp"); } }