-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathBitmapFileHeader.cs
More file actions
29 lines (24 loc) · 863 Bytes
/
BitmapFileHeader.cs
File metadata and controls
29 lines (24 loc) · 863 Bytes
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
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SL3Reader;
[StructLayout(LayoutKind.Sequential, Size = Size, Pack = 2), // Pack is important!
SkipLocalsInit]
internal struct BitmapFileHeader
{
internal const int Size = 14;
private ushort Type;
private uint FileSize;
private ushort Reserved1;
private ushort Reserved2;
private uint OffsetOfImageData;
internal BitmapFileHeader(int width, int height) =>
Update(width, height);
internal uint Update(int width, int height)
{
Type = 19778; // This is "BM" in ASCII.
FileSize = (uint)(BitmapHelper.BitmapCombinedHeaderSize + height * width); // (width + (4 - width % 4))
Reserved1 = 0; Reserved2 = 0;
OffsetOfImageData = BitmapHelper.BitmapCombinedHeaderSize;
return FileSize;
}
}