summaryrefslogtreecommitdiff
path: root/Util.cs
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-05-15 20:46:43 +0000
committerIan C <ianc@noddybox.co.uk>2005-05-15 20:46:43 +0000
commit779300236a4bc3cda33fbdf91411b7a40c17b16d (patch)
tree09585cbc302dbaba2ebc951c84e629400bf07b7d /Util.cs
parent0f11f8e2d536e06b1b1175388752ede4db716117 (diff)
Implemented load/save and tidied some editor control bugs
Diffstat (limited to 'Util.cs')
-rw-r--r--Util.cs61
1 files changed, 61 insertions, 0 deletions
diff --git a/Util.cs b/Util.cs
index ea67003..f7b3bab 100644
--- a/Util.cs
+++ b/Util.cs
@@ -20,6 +20,7 @@
using System;
using System.Windows.Forms;
using System.Text;
+using System.IO;
namespace BitmapFontEd
{
@@ -56,6 +57,66 @@ namespace BitmapFontEd
MessageBoxButtons.OK,MessageBoxIcon.Information);
}
+
+ public static uint ReadUint(Stream str)
+ {
+ uint l=0;
+
+ for(int f=0;f<4;f++)
+ {
+ int b=str.ReadByte();
+ l|=(uint)(b<<(f*8));
+ }
+
+ return l;
+ }
+
+ public static int ReadInt(Stream str)
+ {
+ int l=0;
+
+ for(int f=0;f<4;f++)
+ {
+ int b=str.ReadByte();
+ l|=b<<(f*8);
+ }
+
+ return l;
+ }
+
+ public static void WriteUint(Stream str, uint l)
+ {
+ for(uint f=0;f<4;f++)
+ {
+ str.WriteByte((byte)(l&0xff));
+ l=l>>8;
+ }
+ }
+
+ public static void WriteInt(Stream str, int l)
+ {
+ for(uint f=0;f<4;f++)
+ {
+ str.WriteByte((byte)(l&0xff));
+ l=l>>8;
+ }
+ }
+
+ public static void WriteString(Stream str, string s)
+ {
+ byte[] b=Encoding.ASCII.GetBytes(s);
+
+ str.Write(b,0,b.Length);
+ }
+
+ public static string ReadString(Stream str, int len)
+ {
+ byte[] b=new byte[len];
+
+ str.Read(b,0,len);
+ return Encoding.ASCII.GetString(b);
+ }
+
private Util()
{
}