-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexmap.cs
More file actions
51 lines (45 loc) · 1.45 KB
/
Indexmap.cs
File metadata and controls
51 lines (45 loc) · 1.45 KB
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
namespace BmArrayLoader
{
public class Indexmap
{
private readonly int m_offsetX;
private readonly int m_offsetY;
private readonly int m_width;
private readonly int m_height;
private readonly byte[] m_data;
public Indexmap(int width, int height) : this(0, 0, width, height) { }
public Indexmap(int offsetX, int offsetY, int width, int height)
{
m_offsetX = offsetX;
m_offsetY = offsetY;
m_width = width;
m_height = height;
m_data = new byte[width * height];
}
public byte this[int i]
{
get => (i >= 0 && i < m_data.Length) ? m_data[i] : (byte)0;
set
{
if (i >= 0 && i < m_data.Length)
m_data[i] = value;
}
}
public byte this[int x, int y]
{
get => this[y * m_width + x];
set => this[y * m_width + x] = value;
}
public int Width { get => m_width; }
public int Height { get => m_height; }
public int Size { get => m_data.Length; }
public bool Equals(int offsetX, int offsetY, int width, int height)
{
if (offsetX == m_offsetX && offsetY == m_offsetY &&
width == m_width && height == m_height)
return true;
else
return false;
}
}
}