summaryrefslogtreecommitdiff
path: root/BitmapChar.cs
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-05-15 01:04:53 +0000
committerIan C <ianc@noddybox.co.uk>2005-05-15 01:04:53 +0000
commit0f11f8e2d536e06b1b1175388752ede4db716117 (patch)
tree90e34d983d3e3371dc749550a7d65218184878da /BitmapChar.cs
parent5fb32592ed08ca0f45e3bf1dce77c637441f716e (diff)
Initial working editor and character selection
Diffstat (limited to 'BitmapChar.cs')
-rw-r--r--BitmapChar.cs108
1 files changed, 106 insertions, 2 deletions
diff --git a/BitmapChar.cs b/BitmapChar.cs
index 910a4b2..f902d7c 100644
--- a/BitmapChar.cs
+++ b/BitmapChar.cs
@@ -20,6 +20,7 @@
using System;
using System.Drawing;
using System.IO;
+using System.Collections;
namespace BitmapFontEd
{
@@ -33,9 +34,11 @@ namespace BitmapFontEd
m_width=width;
m_height=height;
m_data=new Color[m_width,m_height];
+ Clear(Color.Black);
+ m_changed=false;
}
- public BitmapChar() : this(8,8)
+ public BitmapChar() : this(16,16)
{
}
@@ -48,6 +51,8 @@ namespace BitmapFontEd
for(int x=0;x<m_width;x++)
for(int y=0;y<m_height;y++)
m_data[x,y]=old.m_data[x,y];
+
+ m_changed=old.m_changed;
}
public uint Width
@@ -60,9 +65,24 @@ namespace BitmapFontEd
get {return m_height;}
}
+ public bool Changed
+ {
+ get {return m_changed;}
+ }
+
public void Resize(uint width, uint height)
{
+ if (width==m_width && height==m_height)
+ {
+ return;
+ }
+
Color[,] data=new Color[width,height];
+
+ for(int y=0;y<height;y++)
+ for(int x=0;x<width;x++)
+ data[x,y]=Color.Black;
+
uint mx=Math.Min(width,m_width);
uint my=Math.Min(height,m_height);
@@ -73,11 +93,16 @@ namespace BitmapFontEd
m_width=width;
m_height=height;
m_data=data;
+ m_changed=true;
}
public Color this [uint x, uint y]
{
- set {m_data[x,y]=value;}
+ set
+ {
+ m_data[x,y]=value;
+ m_changed=true;
+ }
get {return m_data[x,y];}
}
@@ -86,6 +111,8 @@ namespace BitmapFontEd
for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
m_data[x,y]=c;
+
+ m_changed=true;
}
public void MirrorHorizontal()
@@ -97,6 +124,7 @@ namespace BitmapFontEd
d[x,y]=m_data[m_width-x-1,y];
m_data=d;
+ m_changed=true;
}
public void MirrorVertical()
@@ -108,6 +136,7 @@ namespace BitmapFontEd
d[x,y]=m_data[x,m_height-y-1];
m_data=d;
+ m_changed=true;
}
public void Scroll(int dx, int dy)
@@ -119,6 +148,7 @@ namespace BitmapFontEd
d[Mod(x+dx,m_width),Mod(y+dy,m_height)]=m_data[x,y];
m_data=d;
+ m_changed=true;
}
public void RotateRight()
@@ -139,6 +169,7 @@ namespace BitmapFontEd
}
m_data=d;
+ m_changed=true;
}
public void RotateLeft()
@@ -159,6 +190,7 @@ namespace BitmapFontEd
}
m_data=d;
+ m_changed=true;
}
public void Output(Stream stream)
@@ -190,6 +222,8 @@ namespace BitmapFontEd
}
}
+ s.m_changed=false;
+
return s;
}
@@ -199,6 +233,7 @@ namespace BitmapFontEd
private uint m_width;
private uint m_height;
private Color[,] m_data;
+ private bool m_changed;
private int Mod(int v, uint max)
{
@@ -254,4 +289,73 @@ namespace BitmapFontEd
}
}
}
+
+ /// <summary>
+ /// Describes a list of bitmap characters
+ /// </summary>
+ public class BitmapCharList : IEnumerable
+ {
+ private const int CHARS=96;
+
+ public BitmapCharList()
+ {
+ m_list=new BitmapChar[CHARS];
+
+ for(int f=0;f<CHARS;f++)
+ {
+ m_list[f]=new BitmapChar();
+ }
+
+ m_changed=false;
+ }
+
+ public BitmapChar this [int i]
+ {
+ get {return m_list[i];}
+ set
+ {
+ m_list[i]=value;
+ m_changed=true;
+ }
+ }
+
+ public bool Changed
+ {
+ get {return m_changed;}
+ set {m_changed=value;}
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return m_list.GetEnumerator();
+ }
+
+ public void Output(Stream stream)
+ {
+ foreach (BitmapChar c in m_list)
+ {
+ c.Output(stream);
+ }
+ }
+
+ public static BitmapCharList Input(Stream stream)
+ {
+ BitmapCharList l=new BitmapCharList();
+
+ for(int f=0;f<CHARS;f++)
+ {
+ l.m_list[f]=BitmapChar.Input(stream);
+ }
+
+ l.Changed=false;
+
+ return l;
+ }
+
+ // ------------------------------------------------
+ // PRIVATE
+ //
+ private BitmapChar[] m_list;
+ private bool m_changed;
+ }
}