I am trying to have folder of images either converted to a video format I can play and edit frames of or just iterate through the folder and display them. I am using VS, C#, WPF and .NET 4.7.2.
The folder also has a .txt document named "files.txt" that has all of the files in the folder line by line.
Example (Separated by lines, not spaces)-
" frame_000000.jpg frame_000001.jpg frame_000002.jpg frame_000003.jpg frame_000004.jpg frame_000005.jpg ... "
When I drop the folder into the application it begins running.
Here is what I have so far.
using System;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Media.Imaging;
namespace WpfApp2
{
public partial class MainWindow : Window
{
public static string filename { get; set; }
public static string imageName { get; set; }
public MainWindow()
{
InitializeComponent();
}
public void UpdateImage()
{
ImportImage.Source = new BitmapImage(new Uri(imageName));
}
public void FileDropStackPanel_Drop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
filename = Path.GetFullPath(files[0]);
GetFileName();
}
}
public void GetFileName()
{
listFilesInDirectory(filename);
void listFilesInDirectory(string workingDirectory)
{
string[] filePaths = Directory.GetFiles(workingDirectory);
if (filePaths.Contains(filename + @"\files.txt"))
{
string textFile = filename + @"\files.txt";
string[] lines = File.ReadAllLines(textFile);
for (int x = 0; x < lines.Length; x++)
{
imageName = filename + @"\" + lines[x];
UpdateImage();
}
}
}
}
}
}
First of all I had to convert all the JPG files to PNG outside of the code. Second it only shows the last image in the folder.
I can't figure out how to get the JPG into a video format or display them at 25 FPS. Any help would be greatly appreciated!