diff options
author | Ian C <ianc@noddybox.co.uk> | 2005-08-01 23:46:42 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2005-08-01 23:46:42 +0000 |
commit | 2db332c8ad3dff265ab209a1ff727f30be4dbd20 (patch) | |
tree | dda1a6f8ea2346aeff08b77fe6b7d269d9687a94 /Sprite.cs | |
parent | 93ac9c657ce285c5daa5a3ea6ed8c91b50e0281c (diff) |
Initial working version
Diffstat (limited to 'Sprite.cs')
-rw-r--r-- | Sprite.cs | 33 |
1 files changed, 29 insertions, 4 deletions
@@ -19,6 +19,7 @@ //
using System;
using System.Drawing;
+using System.Drawing.Imaging;
using System.IO;
using System.Collections;
@@ -45,6 +46,11 @@ namespace BitmapSpriteEd public Frame(Frame old)
{
+ CopyFrom(old);
+ }
+
+ public void CopyFrom(Frame old)
+ {
m_width=old.m_width;
m_height=old.m_height;
m_data=new Color[m_width,m_height];
@@ -59,7 +65,7 @@ namespace BitmapSpriteEd m_changed=old.m_changed;
}
-
+
public int Width
{
get {return m_width;}
@@ -256,6 +262,24 @@ namespace BitmapSpriteEd return s;
}
+ public Bitmap Bitmap
+ {
+ get
+ {
+ Bitmap bmp=new Bitmap(m_width,m_height,PixelFormat.Format32bppArgb);
+
+ for(int x=0;x<m_width;x++)
+ {
+ for(int y=0;y<m_height;y++)
+ {
+ bmp.SetPixel(x,y,m_data[x,y]);
+ }
+ }
+
+ return bmp;
+ }
+ }
+
// ------------------------------------------------
// PRIVATE
//
@@ -294,7 +318,7 @@ namespace BitmapSpriteEd public Sprite()
{
m_changed=false;
- m_name="Untitled";
+ m_name="";
m_frames=new ArrayList();
m_frames.Add(new Frame(16,16));
}
@@ -382,6 +406,7 @@ namespace BitmapSpriteEd {
Sprite fr=new Sprite();
+ fr.m_frames.Clear();
fr.Name=Util.ReadString(stream);
int num=Util.ReadInt(stream);
@@ -483,10 +508,10 @@ namespace BitmapSpriteEd {
if (this[i].Name.Length==0)
{
- throw new ApplicationException("Empty sprite name found");
+ throw new ApplicationException("Empty sprite name found (sprite number " + (i+1).ToString() + ")");
}
- for(int j=0;j<num;i++)
+ for(int j=0;j<num;j++)
{
if (i!=j)
{
|