EDN Admin
Well-known member
I nned that when i move the trackBar1 once one time to the right it will read from the file ihave binary file the first 256 values calculate the histogram of this 256 values show the frame it did the histogram calculation on and also show the histogram graph
of the current frame.
And if i move the trackBar1 once to the left back it will show the first 256 if i move it to the right it will show each time the NEXT 256 values untill the trackBar1 get to the end.
So i did this:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; void trackBar1_Scroll(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Green; // reading histogram values\
<span style="color:Blue; if (File.Exists(fileName))
{
BinaryReader binReader =
<span style="color:Blue; new BinaryReader(File.Open(fileName, FileMode.Open));
<span style="color:Blue; try
{
<span style="color:Blue; byte[] testArray = <span style="color:Blue; new <span style="color:Blue; byte[3];
<span style="color:Blue; int pos = 0;
<span style="color:Blue; int length = (<span style="color:Blue; int)binReader.BaseStream.Length;
<span style="color:Blue; while (pos < length)
{
binReader.BaseStream.Seek(0, SeekOrigin.Begin);
<span style="color:Blue; while (pos < length)
{
emptyNumbers.Add((<span style="color:Blue; long)binReader.ReadInt64());
pos += <span style="color:Blue; sizeof(Int64);
}
}
}
<span style="color:Blue; catch
{
}
<span style="color:Blue; finally
{
binReader.Close();
}
}
histogramFilesInfo = <span style="color:Blue; new DirectoryInfo(subDirectoryName).GetFiles(<span style="color:#A31515; "*.bmp");
Bitmap myBitmap = <span style="color:Blue; new Bitmap(subDirectoryName + "\" + histogramFilesInfo[myTrackPanelss1.trackBar1.Value].Name);
<span style="color:Blue; long[] myValues = GetHistogram(myBitmap);
histogramControl1.DrawHistogram(myValues);
myBitmap.Dispose();
setpicture(myTrackPanelss1.trackBar1.Value);
}
[/code]
First the bottom part in the scroll event was already and its working good i move the trackBar1 once and its showing me the frame in the pictureBox this is made with the sepicture(...) and it also calculate the histogram of the current frame and also draw
the graph of the histogram with this lines:
long[] myValues = GetHistogram(myBitmap);<br/>
histogramControl1.DrawHistogram(myValues);
Now above it i added the reading from the binary file i already have on the hard disk.
Now what i want to do is to read from the binary file each time i move the trackBar1 once to the right the next 256 values calculate the histogram from them draw the histogram graph and show the current frame using the setpicture.
I also want to do it all in the memory but im not sure if i need to read first all the binary file to a List<> and then use the trackBar1 scroll event and to read each 256 values from the List<> or to do it as im trying now ?
Thanks.
View the full article
of the current frame.
And if i move the trackBar1 once to the left back it will show the first 256 if i move it to the right it will show each time the NEXT 256 values untill the trackBar1 get to the end.
So i did this:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; void trackBar1_Scroll(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Green; // reading histogram values\
<span style="color:Blue; if (File.Exists(fileName))
{
BinaryReader binReader =
<span style="color:Blue; new BinaryReader(File.Open(fileName, FileMode.Open));
<span style="color:Blue; try
{
<span style="color:Blue; byte[] testArray = <span style="color:Blue; new <span style="color:Blue; byte[3];
<span style="color:Blue; int pos = 0;
<span style="color:Blue; int length = (<span style="color:Blue; int)binReader.BaseStream.Length;
<span style="color:Blue; while (pos < length)
{
binReader.BaseStream.Seek(0, SeekOrigin.Begin);
<span style="color:Blue; while (pos < length)
{
emptyNumbers.Add((<span style="color:Blue; long)binReader.ReadInt64());
pos += <span style="color:Blue; sizeof(Int64);
}
}
}
<span style="color:Blue; catch
{
}
<span style="color:Blue; finally
{
binReader.Close();
}
}
histogramFilesInfo = <span style="color:Blue; new DirectoryInfo(subDirectoryName).GetFiles(<span style="color:#A31515; "*.bmp");
Bitmap myBitmap = <span style="color:Blue; new Bitmap(subDirectoryName + "\" + histogramFilesInfo[myTrackPanelss1.trackBar1.Value].Name);
<span style="color:Blue; long[] myValues = GetHistogram(myBitmap);
histogramControl1.DrawHistogram(myValues);
myBitmap.Dispose();
setpicture(myTrackPanelss1.trackBar1.Value);
}
[/code]
First the bottom part in the scroll event was already and its working good i move the trackBar1 once and its showing me the frame in the pictureBox this is made with the sepicture(...) and it also calculate the histogram of the current frame and also draw
the graph of the histogram with this lines:
long[] myValues = GetHistogram(myBitmap);<br/>
histogramControl1.DrawHistogram(myValues);
Now above it i added the reading from the binary file i already have on the hard disk.
Now what i want to do is to read from the binary file each time i move the trackBar1 once to the right the next 256 values calculate the histogram from them draw the histogram graph and show the current frame using the setpicture.
I also want to do it all in the memory but im not sure if i need to read first all the binary file to a List<> and then use the trackBar1 scroll event and to read each 256 values from the List<> or to do it as im trying now ?
Thanks.
View the full article