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

  • nguyendinhvan
    Trả lời cho Vấn đề về tốc độ quay
    bởi nguyendinhvan
    Sử dụng động cơ servor, hoặc lắp thêm một cái encoder vào động cơ bước. Encoder sẽ kiểm soát động cơ có quay hoặc đứng im.
    Hôm qua, 19:50
  • Andrea14
    Vấn đề về tốc độ quay
    bởi Andrea14
    Chào mọi người,

    Tôi muốn mô phỏng sự thay đổi các mùa bằng cách từ từ nghiêng một quả địa cầu 16 inch bằng một động cơ bước nhỏ. Một động cơ bước khác sẽ quay quả địa cầu theo thời gian thực. Hệ thống truyền động...
    12-12-2025, 12:42
  • bqviet
    Trả lời cho Đấu tắt điện cho máy tính bảng
    bởi bqviet
    Bqv cáo lỗi vì chưa đủ khả năng diễn giải để người đọc hiểu. Người làm kỹ thuật sâu đôi khi như thế đó. Về việc nạp pin không vào dù cell mới, khả năng cái mạch quản lý đó đã hỏng - cũng chính là nguyên nhân đám cell cũ hỏng từ đầu.
    06-12-2025, 17:17
  • nguyendinhvan
    Trả lời cho Xin hỏi về mạch thu FM/AM trong catsette
    bởi nguyendinhvan
    Theo tôi, nó chỉ là cái Tuy- ê - nơ, hoặc là khối Trung Văn Tần, nó một phần trong cái Da đì ô thôi. Vì có thấy một chỗ có ba chân hàn, giiống như chân Cờ rít sờ tăng 455 ki nô hẹc. Còn khối Tuy ê nơ thì không nhìn thây cái Di ốt Va di cáp...
    05-12-2025, 19:59
Đang tải...
X