summaryrefslogtreecommitdiff
path: root/BitmapChar.cs
diff options
context:
space:
mode:
Diffstat (limited to 'BitmapChar.cs')
-rw-r--r--BitmapChar.cs77
1 files changed, 46 insertions, 31 deletions
diff --git a/BitmapChar.cs b/BitmapChar.cs
index 4719b33..3033fee 100644
--- a/BitmapChar.cs
+++ b/BitmapChar.cs
@@ -29,12 +29,13 @@ namespace BitmapFontEd
/// </summary>
public class BitmapChar
{
- public BitmapChar(uint width, uint height)
+ public BitmapChar(int width, int height)
{
+ CheckSize(width,height);
m_width=width;
m_height=height;
m_data=new Color[m_width,m_height];
- Clear(Color.Empty);
+ Clear(Color.Transparent);
m_changed=false;
}
@@ -55,12 +56,12 @@ namespace BitmapFontEd
m_changed=old.m_changed;
}
- public uint Width
+ public int Width
{
get {return m_width;}
}
- public uint Height
+ public int Height
{
get {return m_height;}
}
@@ -70,8 +71,10 @@ namespace BitmapFontEd
get {return m_changed;}
}
- public void Resize(uint width, uint height)
+ public void Resize(int width, int height)
{
+ CheckSize(width,height);
+
if (width==m_width && height==m_height)
{
return;
@@ -81,10 +84,10 @@ namespace BitmapFontEd
for(int y=0;y<height;y++)
for(int x=0;x<width;x++)
- data[x,y]=Color.Empty;
+ data[x,y]=Color.Transparent;
- uint mx=Math.Min(width,m_width);
- uint my=Math.Min(height,m_height);
+ int mx=Math.Min(width,m_width);
+ int my=Math.Min(height,m_height);
for(int x=0;x<mx;x++)
for(int y=0;y<my;y++)
@@ -96,7 +99,7 @@ namespace BitmapFontEd
m_changed=true;
}
- public Color this [uint x, uint y]
+ public Color this [int x, int y]
{
set
{
@@ -154,7 +157,7 @@ namespace BitmapFontEd
public void RotateRight()
{
Color[,] d=new Color[m_width,m_height];
- uint min=Math.Min(m_width,m_height);
+ int min=Math.Min(m_width,m_height);
for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
@@ -175,7 +178,7 @@ namespace BitmapFontEd
public void RotateLeft()
{
Color[,] d=new Color[m_width,m_height];
- uint min=Math.Min(m_width,m_height);
+ int min=Math.Min(m_width,m_height);
for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
@@ -201,7 +204,7 @@ namespace BitmapFontEd
//
for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
- d[x,y]=Color.Empty;
+ d[x,y]=Color.Transparent;
for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
@@ -217,6 +220,8 @@ namespace BitmapFontEd
}
}
+ Util.DumpAlpha("Shadow Overlay",d);
+
for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
if (d[x,y].A!=0)
@@ -227,7 +232,7 @@ namespace BitmapFontEd
m_changed=true;
}
- public void Glow(Color col)
+ public void Edge(Color col)
{
Color[,] d=new Color[m_width,m_height];
@@ -235,7 +240,7 @@ namespace BitmapFontEd
//
for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
- d[x,y]=Color.Empty;
+ d[x,y]=Color.Transparent;
for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
@@ -255,6 +260,8 @@ namespace BitmapFontEd
}
}
+ Util.DumpAlpha("Edge Overlay",d);
+
for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
if (d[x,y].A!=0)
@@ -267,12 +274,12 @@ namespace BitmapFontEd
public void Output(Stream stream)
{
- Util.WriteUint(stream,m_width);
- Util.WriteUint(stream,m_height);
+ Util.WriteInt(stream,m_width);
+ Util.WriteInt(stream,m_height);
- for(uint x=0;x<m_width;x++)
+ for(int x=0;x<m_width;x++)
{
- for(uint y=0;y<m_height;y++)
+ for(int y=0;y<m_height;y++)
{
stream.WriteByte(m_data[x,y].B);
stream.WriteByte(m_data[x,y].G);
@@ -284,14 +291,14 @@ namespace BitmapFontEd
public static BitmapChar Input(Stream stream)
{
- uint width=Util.ReadUint(stream);
- uint height=Util.ReadUint(stream);
+ int width=Util.ReadInt(stream);
+ int height=Util.ReadInt(stream);
BitmapChar s=new BitmapChar(width,height);
- for(uint x=0;x<width;x++)
+ for(int x=0;x<width;x++)
{
- for(uint y=0;y<height;y++)
+ for(int y=0;y<height;y++)
{
int B=stream.ReadByte();
int G=stream.ReadByte();
@@ -310,19 +317,27 @@ namespace BitmapFontEd
// ------------------------------------------------
// PRIVATE
//
- private uint m_width;
- private uint m_height;
+ private int m_width;
+ private int m_height;
private Color[,] m_data;
private bool m_changed;
- private int Mod(int v, uint max)
+ private void CheckSize(int width, int height)
{
- while(v<0)
- v+=(int)max;
-
- v=v%(int)max;
+ if (width<0 || height<0)
+ {
+ throw new ArgumentException("Cannot use negative sizes");
+ }
+ }
+
+ private int Mod(int v, int m)
+ {
+ while (v<0)
+ {
+ v+=m;
+ }
- return v;
+ return v%m;
}
}
@@ -365,7 +380,7 @@ namespace BitmapFontEd
{
get
{
- uint w=m_list[0].Width;
+ int w=m_list[0].Width;
foreach (BitmapChar c in m_list)
{