Thông báo

Collapse
No announcement yet.

nhờ dịch code C# sang C++

Collapse
X
 
  • Lọc
  • Giờ
  • Show
Clear All
new posts

  • nhờ dịch code C# sang C++

    using System;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Windows.Forms;
    using System.Data;
    using System.Collections;
    using System.ComponentModel;
    using System.Runtime.InteropServices;
    using System.IO;
    using System.Threading;
    using DexterLib;


    namespace ImageExtractor
    {
    public partial class ExportFrame : Form
    {
    public ExportFrame()
    {
    InitializeComponent();
    }
    string fileName; //used to save the movie file name
    string storagePath = Application.StartupPath + "\\tmp\\"; //used for the path where we save files
    MediaDetClass md; //needed to extract pictures
    static int counter = 0; //to generate different file names
    float interval = 1.0f; //default time interval
    int maxFrame = 0;
    string temp = "";
    int kk = 0;

    private void button2_Click(object sender, EventArgs e)
    {
    OpenFileDialog dlg = new OpenFileDialog();
    kk = 0;
    if (dlg.ShowDialog() == DialogResult.OK)
    {
    try
    {
    fileName = dlg.FileName;
    this.Text = Path.GetFileName(dlg.FileName);

    //create the MediaDetClass and set its properties
    md = new MediaDetClass();
    md.Filename = fileName;
    md.CurrentStream = 0;
    int len = (int)md.StreamLength;
    maxFrame = len * 24;
    //fix a few Gui stuff
    label1.Text = "Frame: " + maxFrame.ToString();
    //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, 320, 240, fBitmapName);
    pictureBox1.Image = new Bitmap(fBitmapName);
    temp = fBitmapName;
    kk++;
    }
    catch (Exception) { MessageBox.Show("Coulnd't open movie file"); }
    }
    }
    class ScanThread
    {
    MediaDetClass md;
    string fileName;
    string storagePath;
    float interval;
    public Thread t;
    public ScanThread(string s, string f, float ival)
    {
    storagePath = s;
    fileName = f;
    interval = ival;
    t = new Thread(new ThreadStart(this.Scan));
    t.Start();
    }
    void Scan()
    {
    md = new MediaDetClass();
    md.Filename = fileName;
    md.CurrentStream = 0;
    int len = (int)md.StreamLength * 24;
    int j = -1;
    float k = 0.0f;
    float l = 0.1f;
    for (int i = 0; i < len; i++)
    {
    j++;
    counter++;
    string fBitmapName = storagePath + Path.GetFileNameWithoutExtension(fileName)
    + "_" + j.ToString();
    md.WriteBitmapBits(k, 320, 240, fBitmapName + ".bmp");
    k = k + l;
    }
    }
    }
    private void button1_Click(object sender, EventArgs e)
    {

    if (md == null) return;
    if (kk == 0) return;
    ScanThread st = new ScanThread(storagePath, fileName, interval);
    do
    {
    Thread.Sleep(100);
    } while (st.t.IsAlive);
    label1.Text = "Export: DONE";

    }

    private void ExportFrame_FormClosing(object sender, FormClosingEventArgs e)
    {

    }
    }
    }

Về tác giả

Collapse

minh255 Tìm hiểu thêm về minh255

Bài viết mới nhất

Collapse

Đang tải...
X