Basic export text generation done.
This commit is contained in:
@@ -11,8 +11,13 @@ using System.Windows.Forms;
|
||||
|
||||
namespace McBitFont {
|
||||
public partial class Export : Form {
|
||||
public Export() {
|
||||
|
||||
private MainForm mainForm;
|
||||
|
||||
public Export(object sender) {
|
||||
InitializeComponent();
|
||||
|
||||
mainForm = (MainForm)sender;
|
||||
}
|
||||
|
||||
private void Export_Load(object sender, EventArgs e) {
|
||||
@@ -82,6 +87,133 @@ namespace McBitFont {
|
||||
}
|
||||
|
||||
private void btnGenerate_Click(object sender, EventArgs e) {
|
||||
txtOutput.Clear();
|
||||
|
||||
int imin, jmin, imax, jmax, idir, jdir;
|
||||
if (cbOrder.SelectedIndex == 0) {
|
||||
if (cbHDir.SelectedIndex == 0) {
|
||||
// Columns; Left to right
|
||||
imin = 0;
|
||||
imax = mainForm.dotWidth;
|
||||
idir = 1;
|
||||
} else {
|
||||
// Columns; Right to left
|
||||
imin = mainForm.dotWidth - 1;
|
||||
imax = -1;
|
||||
idir = -1;
|
||||
}
|
||||
if (cbVDir.SelectedIndex == 0) {
|
||||
// Columns; Top to bottom
|
||||
jmin = 0;
|
||||
jmax = mainForm.dotHeight;
|
||||
jdir = 1;
|
||||
} else {
|
||||
// Columns; Bottom to top
|
||||
jmin = mainForm.dotHeight - 1;
|
||||
jmax = -1;
|
||||
jdir = -1;
|
||||
}
|
||||
} else {
|
||||
if (cbHDir.SelectedIndex == 0) {
|
||||
// Rows; Left to right
|
||||
jmin = 0;
|
||||
jmax = mainForm.dotHeight;
|
||||
jdir = 1;
|
||||
} else {
|
||||
// Rows; Right to left
|
||||
jmin = mainForm.dotHeight - 1;
|
||||
jmax = -1;
|
||||
jdir = -1;
|
||||
}
|
||||
if (cbVDir.SelectedIndex == 0) {
|
||||
// Rows; Top to bottom
|
||||
imin = 0;
|
||||
imax = mainForm.dotWidth;
|
||||
idir = 1;
|
||||
} else {
|
||||
// Rows; Bottom to top
|
||||
imin = mainForm.dotWidth - 1;
|
||||
imax = -1;
|
||||
idir = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ushort bits = 8;
|
||||
switch (cbNumSize.SelectedIndex) {
|
||||
case 0:
|
||||
bits = 8;
|
||||
break;
|
||||
case 1:
|
||||
bits = 16;
|
||||
break;
|
||||
case 2:
|
||||
bits = 32;
|
||||
break;
|
||||
}
|
||||
|
||||
int nbase = 16;
|
||||
string prefix = "0x";
|
||||
string pref = "";
|
||||
int pad = 2;
|
||||
switch (cbNumBase.SelectedIndex) {
|
||||
case 0:
|
||||
nbase = 16;
|
||||
prefix = "0x";
|
||||
pad = cbZeroes.Checked ? bits / 4 : 0;
|
||||
break;
|
||||
case 1:
|
||||
nbase = 2;
|
||||
prefix = "0b";
|
||||
pad = cbZeroes.Checked ? bits : 0;
|
||||
break;
|
||||
case 2:
|
||||
nbase = 10;
|
||||
prefix = "";
|
||||
pad = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ( MainForm.FrameMiniature f in mainForm.frames) {
|
||||
// For each frame
|
||||
string str;
|
||||
uint b = 0;
|
||||
int t, x, y;
|
||||
for (int i = imin; i != imax; i += idir) {
|
||||
str = "";
|
||||
for (int j = jmin; j != jmax; j += jdir) {
|
||||
if (jdir < 0) t = jmin - j;
|
||||
else t = j;
|
||||
if (t % bits == 0) b = 0;
|
||||
|
||||
if (cbOrder.SelectedIndex == 0) { // Columns
|
||||
x = i; y = j;
|
||||
} else { // Rows
|
||||
x = j; y = i;
|
||||
}
|
||||
|
||||
if (f.data[x, y]) {
|
||||
if ((cbBitOrder.SelectedIndex == 0 && jdir > 0) || (cbBitOrder.SelectedIndex == 1 && jdir < 0)) {
|
||||
// LSB on top/Left
|
||||
b |= (uint)(1 << (t % bits));
|
||||
} else {
|
||||
// MSB on top/Left
|
||||
b |= (uint)(1 << (bits - (t % bits) - 1));
|
||||
}
|
||||
|
||||
}
|
||||
if (((t + 1) % bits == 0) || j + jdir == jmax) {
|
||||
if (str.Length > 0) str += " ";
|
||||
pref = (!cbZeroes.Checked && ((b < 10 && nbase == 16) || (b < 2 && nbase == 2))) ? "" : prefix;
|
||||
str += pref + Convert.ToString(b, nbase).PadLeft(pad, '0') + ',';
|
||||
}
|
||||
}
|
||||
txtOutput.AppendText(str);
|
||||
txtOutput.AppendText(Environment.NewLine);
|
||||
}
|
||||
txtOutput.AppendText(Environment.NewLine);
|
||||
}
|
||||
|
||||
txtOutput.SelectAll();
|
||||
ParseText();
|
||||
}
|
||||
|
Reference in New Issue
Block a user