private void button8_Click(object sender, EventArgs e)
{
List<long> averages;
long res = 0;
_fi = new DirectoryInfo(subDirectoryName).GetFiles("*.bmp");
averages = new List<long>(_fi.Length);
for (int i = 0; i < _fi.Length; i++)
{
Bitmap myBitmaps = new Bitmap(_fi[i].Name);
//long[] tt = list_of_histograms[i];
long[] HistogramValues = GetHistogram(myBitmaps);
res = GetTopLumAmount(HistogramValues,1000);
averages.Add(res);
}
}
The exception is on the line:
Bitmap myBitmaps = new Bitmap(_fi[i].Name);
You're only passing the file name to the Bitmap
constructor, but you should actually pass the full path to the file using _fi[i].FullName
@Lester is the right answer (+1), but I did want to say you could shorten your implementation and make it a little more readable by using some functional programming constructs:
var averages = new DirectoryInfo(subDirectoryName)
.GetFiles("*.bmp")
.Select(t => new Bitmap(t.FullName))
.Select(GetHistogram)
.Select(v => GetTopLumAmount(v, 1000))
.ToList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With