diff options
-rw-r--r-- | AlphaColourDialog.cs | 508 | ||||
-rw-r--r-- | BitmapChar.cs | 48 | ||||
-rw-r--r-- | BitmapFontEd.AlphaColourDialog.resources | bin | 0 -> 12357 bytes | |||
-rw-r--r-- | BitmapFontEd.GfxEditor.resources | bin | 13351 -> 14416 bytes | |||
-rw-r--r-- | BitmapFontEd.prjx | 7 | ||||
-rw-r--r-- | DropShadowForm.cs | 3 | ||||
-rw-r--r-- | GfxEditor.cs | 217 | ||||
-rw-r--r-- | MainForm.cs | 41 | ||||
-rw-r--r-- | Util.cs | 5 |
9 files changed, 697 insertions, 132 deletions
diff --git a/AlphaColourDialog.cs b/AlphaColourDialog.cs new file mode 100644 index 0000000..87faf69 --- /dev/null +++ b/AlphaColourDialog.cs @@ -0,0 +1,508 @@ +// XXX - YYY
+// Copyright (C) 200X 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 BitmapFontEd
+{
+ /// <summary>
+ /// Description of AlphaColourDialog.
+ /// </summary>
+ public class AlphaColourDialog : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.Label m_common7;
+ private System.Windows.Forms.Label m_common4;
+ private System.Windows.Forms.Label m_common5;
+ private System.Windows.Forms.Label m_common3;
+ private System.Windows.Forms.TextBox m_red;
+ private System.Windows.Forms.TrackBar m_greenSlider;
+ private System.Windows.Forms.TextBox m_alpha;
+ private System.Windows.Forms.Label m_preview;
+ private System.Windows.Forms.ComboBox m_named;
+ private System.Windows.Forms.TrackBar m_redSlider;
+ private System.Windows.Forms.TrackBar m_alphaSlider;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.TextBox m_green;
+ private System.Windows.Forms.TrackBar m_blueSlider;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.TextBox m_blue;
+ private System.Windows.Forms.Label m_common8;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Label m_common2;
+ private System.Windows.Forms.Button m_ok;
+ private System.Windows.Forms.Button m_cancel;
+ private System.Windows.Forms.Label m_common1;
+ private System.Windows.Forms.Label m_common6;
+
+ private bool m_allowAlpha;
+
+ public AlphaColourDialog(string title)
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+ InitializeComponent();
+
+ Text=title;
+
+ foreach (KnownColor col in Enum.GetValues(typeof(KnownColor)))
+ {
+ if (Color.FromKnownColor(col).A==255)
+ {
+ m_named.Items.Add(col.ToString());
+ }
+ }
+
+ m_allowAlpha=true;
+ }
+
+ public Color Color
+ {
+ get
+ {
+ return m_preview.BackColor;
+ }
+ set
+ {
+ m_redSlider.Value=value.R;
+ m_greenSlider.Value=value.G;
+ m_blueSlider.Value=value.B;
+
+ if (m_allowAlpha)
+ {
+ m_alphaSlider.Value=value.A;
+ }
+ else
+ {
+ m_alphaSlider.Value=255;
+ }
+
+ SetColour();
+ }
+ }
+
+ public bool AllowAlpha
+ {
+ set
+ {
+ m_allowAlpha=value;
+ m_alphaSlider.Visible=false;
+ }
+ }
+
+ private void SetColour()
+ {
+ m_red.Text=m_redSlider.Value.ToString();
+ m_green.Text=m_greenSlider.Value.ToString();
+ m_blue.Text=m_blueSlider.Value.ToString();
+ m_alpha.Text=m_alphaSlider.Value.ToString();
+
+ m_preview.BackColor=Color.FromArgb(m_alphaSlider.Value,
+ m_redSlider.Value,
+ m_greenSlider.Value,
+ m_blueSlider.Value);
+ }
+
+ #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_common6 = new System.Windows.Forms.Label();
+ this.m_common1 = new System.Windows.Forms.Label();
+ this.m_cancel = new System.Windows.Forms.Button();
+ this.m_ok = new System.Windows.Forms.Button();
+ this.m_common2 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
+ this.label6 = new System.Windows.Forms.Label();
+ this.m_common8 = new System.Windows.Forms.Label();
+ this.m_blue = new System.Windows.Forms.TextBox();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.m_blueSlider = new System.Windows.Forms.TrackBar();
+ this.m_green = new System.Windows.Forms.TextBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.m_alphaSlider = new System.Windows.Forms.TrackBar();
+ this.m_redSlider = new System.Windows.Forms.TrackBar();
+ this.m_named = new System.Windows.Forms.ComboBox();
+ this.m_preview = new System.Windows.Forms.Label();
+ this.m_alpha = new System.Windows.Forms.TextBox();
+ this.m_greenSlider = new System.Windows.Forms.TrackBar();
+ this.m_red = new System.Windows.Forms.TextBox();
+ this.m_common3 = new System.Windows.Forms.Label();
+ this.m_common5 = new System.Windows.Forms.Label();
+ this.m_common4 = new System.Windows.Forms.Label();
+ this.m_common7 = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.m_blueSlider)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.m_alphaSlider)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.m_redSlider)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.m_greenSlider)).BeginInit();
+ this.SuspendLayout();
+ //
+ // m_common6
+ //
+ this.m_common6.BackColor = System.Drawing.Color.Yellow;
+ this.m_common6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_common6.Location = new System.Drawing.Point(56, 240);
+ this.m_common6.Name = "m_common6";
+ this.m_common6.Size = new System.Drawing.Size(24, 24);
+ this.m_common6.TabIndex = 21;
+ this.m_common6.Click += new System.EventHandler(this.OnCommon);
+ //
+ // m_common1
+ //
+ this.m_common1.BackColor = System.Drawing.Color.Black;
+ this.m_common1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_common1.Location = new System.Drawing.Point(16, 208);
+ this.m_common1.Name = "m_common1";
+ this.m_common1.Size = new System.Drawing.Size(24, 24);
+ this.m_common1.TabIndex = 16;
+ this.m_common1.Click += new System.EventHandler(this.OnCommon);
+ //
+ // m_cancel
+ //
+ this.m_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.m_cancel.Location = new System.Drawing.Point(296, 328);
+ this.m_cancel.Name = "m_cancel";
+ this.m_cancel.Size = new System.Drawing.Size(104, 24);
+ this.m_cancel.TabIndex = 13;
+ this.m_cancel.Text = "Cancel";
+ //
+ // m_ok
+ //
+ this.m_ok.Location = new System.Drawing.Point(184, 328);
+ this.m_ok.Name = "m_ok";
+ this.m_ok.Size = new System.Drawing.Size(104, 24);
+ this.m_ok.TabIndex = 12;
+ this.m_ok.Text = "OK";
+ this.m_ok.Click += new System.EventHandler(this.OnOK);
+ //
+ // m_common2
+ //
+ this.m_common2.BackColor = System.Drawing.Color.White;
+ this.m_common2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_common2.Location = new System.Drawing.Point(56, 208);
+ this.m_common2.Name = "m_common2";
+ this.m_common2.Size = new System.Drawing.Size(24, 24);
+ this.m_common2.TabIndex = 17;
+ this.m_common2.Click += new System.EventHandler(this.OnCommon);
+ //
+ // label4
+ //
+ this.label4.Location = new System.Drawing.Point(352, 0);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(56, 24);
+ this.label4.TabIndex = 7;
+ this.label4.Text = "Alpha";
+ this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // label5
+ //
+ this.label5.Location = new System.Drawing.Point(8, 192);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(128, 16);
+ this.label5.TabIndex = 15;
+ this.label5.Text = "Primary Colours:";
+ //
+ // label6
+ //
+ this.label6.Location = new System.Drawing.Point(8, 280);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(128, 16);
+ this.label6.TabIndex = 24;
+ this.label6.Text = "Named Colours:";
+ //
+ // m_common8
+ //
+ this.m_common8.BackColor = System.Drawing.Color.Cyan;
+ this.m_common8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_common8.Location = new System.Drawing.Point(136, 240);
+ this.m_common8.Name = "m_common8";
+ this.m_common8.Size = new System.Drawing.Size(24, 24);
+ this.m_common8.TabIndex = 23;
+ this.m_common8.Click += new System.EventHandler(this.OnCommon);
+ //
+ // m_blue
+ //
+ this.m_blue.Location = new System.Drawing.Point(304, 296);
+ this.m_blue.MaxLength = 3;
+ this.m_blue.Name = "m_blue";
+ this.m_blue.ReadOnly = true;
+ this.m_blue.Size = new System.Drawing.Size(40, 20);
+ this.m_blue.TabIndex = 10;
+ this.m_blue.Text = "textBox1";
+ //
+ // label2
+ //
+ this.label2.Location = new System.Drawing.Point(240, 0);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(56, 24);
+ this.label2.TabIndex = 3;
+ this.label2.Text = "Green";
+ this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // label3
+ //
+ this.label3.Location = new System.Drawing.Point(296, 0);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(56, 24);
+ this.label3.TabIndex = 5;
+ this.label3.Text = "Blue";
+ this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // m_blueSlider
+ //
+ this.m_blueSlider.Location = new System.Drawing.Point(304, 24);
+ this.m_blueSlider.Maximum = 255;
+ this.m_blueSlider.Name = "m_blueSlider";
+ this.m_blueSlider.Orientation = System.Windows.Forms.Orientation.Vertical;
+ this.m_blueSlider.Size = new System.Drawing.Size(42, 264);
+ this.m_blueSlider.TabIndex = 4;
+ this.m_blueSlider.TickFrequency = 5;
+ this.m_blueSlider.Scroll += new System.EventHandler(this.OnBlue);
+ //
+ // m_green
+ //
+ this.m_green.Location = new System.Drawing.Point(248, 296);
+ this.m_green.MaxLength = 3;
+ this.m_green.Name = "m_green";
+ this.m_green.ReadOnly = true;
+ this.m_green.Size = new System.Drawing.Size(40, 20);
+ this.m_green.TabIndex = 9;
+ this.m_green.Text = "textBox1";
+ //
+ // label1
+ //
+ this.label1.Location = new System.Drawing.Point(184, 0);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(56, 24);
+ this.label1.TabIndex = 1;
+ this.label1.Text = "Red";
+ this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // m_alphaSlider
+ //
+ this.m_alphaSlider.Location = new System.Drawing.Point(360, 24);
+ this.m_alphaSlider.Maximum = 255;
+ this.m_alphaSlider.Name = "m_alphaSlider";
+ this.m_alphaSlider.Orientation = System.Windows.Forms.Orientation.Vertical;
+ this.m_alphaSlider.Size = new System.Drawing.Size(42, 264);
+ this.m_alphaSlider.TabIndex = 6;
+ this.m_alphaSlider.TickFrequency = 5;
+ this.m_alphaSlider.Value = 255;
+ this.m_alphaSlider.Scroll += new System.EventHandler(this.OnAlpha);
+ //
+ // m_redSlider
+ //
+ this.m_redSlider.Location = new System.Drawing.Point(192, 24);
+ this.m_redSlider.Maximum = 255;
+ this.m_redSlider.Name = "m_redSlider";
+ this.m_redSlider.Orientation = System.Windows.Forms.Orientation.Vertical;
+ this.m_redSlider.Size = new System.Drawing.Size(42, 264);
+ this.m_redSlider.TabIndex = 0;
+ this.m_redSlider.TickFrequency = 5;
+ this.m_redSlider.Scroll += new System.EventHandler(this.OnRed);
+ //
+ // m_named
+ //
+ this.m_named.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.m_named.Location = new System.Drawing.Point(8, 296);
+ this.m_named.MaxDropDownItems = 20;
+ this.m_named.Name = "m_named";
+ this.m_named.Size = new System.Drawing.Size(168, 21);
+ this.m_named.Sorted = true;
+ this.m_named.TabIndex = 25;
+ this.m_named.SelectedIndexChanged += new System.EventHandler(this.OnNamedColour);
+ //
+ // m_preview
+ //
+ this.m_preview.BackColor = System.Drawing.Color.Black;
+ this.m_preview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_preview.Location = new System.Drawing.Point(8, 8);
+ this.m_preview.Name = "m_preview";
+ this.m_preview.Size = new System.Drawing.Size(168, 168);
+ this.m_preview.TabIndex = 14;
+ //
+ // m_alpha
+ //
+ this.m_alpha.Location = new System.Drawing.Point(360, 296);
+ this.m_alpha.MaxLength = 3;
+ this.m_alpha.Name = "m_alpha";
+ this.m_alpha.ReadOnly = true;
+ this.m_alpha.Size = new System.Drawing.Size(40, 20);
+ this.m_alpha.TabIndex = 11;
+ this.m_alpha.Text = "textBox1";
+ //
+ // m_greenSlider
+ //
+ this.m_greenSlider.Location = new System.Drawing.Point(248, 24);
+ this.m_greenSlider.Maximum = 255;
+ this.m_greenSlider.Name = "m_greenSlider";
+ this.m_greenSlider.Orientation = System.Windows.Forms.Orientation.Vertical;
+ this.m_greenSlider.Size = new System.Drawing.Size(42, 264);
+ this.m_greenSlider.TabIndex = 2;
+ this.m_greenSlider.TickFrequency = 5;
+ this.m_greenSlider.Scroll += new System.EventHandler(this.OnGreen);
+ //
+ // m_red
+ //
+ this.m_red.Location = new System.Drawing.Point(192, 296);
+ this.m_red.MaxLength = 3;
+ this.m_red.Name = "m_red";
+ this.m_red.ReadOnly = true;
+ this.m_red.Size = new System.Drawing.Size(40, 20);
+ this.m_red.TabIndex = 8;
+ this.m_red.Text = "textBox1";
+ //
+ // m_common3
+ //
+ this.m_common3.BackColor = System.Drawing.Color.Red;
+ this.m_common3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_common3.Location = new System.Drawing.Point(96, 208);
+ this.m_common3.Name = "m_common3";
+ this.m_common3.Size = new System.Drawing.Size(24, 24);
+ this.m_common3.TabIndex = 18;
+ this.m_common3.Click += new System.EventHandler(this.OnCommon);
+ //
+ // m_common5
+ //
+ this.m_common5.BackColor = System.Drawing.Color.Blue;
+ this.m_common5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_common5.Location = new System.Drawing.Point(16, 240);
+ this.m_common5.Name = "m_common5";
+ this.m_common5.Size = new System.Drawing.Size(24, 24);
+ this.m_common5.TabIndex = 20;
+ this.m_common5.Click += new System.EventHandler(this.OnCommon);
+ //
+ // m_common4
+ //
+ this.m_common4.BackColor = System.Drawing.Color.Lime;
+ this.m_common4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_common4.Location = new System.Drawing.Point(136, 208);
+ this.m_common4.Name = "m_common4";
+ this.m_common4.Size = new System.Drawing.Size(24, 24);
+ this.m_common4.TabIndex = 19;
+ this.m_common4.Click += new System.EventHandler(this.OnCommon);
+ //
+ // m_common7
+ //
+ this.m_common7.BackColor = System.Drawing.Color.Fuchsia;
+ this.m_common7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_common7.Location = new System.Drawing.Point(96, 240);
+ this.m_common7.Name = "m_common7";
+ this.m_common7.Size = new System.Drawing.Size(24, 24);
+ this.m_common7.TabIndex = 22;
+ this.m_common7.Click += new System.EventHandler(this.OnCommon);
+ //
+ // AlphaColourDialog
+ //
+ this.AcceptButton = this.m_ok;
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.CancelButton = this.m_cancel;
+ this.ClientSize = new System.Drawing.Size(410, 362);
+ this.Controls.Add(this.m_named);
+ this.Controls.Add(this.label6);
+ this.Controls.Add(this.m_common8);
+ this.Controls.Add(this.m_common7);
+ this.Controls.Add(this.m_common6);
+ this.Controls.Add(this.m_common5);
+ this.Controls.Add(this.m_common4);
+ this.Controls.Add(this.m_common3);
+ this.Controls.Add(this.m_common2);
+ this.Controls.Add(this.m_common1);
+ this.Controls.Add(this.label5);
+ this.Controls.Add(this.m_preview);
+ this.Controls.Add(this.m_cancel);
+ this.Controls.Add(this.m_ok);
+ this.Controls.Add(this.m_alpha);
+ this.Controls.Add(this.m_blue);
+ this.Controls.Add(this.m_green);
+ this.Controls.Add(this.m_red);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.m_alphaSlider);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.m_blueSlider);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.m_greenSlider);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.m_redSlider);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+ this.Name = "AlphaColourDialog";
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "AlphaColourDialog";
+ ((System.ComponentModel.ISupportInitialize)(this.m_blueSlider)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.m_alphaSlider)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.m_redSlider)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.m_greenSlider)).EndInit();
+ this.ResumeLayout(false);
+ }
+ #endregion
+
+ void OnRed(object sender, System.EventArgs e)
+ {
+ SetColour();
+ }
+
+ void OnGreen(object sender, System.EventArgs e)
+ {
+ SetColour();
+ }
+
+ void OnBlue(object sender, System.EventArgs e)
+ {
+ SetColour();
+ }
+
+ void OnAlpha(object sender, System.EventArgs e)
+ {
+ SetColour();
+ }
+
+ void OnOK(object sender, System.EventArgs e)
+ {
+ DialogResult=DialogResult.OK;
+ Close();
+ }
+
+ void OnCommon(object sender, System.EventArgs e)
+ {
+ Label l=(Label)sender;
+
+ Color=l.BackColor;
+ }
+
+ void OnNamedColour(object sender, System.EventArgs e)
+ {
+ string s=(string)m_named.SelectedItem;
+
+ Color=Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor),s));
+ }
+
+ }
+}
diff --git a/BitmapChar.cs b/BitmapChar.cs index 12d3aae..4719b33 100644 --- a/BitmapChar.cs +++ b/BitmapChar.cs @@ -34,7 +34,7 @@ namespace BitmapFontEd m_width=width;
m_height=height;
m_data=new Color[m_width,m_height];
- Clear(Color.Black);
+ Clear(Color.Empty);
m_changed=false;
}
@@ -81,7 +81,7 @@ namespace BitmapFontEd for(int y=0;y<height;y++)
for(int x=0;x<width;x++)
- data[x,y]=Color.Black;
+ data[x,y]=Color.Empty;
uint mx=Math.Min(width,m_width);
uint my=Math.Min(height,m_height);
@@ -201,17 +201,17 @@ namespace BitmapFontEd //
for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
- d[x,y]=Color.Black;
+ d[x,y]=Color.Empty;
for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
- if (m_data[x,y]!=Color.Black)
+ 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]==Color.Black)
+ m_data[nx,ny].A==0)
{
d[nx,ny]=col;
}
@@ -219,7 +219,7 @@ namespace BitmapFontEd for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
- if (d[x,y]!=Color.Black)
+ if (d[x,y].A!=0)
{
m_data[x,y]=d[x,y];
}
@@ -235,11 +235,11 @@ namespace BitmapFontEd //
for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
- d[x,y]=Color.Black;
+ d[x,y]=Color.Empty;
for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
- if (m_data[x,y]!=Color.Black)
+ if (m_data[x,y].A!=0)
{
for(int dx=-1;dx<2;dx++)
for(int dy=-1;dy<2;dy++)
@@ -248,7 +248,7 @@ namespace BitmapFontEd int ny=y+dy;
if (nx>=0 && nx<m_width && ny>=0 && ny<m_height &&
- m_data[nx,ny]==Color.Black)
+ m_data[nx,ny].A==0)
{
d[nx,ny]=col;
}
@@ -257,7 +257,7 @@ namespace BitmapFontEd for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
- if (d[x,y]!=Color.Black)
+ if (d[x,y].A!=0)
{
m_data[x,y]=d[x,y];
}
@@ -274,14 +274,10 @@ namespace BitmapFontEd {
for(uint y=0;y<m_height;y++)
{
- if (m_data[x,y]!=Color.Black)
- {
- Util.WriteInt(stream,m_data[x,y].ToArgb());
- }
- else
- {
- Util.WriteInt(stream,0);
- }
+ stream.WriteByte(m_data[x,y].B);
+ stream.WriteByte(m_data[x,y].G);
+ stream.WriteByte(m_data[x,y].R);
+ stream.WriteByte(m_data[x,y].A);
}
}
}
@@ -297,16 +293,12 @@ namespace BitmapFontEd {
for(uint y=0;y<height;y++)
{
- int col=Util.ReadInt(stream);
-
- if (col==0)
- {
- s[x,y]=Color.Black;
- }
- else
- {
- s[x,y]=Color.FromArgb(255,(col&0xff0000)>>16,(col&0xff00)>>8,col&0xff);
- }
+ int B=stream.ReadByte();
+ int G=stream.ReadByte();
+ int R=stream.ReadByte();
+ int A=stream.ReadByte();
+
+ s[x,y]=Color.FromArgb(A,R,G,B);
}
}
diff --git a/BitmapFontEd.AlphaColourDialog.resources b/BitmapFontEd.AlphaColourDialog.resources Binary files differnew file mode 100644 index 0000000..c7f215e --- /dev/null +++ b/BitmapFontEd.AlphaColourDialog.resources diff --git a/BitmapFontEd.GfxEditor.resources b/BitmapFontEd.GfxEditor.resources Binary files differindex 275f1ce..01b0eb4 100644 --- a/BitmapFontEd.GfxEditor.resources +++ b/BitmapFontEd.GfxEditor.resources diff --git a/BitmapFontEd.prjx b/BitmapFontEd.prjx index ece3b36..213ceea 100644 --- a/BitmapFontEd.prjx +++ b/BitmapFontEd.prjx @@ -10,17 +10,20 @@ <File name="..\Util.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="" />
+ <File name=".\BitmapFontEd.DebugDisplay.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
+ <File name=".\AlphaColourDialog.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\BitmapFontEd.AlphaColourDialog.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
</Contents>
<References />
<DeploymentInformation target="" script="" strategy="File" />
<Configuration runwithwarnings="True" name="Debug">
- <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="WinExe" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
+ <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="Standard" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="WinExe" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
<Execution commandlineparameters="" consolepause="False" />
<Output directory="..\bin\Debug" assembly="BitmapFontEd" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
</Configuration>
<Configurations active="Debug">
<Configuration runwithwarnings="True" name="Debug">
- <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="WinExe" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
+ <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="Standard" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="WinExe" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
<Execution commandlineparameters="" consolepause="False" />
<Output directory="..\bin\Debug" assembly="BitmapFontEd" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
</Configuration>
diff --git a/DropShadowForm.cs b/DropShadowForm.cs index ac3b55f..2446042 100644 --- a/DropShadowForm.cs +++ b/DropShadowForm.cs @@ -306,10 +306,9 @@ namespace BitmapFontEd void OnSelectColor(object sender, System.EventArgs e)
{
- ColorDialog d=new ColorDialog();
+ AlphaColourDialog d=new AlphaColourDialog("Select shadow colour");
d.Color=m_color.BackColor;
- d.FullOpen=true;
if (d.ShowDialog()==DialogResult.OK)
{
diff --git a/GfxEditor.cs b/GfxEditor.cs index f5f002a..b78155a 100644 --- a/GfxEditor.cs +++ b/GfxEditor.cs @@ -35,7 +35,7 @@ namespace BitmapFontEd {
private System.Windows.Forms.Label m_fgPreview;
private System.Windows.Forms.ComboBox m_modeList;
- private System.Windows.Forms.PictureBox m_edit;
+ private System.Windows.Forms.Label m_recent8;
private System.Windows.Forms.Label m_recent1;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label m_recent4;
@@ -44,12 +44,14 @@ namespace BitmapFontEd private System.Windows.Forms.Label m_recent7;
private System.Windows.Forms.Label m_bgPreview;
private System.Windows.Forms.Label m_recent2;
- private System.Windows.Forms.NumericUpDown m_sizeY;
+ private System.Windows.Forms.Label m_recent3;
private System.Windows.Forms.PictureBox m_preview;
+ private System.Windows.Forms.NumericUpDown m_sizeY;
+ private System.Windows.Forms.Label m_gridCol;
+ private System.Windows.Forms.PictureBox m_edit;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label m_pos;
- private System.Windows.Forms.Label m_recent3;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Button m_undoButton;
@@ -61,7 +63,7 @@ namespace BitmapFontEd private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Label m_recent8;
+ private System.Windows.Forms.Label m_backCol;
public const int MAX_SIZE=32;
@@ -99,7 +101,6 @@ namespace BitmapFontEd private uint m_grid;
private uint m_mx;
private uint m_my;
- private Color m_gridCol;
private bool m_drawing;
private Mode m_mode;
@@ -128,10 +129,8 @@ namespace BitmapFontEd m_char=null;
m_grid=8;
- m_grid=8;
m_mx=SIZE;
m_my=SIZE;
- m_gridCol=Color.LightGreen;
m_editRect=m_edit.ClientRectangle;
m_editBmp=new Bitmap(m_editRect.Width,m_editRect.Height);
@@ -144,6 +143,8 @@ namespace BitmapFontEd m_drawing=false;
m_mode=Mode.ePlot;
+ m_bgPreview.BackColor=Color.FromArgb(0);
+
if (m_editRect.Width!=SIZE && m_editRect.Height!=SIZE)
{
throw new Exception("GfxEditor built with bad SIZE!");
@@ -165,7 +166,7 @@ namespace BitmapFontEd /// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
- this.m_recent8 = new System.Windows.Forms.Label();
+ this.m_backCol = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
@@ -177,12 +178,14 @@ namespace BitmapFontEd this.m_undoButton = new System.Windows.Forms.Button();
this.label15 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
- this.m_recent3 = new System.Windows.Forms.Label();
this.m_pos = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
- this.m_preview = new System.Windows.Forms.PictureBox();
+ this.m_edit = new System.Windows.Forms.PictureBox();
+ this.m_gridCol = new System.Windows.Forms.Label();
this.m_sizeY = new System.Windows.Forms.NumericUpDown();
+ this.m_preview = new System.Windows.Forms.PictureBox();
+ this.m_recent3 = new System.Windows.Forms.Label();
this.m_recent2 = new System.Windows.Forms.Label();
this.m_bgPreview = new System.Windows.Forms.Label();
this.m_recent7 = new System.Windows.Forms.Label();
@@ -191,22 +194,22 @@ namespace BitmapFontEd this.m_recent4 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.m_recent1 = new System.Windows.Forms.Label();
- this.m_edit = new System.Windows.Forms.PictureBox();
+ this.m_recent8 = new System.Windows.Forms.Label();
this.m_modeList = new System.Windows.Forms.ComboBox();
this.m_fgPreview = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.m_sizeX)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.m_sizeY)).BeginInit();
this.SuspendLayout();
//
- // m_recent8
+ // m_backCol
//
- this.m_recent8.BackColor = System.Drawing.Color.Black;
- this.m_recent8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.m_recent8.Location = new System.Drawing.Point(352, 272);
- this.m_recent8.Name = "m_recent8";
- this.m_recent8.Size = new System.Drawing.Size(16, 16);
- this.m_recent8.TabIndex = 32;
- this.m_recent8.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnRecent);
+ this.m_backCol.BackColor = System.Drawing.Color.Black;
+ this.m_backCol.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_backCol.Location = new System.Drawing.Point(168, 272);
+ this.m_backCol.Name = "m_backCol";
+ this.m_backCol.Size = new System.Drawing.Size(24, 24);
+ this.m_backCol.TabIndex = 34;
+ this.m_backCol.Click += new System.EventHandler(this.OnPaper);
//
// label4
//
@@ -260,7 +263,7 @@ namespace BitmapFontEd 0});
this.m_sizeX.Name = "m_sizeX";
this.m_sizeX.ReadOnly = true;
- this.m_sizeX.Size = new System.Drawing.Size(48, 21);
+ this.m_sizeX.Size = new System.Drawing.Size(48, 20);
this.m_sizeX.TabIndex = 19;
this.m_sizeX.Value = new System.Decimal(new int[] {
1,
@@ -320,21 +323,11 @@ namespace BitmapFontEd this.label14.Size = new System.Drawing.Size(16, 16);
this.label14.TabIndex = 29;
//
- // m_recent3
- //
- this.m_recent3.BackColor = System.Drawing.Color.Black;
- this.m_recent3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.m_recent3.Location = new System.Drawing.Point(328, 248);
- this.m_recent3.Name = "m_recent3";
- this.m_recent3.Size = new System.Drawing.Size(16, 16);
- this.m_recent3.TabIndex = 27;
- this.m_recent3.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnRecent);
- //
// m_pos
//
- this.m_pos.Location = new System.Drawing.Point(160, 272);
+ this.m_pos.Location = new System.Drawing.Point(208, 272);
this.m_pos.Name = "m_pos";
- this.m_pos.Size = new System.Drawing.Size(104, 24);
+ this.m_pos.Size = new System.Drawing.Size(56, 24);
this.m_pos.TabIndex = 23;
this.m_pos.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
@@ -354,14 +347,29 @@ namespace BitmapFontEd this.label12.Size = new System.Drawing.Size(16, 16);
this.label12.TabIndex = 31;
//
- // m_preview
+ // m_edit
//
- this.m_preview.BackColor = System.Drawing.SystemColors.Control;
- this.m_preview.Location = new System.Drawing.Point(288, 184);
- this.m_preview.Name = "m_preview";
- this.m_preview.Size = new System.Drawing.Size(34, 34);
- this.m_preview.TabIndex = 1;
- this.m_preview.TabStop = false;
+ this.m_edit.BackColor = System.Drawing.SystemColors.Control;
+ this.m_edit.Location = new System.Drawing.Point(8, 8);
+ this.m_edit.Name = "m_edit";
+ this.m_edit.Size = new System.Drawing.Size(256, 256);
+ this.m_edit.TabIndex = 0;
+ this.m_edit.TabStop = false;
+ this.m_edit.MouseEnter += new System.EventHandler(this.OnEnterEditor);
+ this.m_edit.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
+ this.m_edit.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
+ this.m_edit.MouseLeave += new System.EventHandler(this.OnLeaveEditor);
+ this.m_edit.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
+ //
+ // m_gridCol
+ //
+ this.m_gridCol.BackColor = System.Drawing.Color.Lime;
+ this.m_gridCol.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_gridCol.Location = new System.Drawing.Point(136, 272);
+ this.m_gridCol.Name = "m_gridCol";
+ this.m_gridCol.Size = new System.Drawing.Size(24, 24);
+ this.m_gridCol.TabIndex = 33;
+ this.m_gridCol.Click += new System.EventHandler(this.OnGrid);
//
// m_sizeY
//
@@ -379,7 +387,7 @@ namespace BitmapFontEd 0});
this.m_sizeY.Name = "m_sizeY";
this.m_sizeY.ReadOnly = true;
- this.m_sizeY.Size = new System.Drawing.Size(48, 21);
+ this.m_sizeY.Size = new System.Drawing.Size(48, 20);
this.m_sizeY.TabIndex = 20;
this.m_sizeY.Value = new System.Decimal(new int[] {
1,
@@ -389,6 +397,25 @@ namespace BitmapFontEd this.m_sizeY.ValueChanged += new System.EventHandler(this.OnSizeHeight);
this.m_sizeY.Leave += new System.EventHandler(this.OnSizeHeight);
//
+ // m_preview
+ //
+ this.m_preview.BackColor = System.Drawing.SystemColors.Control;
+ this.m_preview.Location = new System.Drawing.Point(288, 184);
+ this.m_preview.Name = "m_preview";
+ this.m_preview.Size = new System.Drawing.Size(34, 34);
+ this.m_preview.TabIndex = 1;
+ this.m_preview.TabStop = false;
+ //
+ // m_recent3
+ //
+ this.m_recent3.BackColor = System.Drawing.Color.Black;
+ this.m_recent3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_recent3.Location = new System.Drawing.Point(328, 248);
+ this.m_recent3.Name = "m_recent3";
+ this.m_recent3.Size = new System.Drawing.Size(16, 16);
+ this.m_recent3.TabIndex = 27;
+ this.m_recent3.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnRecent);
+ //
// m_recent2
//
this.m_recent2.BackColor = System.Drawing.Color.Black;
@@ -401,7 +428,7 @@ namespace BitmapFontEd //
// m_bgPreview
//
- this.m_bgPreview.BackColor = System.Drawing.Color.Black;
+ this.m_bgPreview.BackColor = System.Drawing.Color.Transparent;
this.m_bgPreview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.m_bgPreview.Location = new System.Drawing.Point(336, 112);
this.m_bgPreview.Name = "m_bgPreview";
@@ -467,19 +494,15 @@ namespace BitmapFontEd this.m_recent1.TabIndex = 25;
this.m_recent1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnRecent);
//
- // m_edit
+ // m_recent8
//
- this.m_edit.BackColor = System.Drawing.SystemColors.Control;
- this.m_edit.Location = new System.Drawing.Point(8, 8);
- this.m_edit.Name = "m_edit";
- this.m_edit.Size = new System.Drawing.Size(256, 256);
- this.m_edit.TabIndex = 0;
- this.m_edit.TabStop = false;
- this.m_edit.MouseEnter += new System.EventHandler(this.OnEnterEditor);
- this.m_edit.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
- this.m_edit.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
- this.m_edit.MouseLeave += new System.EventHandler(this.OnLeaveEditor);
- this.m_edit.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
+ this.m_recent8.BackColor = System.Drawing.Color.Black;
+ this.m_recent8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_recent8.Location = new System.Drawing.Point(352, 272);
+ this.m_recent8.Name = "m_recent8";
+ this.m_recent8.Size = new System.Drawing.Size(16, 16);
+ this.m_recent8.TabIndex = 32;
+ this.m_recent8.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnRecent);
//
// m_modeList
//
@@ -514,6 +537,8 @@ namespace BitmapFontEd //
// GfxEditor
//
+ this.Controls.Add(this.m_backCol);
+ this.Controls.Add(this.m_gridCol);
this.Controls.Add(this.m_recent8);
this.Controls.Add(this.m_recent7);
this.Controls.Add(this.m_recent6);
@@ -551,11 +576,6 @@ namespace BitmapFontEd // -------------------------------------------------------
#region Public Interfaces
- public Color GridColour
- {
- set {m_gridCol=value;}
- }
-
public uint CharWidth
{
get {return m_width;}
@@ -634,14 +654,14 @@ namespace BitmapFontEd private void DrawGrid()
{
Graphics g=Graphics.FromImage(m_prevBmp);
- Pen p=new Pen(m_gridCol);
+ Pen p=new Pen(m_gridCol.BackColor);
g.Clear(Color.Black);
Flush(ref g);
g=Graphics.FromImage(m_editBmp);
- g.Clear(Color.Black);
+ g.Clear(m_backCol.BackColor);
for(int x=0;x<m_width+1;x++)
{
@@ -659,6 +679,14 @@ namespace BitmapFontEd m_preview.Invalidate();
}
+ private void RedrawChar()
+ {
+ DrawGrid();
+ DrawChar();
+ }
+
+ // This could really do with some optimisations
+ //
private void DrawChar()
{
if (m_char==null)
@@ -668,7 +696,7 @@ namespace BitmapFontEd Graphics editg=Graphics.FromImage(m_editBmp);
Graphics prevg=Graphics.FromImage(m_prevBmp);
-
+
for(uint x=0;x<m_char.Width;x++)
for(uint y=0;y<m_char.Height;y++)
if (m_overlay[x,y]==TRANS)
@@ -678,19 +706,36 @@ namespace BitmapFontEd Flush(ref editg);
Flush(ref prevg);
-
+
m_edit.Invalidate();
+ m_edit.Update();
m_preview.Invalidate();
+ m_preview.Update();
}
private void CharPlot(Graphics edit, Graphics prev,
- uint x, uint y, Color c)
+ uint x, uint y, Color c)
{
- SolidBrush p=new SolidBrush(c);
+ if (m_prevBmp.GetPixel((int)x,(int)y)==c)
+ {
+ return;
+ }
+
+ SolidBrush p=new SolidBrush(m_backCol.BackColor);
+
+ uint gx=x*m_grid+1;
+ uint gy=y*m_grid+1;
+ uint gw=m_grid-1;
- edit.FillRectangle(p,x*m_grid+1,y*m_grid+1,m_grid-1,m_grid-1);
+ edit.FillRectangle(p,gx,gy,gw,gw);
+ prev.FillRectangle(p,1+x,1+y,1,1);
+
+ p=new SolidBrush(c);
+
+ edit.FillRectangle(p,gx,gy,gw,gw);
prev.FillRectangle(p,1+x,1+y,1,1);
}
+
#endregion
// -------------------------------------------------------
@@ -758,14 +803,14 @@ namespace BitmapFontEd for(uint x=x1;x<=x2;x++)
{
- m_overlay[x,y1]=m_gridCol;
- m_overlay[x,y2]=m_gridCol;
+ m_overlay[x,y1]=m_gridCol.BackColor;
+ m_overlay[x,y2]=m_gridCol.BackColor;
}
for(uint y=y1;y<=y2;y++)
{
- m_overlay[x1,y]=m_gridCol;
- m_overlay[x2,y]=m_gridCol;
+ m_overlay[x1,y]=m_gridCol.BackColor;
+ m_overlay[x2,y]=m_gridCol.BackColor;
}
}
@@ -1284,10 +1329,9 @@ namespace BitmapFontEd void OnForeground(object sender, System.EventArgs e)
{
- ColorDialog d=new ColorDialog();
+ AlphaColourDialog d=new AlphaColourDialog("Select Colour for Left Mouse Button");
d.Color=m_fgPreview.BackColor;
- d.FullOpen=true;
if (d.ShowDialog()==DialogResult.OK)
{
@@ -1298,10 +1342,9 @@ namespace BitmapFontEd void OnBackground(object sender, System.EventArgs e)
{
- ColorDialog d=new ColorDialog();
+ AlphaColourDialog d=new AlphaColourDialog("Select Colour for Right Mouse Button");
d.Color=m_bgPreview.BackColor;
- d.FullOpen=true;
if (d.ShowDialog()==DialogResult.OK)
{
@@ -1324,6 +1367,34 @@ namespace BitmapFontEd }
}
+ void OnGrid(object sender, System.EventArgs e)
+ {
+ AlphaColourDialog d=new AlphaColourDialog("Select Grid Colour");
+
+ d.AllowAlpha=false;
+ d.Color=m_gridCol.BackColor;
+
+ if (d.ShowDialog()==DialogResult.OK)
+ {
+ m_gridCol.BackColor=d.Color;
+ RedrawChar();
+ }
+ }
+
+ void OnPaper(object sender, System.EventArgs e)
+ {
+ AlphaColourDialog d=new AlphaColourDialog("Select Background Colour");
+
+ d.AllowAlpha=false;
+ d.Color=m_backCol.BackColor;
+
+ if (d.ShowDialog()==DialogResult.OK)
+ {
+ m_backCol.BackColor=d.Color;
+ RedrawChar();
+ }
+ }
+
#endregion
}
}
diff --git a/MainForm.cs b/MainForm.cs index efc34c5..6a48840 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -913,10 +913,9 @@ namespace BitmapFontEd void OnGlow(object sender, System.EventArgs e)
{
- ColorDialog d=new ColorDialog();
+ AlphaColourDialog d=new AlphaColourDialog("Select Glow Colour");
d.Color=m_glowCol;
- d.FullOpen=true;
if (d.ShowDialog()==DialogResult.OK)
{
@@ -944,31 +943,27 @@ namespace BitmapFontEd {
int x,y;
int mx,my;
- bool found;
-
- //System.Diagnostics.Debugger.Break();
c.Clear(m_edit.BackColor);
- found=false;
+ mx=Int32.MinValue;
+ my=Int32.MinValue;
- for(my=GfxEditor.MAX_SIZE-1;my>=0 && !found;my--)
- for(x=0;x<GfxEditor.MAX_SIZE && !found;x++)
- if (!Util.IsBlack(bmp.GetPixel(x,my)))
- found=true;
+ for(y=0;y<GfxEditor.MAX_SIZE;y++)
+ for(x=0;x<GfxEditor.MAX_SIZE;x++)
+ if (bmp.GetPixel(x,y).A!=0)
+ {
+ mx=Math.Max(mx,x);
+ my=Math.Max(my,y);
+ }
- if (!found)
+ if (mx==Int32.MinValue)
return;
- found=false;
-
- for(mx=GfxEditor.MAX_SIZE-1;mx>=0 && !found;mx--)
- for(y=0;y<GfxEditor.MAX_SIZE && !found;y++)
- if (!Util.IsBlack(bmp.GetPixel(mx,y)))
- found=true;
-
+ System.Diagnostics.Debug.WriteLine("(pre)mx="+mx+" my="+my);
mx=Math.Min(mx+1,GfxEditor.MAX_SIZE);
my=Math.Min(my+1,GfxEditor.MAX_SIZE);
+ System.Diagnostics.Debug.WriteLine("(post)mx="+mx+" my="+my);
c.Resize((uint)mx,(uint)my);
@@ -983,10 +978,9 @@ namespace BitmapFontEd if (fdlg.ShowDialog()==DialogResult.OK)
{
- ColorDialog coldlg=new ColorDialog();
+ AlphaColourDialog coldlg=new AlphaColourDialog("Font Colour");
coldlg.Color=Color.White;
- coldlg.FullOpen=true;
if (coldlg.ShowDialog()==DialogResult.OK)
{
@@ -995,6 +989,7 @@ namespace BitmapFontEd Bitmap bmp=new Bitmap(GfxEditor.MAX_SIZE,
GfxEditor.MAX_SIZE,
PixelFormat.Format32bppArgb);
+
SolidBrush b=new SolidBrush(coldlg.Color);
using (Graphics g=Graphics.FromImage(bmp))
@@ -1002,12 +997,14 @@ namespace BitmapFontEd for(byte ascii=33;ascii<127;ascii++)
{
string s=Encoding.ASCII.GetString(new byte[] {ascii});
- g.Clear(Color.Black);
+ g.Clear(Color.Transparent);
g.DrawString(s,fdlg.Font,b,0,0);
- g.Flush();
+ g.Flush(FlushIntention.Sync);
GrabChar(bmp,m_chars[ascii-32]);
}
}
+
+ m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]);
}
catch (Exception ex)
{
@@ -53,11 +53,6 @@ namespace BitmapFontEd MessageBoxButtons.OK,MessageBoxIcon.Information);
}
- public static bool IsBlack(Color c)
- {
- return c.R==0 && c.G==0 && c.B==0;
- }
-
public static uint ReadUint(Stream str)
{
uint l=0;
|