summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-08-02 23:20:19 +0000
committerIan C <ianc@noddybox.co.uk>2005-08-02 23:20:19 +0000
commitfb9f2ab945ec9795905eb738e115a05354cd6c58 (patch)
tree12190183a797cbc98feb5249cb1e20c404e811f7
parent2db332c8ad3dff265ab209a1ff727f30be4dbd20 (diff)
Added extra manipulations
-rw-r--r--AlphaColourDialog.cs1
-rw-r--r--BitmapFontEd.DropShadowForm.resourcesbin0 -> 8379 bytes
-rw-r--r--BitmapSpriteEd.prjx2
-rw-r--r--DropShadowForm.cs319
-rw-r--r--GfxEditor.cs47
-rw-r--r--ManipulationMenu.cs10
-rw-r--r--Sprite.cs146
7 files changed, 521 insertions, 4 deletions
diff --git a/AlphaColourDialog.cs b/AlphaColourDialog.cs
index cab8438..1cecf40 100644
--- a/AlphaColourDialog.cs
+++ b/AlphaColourDialog.cs
@@ -76,6 +76,7 @@ namespace BitmapSpriteEd
}
m_allowAlpha=true;
+ Color=Color.White;
}
public Color Color
diff --git a/BitmapFontEd.DropShadowForm.resources b/BitmapFontEd.DropShadowForm.resources
new file mode 100644
index 0000000..5b424ca
--- /dev/null
+++ b/BitmapFontEd.DropShadowForm.resources
Binary files differ
diff --git a/BitmapSpriteEd.prjx b/BitmapSpriteEd.prjx
index 76fc817..2f22c95 100644
--- a/BitmapSpriteEd.prjx
+++ b/BitmapSpriteEd.prjx
@@ -10,6 +10,8 @@
<File name=".\AlphaColourDialog.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\BitmapSpriteEd.GfxEditor.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
<File name=".\ManipulationMenu.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\DropShadowForm.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\BitmapFontEd.DropShadowForm.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
</Contents>
<References />
<DeploymentInformation target="" script="" strategy="File" />
diff --git a/DropShadowForm.cs b/DropShadowForm.cs
new file mode 100644
index 0000000..2550187
--- /dev/null
+++ b/DropShadowForm.cs
@@ -0,0 +1,319 @@
+// BitmapSpriteEd - Bitmap Sprite Editor
+// Copyright (C) 2005 Ian Cowburn
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// $Id$
+//
+
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace BitmapSpriteEd
+{
+ /// <summary>
+ /// Description of DropShadowForm.
+ /// </summary>
+ public class DropShadowForm : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.RadioButton m_bottomLeft;
+ private System.Windows.Forms.Button m_ok;
+ private System.Windows.Forms.RadioButton m_topRight;
+ private System.Windows.Forms.RadioButton m_left;
+ private System.Windows.Forms.Label m_color;
+ private System.Windows.Forms.RadioButton m_top;
+ private System.Windows.Forms.RadioButton m_topLeft;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.NumericUpDown m_depth;
+ private System.Windows.Forms.RadioButton m_bottomRight;
+ private System.Windows.Forms.Button m_cancel;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.RadioButton m_right;
+ private System.Windows.Forms.RadioButton m_bottom;
+
+ public class Shadow
+ {
+ public Shadow(int dx, int dy)
+ {
+ m_dx=dx;
+ m_dy=dy;
+ }
+
+ public int DX {get {return m_dx;}}
+ public int DY {get {return m_dy;}}
+
+ private int m_dx;
+ private int m_dy;
+ }
+
+ public DropShadowForm()
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+ InitializeComponent();
+
+ m_topLeft.Tag=new Shadow(-1,-1);
+ m_top.Tag=new Shadow(0,-1);
+ m_topRight.Tag=new Shadow(1,-1);
+ m_left.Tag=new Shadow(-1,0);
+ m_right.Tag=new Shadow(1,0);
+ m_bottomLeft.Tag=new Shadow(-1,1);
+ m_bottom.Tag=new Shadow(0,1);
+ m_bottomRight.Tag=new Shadow(1,1);
+ }
+
+ #region Windows Forms Designer generated code
+ /// <summary>
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ /// </summary>
+ private void InitializeComponent() {
+ this.m_bottom = new System.Windows.Forms.RadioButton();
+ this.m_right = new System.Windows.Forms.RadioButton();
+ this.label1 = new System.Windows.Forms.Label();
+ this.m_cancel = new System.Windows.Forms.Button();
+ this.m_bottomRight = new System.Windows.Forms.RadioButton();
+ this.m_depth = new System.Windows.Forms.NumericUpDown();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.m_topLeft = new System.Windows.Forms.RadioButton();
+ this.m_top = new System.Windows.Forms.RadioButton();
+ this.m_color = new System.Windows.Forms.Label();
+ this.m_left = new System.Windows.Forms.RadioButton();
+ this.m_topRight = new System.Windows.Forms.RadioButton();
+ this.m_ok = new System.Windows.Forms.Button();
+ this.m_bottomLeft = new System.Windows.Forms.RadioButton();
+ ((System.ComponentModel.ISupportInitialize)(this.m_depth)).BeginInit();
+ this.SuspendLayout();
+ //
+ // m_bottom
+ //
+ this.m_bottom.Location = new System.Drawing.Point(32, 48);
+ this.m_bottom.Name = "m_bottom";
+ this.m_bottom.Size = new System.Drawing.Size(16, 16);
+ this.m_bottom.TabIndex = 8;
+ //
+ // m_right
+ //
+ this.m_right.Location = new System.Drawing.Point(48, 32);
+ this.m_right.Name = "m_right";
+ this.m_right.Size = new System.Drawing.Size(16, 16);
+ this.m_right.TabIndex = 5;
+ //
+ // label1
+ //
+ this.label1.Location = new System.Drawing.Point(72, 16);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(56, 48);
+ this.label1.TabIndex = 9;
+ this.label1.Text = "Shadow Direction";
+ this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // m_cancel
+ //
+ this.m_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.m_cancel.Location = new System.Drawing.Point(136, 120);
+ this.m_cancel.Name = "m_cancel";
+ this.m_cancel.Size = new System.Drawing.Size(112, 24);
+ this.m_cancel.TabIndex = 10;
+ this.m_cancel.Text = "Cancel";
+ this.m_cancel.Click += new System.EventHandler(this.OnOK);
+ //
+ // m_bottomRight
+ //
+ this.m_bottomRight.Checked = true;
+ this.m_bottomRight.Location = new System.Drawing.Point(48, 48);
+ this.m_bottomRight.Name = "m_bottomRight";
+ this.m_bottomRight.Size = new System.Drawing.Size(16, 16);
+ this.m_bottomRight.TabIndex = 7;
+ this.m_bottomRight.TabStop = true;
+ //
+ // m_depth
+ //
+ this.m_depth.Location = new System.Drawing.Point(16, 72);
+ this.m_depth.Maximum = new System.Decimal(new int[] {
+ 10,
+ 0,
+ 0,
+ 0});
+ this.m_depth.Minimum = new System.Decimal(new int[] {
+ 1,
+ 0,
+ 0,
+ 0});
+ this.m_depth.Name = "m_depth";
+ this.m_depth.ReadOnly = true;
+ this.m_depth.Size = new System.Drawing.Size(48, 20);
+ this.m_depth.TabIndex = 11;
+ this.m_depth.Value = new System.Decimal(new int[] {
+ 1,
+ 0,
+ 0,
+ 0});
+ //
+ // label3
+ //
+ this.label3.Location = new System.Drawing.Point(72, 104);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(56, 40);
+ this.label3.TabIndex = 14;
+ this.label3.Text = "Shadow Color";
+ this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // label2
+ //
+ this.label2.Location = new System.Drawing.Point(72, 72);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(48, 24);
+ this.label2.TabIndex = 12;
+ this.label2.Text = "Shadow Depth";
+ this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // m_topLeft
+ //
+ this.m_topLeft.Location = new System.Drawing.Point(16, 16);
+ this.m_topLeft.Name = "m_topLeft";
+ this.m_topLeft.Size = new System.Drawing.Size(16, 16);
+ this.m_topLeft.TabIndex = 1;
+ //
+ // m_top
+ //
+ this.m_top.Location = new System.Drawing.Point(32, 16);
+ this.m_top.Name = "m_top";
+ this.m_top.Size = new System.Drawing.Size(16, 16);
+ this.m_top.TabIndex = 2;
+ //
+ // m_color
+ //
+ this.m_color.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));
+ this.m_color.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_color.Location = new System.Drawing.Point(16, 104);
+ this.m_color.Name = "m_color";
+ this.m_color.Size = new System.Drawing.Size(48, 40);
+ this.m_color.TabIndex = 13;
+ this.m_color.Click += new System.EventHandler(this.OnSelectColor);
+ //
+ // m_left
+ //
+ this.m_left.Location = new System.Drawing.Point(16, 32);
+ this.m_left.Name = "m_left";
+ this.m_left.Size = new System.Drawing.Size(16, 16);
+ this.m_left.TabIndex = 4;
+ //
+ // m_topRight
+ //
+ this.m_topRight.Location = new System.Drawing.Point(48, 16);
+ this.m_topRight.Name = "m_topRight";
+ this.m_topRight.Size = new System.Drawing.Size(16, 16);
+ this.m_topRight.TabIndex = 3;
+ //
+ // m_ok
+ //
+ this.m_ok.Location = new System.Drawing.Point(136, 88);
+ this.m_ok.Name = "m_ok";
+ this.m_ok.Size = new System.Drawing.Size(112, 24);
+ this.m_ok.TabIndex = 0;
+ this.m_ok.Text = "OK";
+ this.m_ok.Click += new System.EventHandler(this.OnOK);
+ //
+ // m_bottomLeft
+ //
+ this.m_bottomLeft.Location = new System.Drawing.Point(16, 48);
+ this.m_bottomLeft.Name = "m_bottomLeft";
+ this.m_bottomLeft.Size = new System.Drawing.Size(16, 16);
+ this.m_bottomLeft.TabIndex = 6;
+ //
+ // DropShadowForm
+ //
+ this.AcceptButton = this.m_ok;
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.CancelButton = this.m_cancel;
+ this.ClientSize = new System.Drawing.Size(258, 154);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.m_color);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.m_depth);
+ this.Controls.Add(this.m_cancel);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.m_left);
+ this.Controls.Add(this.m_ok);
+ this.Controls.Add(this.m_bottomLeft);
+ this.Controls.Add(this.m_bottom);
+ this.Controls.Add(this.m_bottomRight);
+ this.Controls.Add(this.m_right);
+ this.Controls.Add(this.m_topRight);
+ this.Controls.Add(this.m_top);
+ this.Controls.Add(this.m_topLeft);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+ this.Name = "DropShadowForm";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Drop Shadow";
+ ((System.ComponentModel.ISupportInitialize)(this.m_depth)).EndInit();
+ this.ResumeLayout(false);
+ }
+ #endregion
+
+ public Shadow ShadowSize
+ {
+ get
+ {
+ foreach (Control c in Controls)
+ {
+ if (c is RadioButton)
+ {
+ RadioButton r=(RadioButton)c;
+
+ if (r.Checked)
+ {
+ Shadow s=(Shadow)r.Tag;
+ int depth=Convert.ToInt32(m_depth.Value);
+
+ return new Shadow(s.DX*depth,s.DY*depth);
+ }
+ }
+ }
+
+ return new Shadow(0,0);
+ }
+ }
+
+ public Color ShadowColour
+ {
+ get {return m_color.BackColor;}
+ }
+
+ void OnOK(object sender, System.EventArgs e)
+ {
+ DialogResult=DialogResult.OK;
+ Close();
+ }
+
+ void OnSelectColor(object sender, System.EventArgs e)
+ {
+ AlphaColourDialog d=new AlphaColourDialog("Select shadow colour");
+
+ d.Color=m_color.BackColor;
+
+ if (d.ShowDialog()==DialogResult.OK)
+ {
+ m_color.BackColor=d.Color;
+ }
+ }
+ }
+}
diff --git a/GfxEditor.cs b/GfxEditor.cs
index 604f00e..25578b9 100644
--- a/GfxEditor.cs
+++ b/GfxEditor.cs
@@ -149,6 +149,11 @@ namespace BitmapSpriteEd
private Label[] m_recent;
+ private AlphaColourDialog m_fromColForm;
+ private AlphaColourDialog m_toColForm;
+ private AlphaColourDialog m_edgeColForm;
+ private DropShadowForm m_shadowForm;
+
public GfxEditor()
{
//
@@ -187,6 +192,11 @@ namespace BitmapSpriteEd
m_cpMenu=new CopyMenu();
m_manipMenu=new ManipulationMenu();
+ m_fromColForm=new AlphaColourDialog("Select colour to change from");
+ m_toColForm=new AlphaColourDialog("Select colour to change to");
+ m_edgeColForm=new AlphaColourDialog("Select edge colour");
+ m_shadowForm=new DropShadowForm();
+
m_recent=new Label[]
{m_recent1,m_recent2,m_recent3,m_recent4,
m_recent5,m_recent6,m_recent7,m_recent8};
@@ -1481,6 +1491,43 @@ namespace BitmapSpriteEd
case ManipulationMenu.EMode.eScrollRight:
m_char.Scroll(1,0);
break;
+
+ case ManipulationMenu.EMode.eEdge:
+ if (m_edgeColForm.ShowDialog()==DialogResult.OK)
+ {
+ SetUndo(new Frame(m_char));
+ m_char.Edge(m_edgeColForm.Color);
+ }
+ break;
+
+ case ManipulationMenu.EMode.eDropShadow:
+ if (m_shadowForm.ShowDialog()==DialogResult.OK)
+ {
+ SetUndo(new Frame(m_char));
+ m_char.DropShadow(m_shadowForm.ShadowSize.DX,
+ m_shadowForm.ShadowSize.DY,
+ m_shadowForm.ShadowColour);
+ }
+ break;
+
+ case ManipulationMenu.EMode.eReplace:
+ if (m_fromColForm.ShowDialog()==DialogResult.OK)
+ {
+ if (m_toColForm.ShowDialog()==DialogResult.OK)
+ {
+ SetUndo(new Frame(m_char));
+ m_char.Replace(m_fromColForm.Color,m_toColForm.Color);
+ }
+ }
+ break;
+
+ case ManipulationMenu.EMode.eReplaceAll:
+ if (m_toColForm.ShowDialog()==DialogResult.OK)
+ {
+ SetUndo(new Frame(m_char));
+ m_char.Replace(m_toColForm.Color);
+ }
+ break;
case ManipulationMenu.EMode.eNothing:
redraw=false;
diff --git a/ManipulationMenu.cs b/ManipulationMenu.cs
index f71cbd3..0e6696c 100644
--- a/ManipulationMenu.cs
+++ b/ManipulationMenu.cs
@@ -39,7 +39,11 @@ namespace BitmapSpriteEd
eScrollUp,
eScrollDown,
eScrollLeft,
- eScrollRight
+ eScrollRight,
+ eEdge,
+ eDropShadow,
+ eReplace,
+ eReplaceAll
};
public ManipulationMenu()
@@ -94,6 +98,10 @@ namespace BitmapSpriteEd
CreateItem("Scroll Down",EMode.eScrollDown);
CreateItem("Scroll Left",EMode.eScrollLeft);
CreateItem("Scroll Right",EMode.eScrollRight);
+ CreateItem("Edge",EMode.eEdge);
+ CreateItem("Drop Shadow",EMode.eDropShadow);
+ CreateItem("Replace Colour",EMode.eReplace);
+ CreateItem("Replace all non-zero alpha colours",EMode.eReplaceAll);
}
private void OnMenu(object sender, System.EventArgs e)
diff --git a/Sprite.cs b/Sprite.cs
index 290f582..ac2c0e7 100644
--- a/Sprite.cs
+++ b/Sprite.cs
@@ -145,8 +145,12 @@ namespace BitmapSpriteEd
Color[,] d=new Color[m_width,m_height];
for(int y=0;y<m_height;y++)
+ {
for(int x=0;x<m_width;x++)
- d[x,y]=m_data[m_width-x-1,y];
+ {
+ d[x,y]=m_data[m_width-x-1,y];
+ }
+ }
m_data=d;
m_changed=true;
@@ -157,8 +161,12 @@ namespace BitmapSpriteEd
Color[,] d=new Color[m_width,m_height];
for(int y=0;y<m_height;y++)
+ {
for(int x=0;x<m_width;x++)
- d[x,y]=m_data[x,m_height-y-1];
+ {
+ d[x,y]=m_data[x,m_height-y-1];
+ }
+ }
m_data=d;
m_changed=true;
@@ -169,8 +177,12 @@ namespace BitmapSpriteEd
Color[,] d=new Color[m_width,m_height];
for(int y=0;y<m_height;y++)
+ {
for(int x=0;x<m_width;x++)
- d[Mod(x+dx,m_width),Mod(y+dy,m_height)]=m_data[x,y];
+ {
+ d[Mod(x+dx,m_width),Mod(y+dy,m_height)]=m_data[x,y];
+ }
+ }
m_data=d;
m_changed=true;
@@ -218,6 +230,134 @@ namespace BitmapSpriteEd
m_changed=true;
}
+ public void DropShadow(int dx, int dy, Color col)
+ {
+ Color[,] d=new Color[m_width,m_height];
+
+ // I'm sure this is too convoluted...
+ //
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ d[x,y]=Color.Transparent;
+ }
+ }
+
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ if (m_data[x,y].A!=0)
+ {
+ int nx=x+dx;
+ int ny=y+dy;
+
+ if (nx>=0 && nx<m_width && ny>=0 && ny<m_height &&
+ m_data[nx,ny].A==0)
+ {
+ d[nx,ny]=col;
+ }
+ }
+ }
+ }
+
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ if (d[x,y].A!=0)
+ {
+ m_data[x,y]=d[x,y];
+ }
+ }
+ }
+
+ m_changed=true;
+ }
+
+ public void Edge(Color col)
+ {
+ Color[,] d=new Color[m_width,m_height];
+
+ // I'm sure this is too convoluted...
+ //
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ d[x,y]=Color.Transparent;
+ }
+ }
+
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ if (m_data[x,y].A!=0)
+ {
+ for(int dx=-1;dx<2;dx++)
+ for(int dy=-1;dy<2;dy++)
+ {
+ int nx=x+dx;
+ int ny=y+dy;
+
+ if (nx>=0 && nx<m_width && ny>=0 && ny<m_height &&
+ m_data[nx,ny].A==0)
+ {
+ d[nx,ny]=col;
+ }
+ }
+ }
+ }
+ }
+
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ if (d[x,y].A!=0)
+ {
+ m_data[x,y]=d[x,y];
+ }
+ }
+ }
+
+ m_changed=true;
+ }
+
+ public void Replace(Color from, Color to)
+ {
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ if (m_data[x,y]==from)
+ {
+ m_data[x,y]=to;
+ }
+ }
+ }
+
+ m_changed=true;
+ }
+
+ public void Replace(Color to)
+ {
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ if (m_data[x,y].A>0)
+ {
+ m_data[x,y]=to;
+ }
+ }
+ }
+
+ m_changed=true;
+ }
+
public void Output(Stream stream)
{
Util.WriteInt(stream,m_width);