NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

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 WindowsFormsApplication4
{
public partial class Form1 : Form
{
string fileName; //used to save the movie file name
string storagePath; //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

public Form1()
{
InitializeComponent();

//initialize a few properties
trackBar1.Minimum = trackBar1.Maximum = 0;
this.MaximizeBox = false;

storagePath = Application.StartupPath + "\resimler\";

//if the storage directory doesn't exist we create it
if (!Directory.Exists(storagePath))
Directory.CreateDirectory(storagePath);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
try
{
//try to get rid of all the tmp files created during the session
if (pictureBox1.Image != null)
pictureBox1.Image.Dispose();
string[] bmpFiles = Directory.GetFiles(storagePath, "*.bmp");
for (int i = 0; i < bmpFiles.Length; i++)
System.IO.File.Delete(bmpFiles[i]);
}
catch (Exception) { MessageBox.Show("Couldn't delete all temporary files"); }
base.Dispose(disposing);
}
private void pictureBox1_Click(object sender, EventArgs e)
{

}

private void button5_Click(object sender, 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 MediaDetClass();
md.Filename = fileName;
md.CurrentStream = 0;
int len = (int)md.StreamLength;

//fix a few Gui stuff
label1.Text = "Frame: " + 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

}
catch (Exception) { MessageBox.Show("Coulnd't open movie file"); }
}
}

private void button2_Click(object sender, EventArgs e)
{
if (md == null) return;

ScanThread st = new ScanThread(storagePath, fileName, interval);
do
{
//waits until the processing is done, displaying the
//number of the file we are currently saving
Thread.Sleep(1000);
label1.Text = "Kaydediliyor: " + counter.ToString();
label1.Invalidate();
label1.Update();
} while (st.t.IsAlive);
label1.Text = "Tamamlandı";
}
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();
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, 320, 240, fBitmapName + ".bmp");
img = Image.FromFile(fBitmapName + ".bmp");
img.Save(fBitmapName + ".jpg", ImageFormat.Jpeg);
img.Dispose();
System.IO.File.Delete(fBitmapName + ".bmp");
}
}
}

private void button1_Click(object sender, EventArgs e)
{


string fBitmapName = storagePath + Path.GetFileNameWithoutExtension(fileName)
+ "_" + counter.ToString();
md.WriteBitmapBits(trackBar1.Value, 320, 240, fBitmapName + ".bmp");

//save the picture as jpeg
Image img = Image.FromFile(fBitmapName + ".bmp");
img.Save(fBitmapName + ".jpg", ImageFormat.Jpeg);
img.Dispose();
counter++;
}

private void button3_Click(object sender, EventArgs e)
{
if (trackBar1.Value >= trackBar1.Minimum + 1)
trackBar1.Value = trackBar1.Value - 1;
}

private void button4_Click(object sender, EventArgs e)
{
if (trackBar1.Value <= trackBar1.Maximum - 1)
trackBar1.Value = trackBar1.Value + 1;
}
private void trackBar1_ValueChanged(object sender, System.EventArgs e)
{
if (md == null) return;
pictureBox1.Image.Dispose();
label1.Text = "Cur Pos: " + trackBar1.Value.ToString();
string fBitmapName = storagePath + "tmp" + counter.ToString() + ".bmp";
counter++;
md.WriteBitmapBits(trackBar1.Value, 320, 240, fBitmapName);
pictureBox1.Image = new Bitmap(fBitmapName);

}

}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.