summaryrefslogtreecommitdiff
path: root/Util.cs
diff options
context:
space:
mode:
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()
{
}