forked from hpavlov/tangra3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBMPFileSequenceStream.cs
132 lines (99 loc) · 2.85 KB
/
BMPFileSequenceStream.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using Tangra.Model.Config;
using Tangra.Model.Image;
using Tangra.Model.Video;
namespace Tangra.Video
{
internal class BMPFileSequenceStream : IDisposable, IFrameStream
{
public const string ENGINE = "BMP::SEQ";
private List<string> m_BmpFilesList = new List<string>();
public static BMPFileSequenceStream OpenFolder(string[] fitsFiles)
{
var rv = new BMPFileSequenceStream(fitsFiles);
rv.FileName = Path.GetDirectoryName(fitsFiles[0]);
return rv;
}
private BMPFileSequenceStream(string[] fitsFiles)
{
m_BmpFilesList.AddRange(fitsFiles);
m_BmpFilesList.Sort();
FirstFrame = 0;
LastFrame = m_BmpFilesList.Count - 1;
CountFrames = m_BmpFilesList.Count;
Bitmap bmp = (Bitmap)Bitmap.FromFile(m_BmpFilesList[0]);
Width = bmp.Width;
Height = bmp.Height;
BitPix = 8;
HasUTCTimeStamps = false;
VideoFileType = ENGINE;
}
public int Width { get; private set; }
public int Height { get; private set; }
public int BitPix { get; private set; }
public int FirstFrame { get; private set; }
public int LastFrame { get; private set; }
public int CountFrames { get; private set; }
public double FrameRate
{
get { return double.NaN; }
}
public double MillisecondsPerFrame
{
get { return 0; }
}
public Pixelmap GetPixelmap(int index)
{
Bitmap bmp = (Bitmap)Bitmap.FromFile(m_BmpFilesList[index]);
return Pixelmap.ConstructFromBitmap(bmp, TangraConfig.ColourChannel.Red);
}
public int RecommendedBufferSize
{
get { return Math.Min(8, CountFrames); }
}
public bool SupportsSoftwareIntegration
{
get { return false; }
}
public bool SupportsIntegrationByMedian
{
get { return false; }
}
public string VideoFileType { get; private set; }
public Pixelmap GetIntegratedFrame(int startFrameNo, int framesToIntegrate, bool isSlidingIntegration, bool isMedianAveraging)
{
throw new NotImplementedException();
}
public string Engine
{
get { return ENGINE; }
}
public string FileName { get; private set; }
public uint GetAav16NormVal()
{
return 0;
}
public string GetFrameFileName(int index)
{
if (index >= 0 && index < m_BmpFilesList.Count)
return Path.GetFileName(m_BmpFilesList[index]);
return null;
}
public bool SupportsFrameFileNames
{
get { return true; }
}
public void Dispose()
{
}
public bool HasUTCTimeStamps { get; private set; }
}
}