12 Commits

Author SHA1 Message Date
e5a4baadb7 Merge branch 'dev' - v2.8
Changes:

Functionality:
- Screensot a frame function
- Frame note field to store a frame description
2025-07-03 01:13:05 +03:00
37abcf2c8e TODO feature: Frame note field to store a frame description 2025-07-03 01:03:12 +03:00
2c2a8d6158 Update examples 2025-07-02 23:58:54 +03:00
Anton Mukhin
4115455a54 TODO feature: Screensot a frame function 2025-07-02 20:06:14 +03:00
67be566605 Main window screenshot update 2025-07-01 00:29:39 +03:00
7aa75224ee Merge branch 'dev' - v2.7
Changes:

Application:
- Cursor for rectangular selection tool
- Icons for tool buttons
- Tooltips now has keyboard shortcuts info

Bugs:
- Fix selection info: change comma to x

Other:
- Examples update
- C library example
2025-07-01 00:09:23 +03:00
4fe2af03b0 TODO features:
V Cursor for rectangular selection tool
V Icons for tool buttons
V Tooltips now has keyboard shortcuts info

V Fix selection info: change comma to x
2025-07-01 00:07:01 +03:00
Anton Mukhin
fc4822065a mctext library fix 2025-06-27 12:45:31 +03:00
Anton Mukhin
3778a753fb Update TODO 2025-06-27 12:18:27 +03:00
Anton Mukhin
20bd7095dd mctext.c library fix 2025-06-26 14:42:19 +03:00
8ed1e33f22 Alagard 9x17 font finished 2025-06-25 02:00:28 +03:00
Anton Mukhin
1eb463c94f STM32 HAL library example 2025-06-23 12:31:24 +03:00
18 changed files with 632 additions and 56 deletions

View File

@@ -34,6 +34,7 @@
cbZoom = new System.Windows.Forms.ComboBox();
label4 = new System.Windows.Forms.Label();
panel1 = new System.Windows.Forms.Panel();
tbFrameNote = new System.Windows.Forms.TextBox();
btnFill = new System.Windows.Forms.Button();
btnClear = new System.Windows.Forms.Button();
btnMirrorY = new System.Windows.Forms.Button();
@@ -69,6 +70,7 @@
importImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
exportFontLayoutPNGToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
frameScreenshotToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -214,7 +216,7 @@
cbZoom.Size = new System.Drawing.Size(75, 23);
cbZoom.TabIndex = 6;
cbZoom.TabStop = false;
toolTip1.SetToolTip(cbZoom, "Canvas zoom level");
toolTip1.SetToolTip(cbZoom, "Canvas zoom level (Ctrl+Scroll)");
//
// label4
//
@@ -230,7 +232,7 @@
// panel1
//
panel1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
panel1.Controls.Add(tbFrameNote);
panel1.Controls.Add(btnFill);
panel1.Controls.Add(btnClear);
panel1.Controls.Add(btnMirrorY);
@@ -240,47 +242,58 @@
panel1.Controls.Add(btnShiftUp);
panel1.Controls.Add(btnShiftRight);
panel1.Controls.Add(btnShiftLeft);
panel1.Location = new System.Drawing.Point(472, 31);
panel1.Location = new System.Drawing.Point(472, 24);
panel1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
panel1.Name = "panel1";
panel1.Size = new System.Drawing.Size(140, 139);
panel1.Size = new System.Drawing.Size(140, 154);
panel1.TabIndex = 9;
//
// tbFrameNote
//
tbFrameNote.Location = new System.Drawing.Point(7, 127);
tbFrameNote.Name = "tbFrameNote";
tbFrameNote.PlaceholderText = "Frame note";
tbFrameNote.Size = new System.Drawing.Size(119, 23);
tbFrameNote.TabIndex = 9;
toolTip1.SetToolTip(tbFrameNote, "Frame note");
tbFrameNote.WordWrap = false;
tbFrameNote.TextChanged += tbFrameNote_TextChanged;
//
// btnFill
//
btnFill.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204);
btnFill.Location = new System.Drawing.Point(92, 9);
btnFill.Image = Properties.Resources.Canvas_Fill;
btnFill.Location = new System.Drawing.Point(91, 3);
btnFill.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnFill.Name = "btnFill";
btnFill.Size = new System.Drawing.Size(35, 35);
btnFill.TabIndex = 8;
btnFill.Text = "⬤";
toolTip1.SetToolTip(btnFill, "Paint canvas black");
toolTip1.SetToolTip(btnFill, "Paint canvas black (Ctrl+B)");
btnFill.UseVisualStyleBackColor = true;
btnFill.Click += btnFill_Click;
//
// btnClear
//
btnClear.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204);
btnClear.Location = new System.Drawing.Point(8, 9);
btnClear.Image = Properties.Resources.Canvas_Clear;
btnClear.Location = new System.Drawing.Point(7, 3);
btnClear.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnClear.Name = "btnClear";
btnClear.Size = new System.Drawing.Size(35, 35);
btnClear.TabIndex = 7;
btnClear.Text = "○";
toolTip1.SetToolTip(btnClear, "Paint canvas white");
toolTip1.SetToolTip(btnClear, "Paint canvas white (Ctrl+W)");
btnClear.UseVisualStyleBackColor = true;
btnClear.Click += btnClear_Click;
//
// btnMirrorY
//
btnMirrorY.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204);
btnMirrorY.Location = new System.Drawing.Point(92, 92);
btnMirrorY.Image = Properties.Resources.Famfamfam_Silk_Shape_flip_vertical_16;
btnMirrorY.Location = new System.Drawing.Point(91, 86);
btnMirrorY.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnMirrorY.Name = "btnMirrorY";
btnMirrorY.Size = new System.Drawing.Size(35, 35);
btnMirrorY.TabIndex = 6;
btnMirrorY.Text = "⩥";
toolTip1.SetToolTip(btnMirrorY, "Mirror by Y axis (vertical)");
btnMirrorY.UseVisualStyleBackColor = true;
btnMirrorY.Click += btnMirrorY_Click;
@@ -288,12 +301,12 @@
// btnMirrorX
//
btnMirrorX.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204);
btnMirrorX.Location = new System.Drawing.Point(50, 92);
btnMirrorX.Image = Properties.Resources.Famfamfam_Silk_Shape_flip_horizontal_16;
btnMirrorX.Location = new System.Drawing.Point(49, 86);
btnMirrorX.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnMirrorX.Name = "btnMirrorX";
btnMirrorX.Size = new System.Drawing.Size(35, 35);
btnMirrorX.TabIndex = 5;
btnMirrorX.Text = "◮";
toolTip1.SetToolTip(btnMirrorX, "Mirror by X axis (horizontal)");
btnMirrorX.UseVisualStyleBackColor = true;
btnMirrorX.Click += btnMirrorX_Click;
@@ -301,65 +314,65 @@
// btnInvert
//
btnInvert.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204);
btnInvert.Location = new System.Drawing.Point(8, 92);
btnInvert.Image = Properties.Resources.z_contrast;
btnInvert.Location = new System.Drawing.Point(7, 86);
btnInvert.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnInvert.Name = "btnInvert";
btnInvert.Size = new System.Drawing.Size(35, 35);
btnInvert.TabIndex = 4;
btnInvert.Text = "◪";
toolTip1.SetToolTip(btnInvert, "Invert pixel colors");
toolTip1.SetToolTip(btnInvert, "Invert pixel colors (Ctrl+I)");
btnInvert.UseVisualStyleBackColor = true;
btnInvert.Click += btnInvert_Click;
//
// btnShiftDown
//
btnShiftDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204);
btnShiftDown.Location = new System.Drawing.Point(50, 51);
btnShiftDown.Image = Properties.Resources.z_down;
btnShiftDown.Location = new System.Drawing.Point(49, 45);
btnShiftDown.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnShiftDown.Name = "btnShiftDown";
btnShiftDown.Size = new System.Drawing.Size(35, 35);
btnShiftDown.TabIndex = 3;
btnShiftDown.Text = "▼";
toolTip1.SetToolTip(btnShiftDown, "Shift pixels down");
toolTip1.SetToolTip(btnShiftDown, "Shift pixels down (Ctrl+Down)");
btnShiftDown.UseVisualStyleBackColor = true;
btnShiftDown.Click += btnShiftDown_Click;
//
// btnShiftUp
//
btnShiftUp.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204);
btnShiftUp.Location = new System.Drawing.Point(50, 9);
btnShiftUp.Image = Properties.Resources.z_uo;
btnShiftUp.Location = new System.Drawing.Point(49, 3);
btnShiftUp.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnShiftUp.Name = "btnShiftUp";
btnShiftUp.Size = new System.Drawing.Size(35, 35);
btnShiftUp.TabIndex = 2;
btnShiftUp.Text = "▲";
toolTip1.SetToolTip(btnShiftUp, "Shift pixels up");
toolTip1.SetToolTip(btnShiftUp, "Shift pixels up (Ctrl+Up)");
btnShiftUp.UseVisualStyleBackColor = true;
btnShiftUp.Click += btnShiftUp_Click;
//
// btnShiftRight
//
btnShiftRight.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204);
btnShiftRight.Location = new System.Drawing.Point(92, 51);
btnShiftRight.Image = Properties.Resources.z_right;
btnShiftRight.Location = new System.Drawing.Point(91, 45);
btnShiftRight.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnShiftRight.Name = "btnShiftRight";
btnShiftRight.Size = new System.Drawing.Size(35, 35);
btnShiftRight.TabIndex = 1;
btnShiftRight.Text = "▶";
toolTip1.SetToolTip(btnShiftRight, "Shift pixels right");
toolTip1.SetToolTip(btnShiftRight, "Shift pixels right (Ctrl+Right)");
btnShiftRight.UseVisualStyleBackColor = true;
btnShiftRight.Click += btnShiftRight_Click;
//
// btnShiftLeft
//
btnShiftLeft.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204);
btnShiftLeft.Location = new System.Drawing.Point(8, 51);
btnShiftLeft.Image = Properties.Resources.z_left;
btnShiftLeft.Location = new System.Drawing.Point(7, 45);
btnShiftLeft.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnShiftLeft.Name = "btnShiftLeft";
btnShiftLeft.Size = new System.Drawing.Size(35, 35);
btnShiftLeft.TabIndex = 0;
btnShiftLeft.Text = "◀";
toolTip1.SetToolTip(btnShiftLeft, "Shift pixels left");
toolTip1.SetToolTip(btnShiftLeft, "Shift pixels left (Ctrl+Left)");
btnShiftLeft.UseVisualStyleBackColor = true;
btnShiftLeft.Click += btnShiftLeft_Click;
//
@@ -374,7 +387,7 @@
btnExport.Text = " Export";
btnExport.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
btnExport.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
toolTip1.SetToolTip(btnExport, "Configure and export data");
toolTip1.SetToolTip(btnExport, "Configure and export data (Ctrl+E)");
btnExport.UseVisualStyleBackColor = true;
btnExport.Click += Export_Click;
//
@@ -391,6 +404,7 @@
miniList.MultiSelect = false;
miniList.Name = "miniList";
miniList.ShowGroups = false;
miniList.ShowItemToolTips = true;
miniList.Size = new System.Drawing.Size(427, 455);
miniList.SmallImageList = ilMiniatures;
miniList.Sorting = System.Windows.Forms.SortOrder.Ascending;
@@ -491,7 +505,7 @@
btnApply.Text = " Apply";
btnApply.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
btnApply.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
toolTip1.SetToolTip(btnApply, "Apply changes made to the symbol");
toolTip1.SetToolTip(btnApply, "Apply changes made to the symbol (Ctrl+Space)");
btnApply.UseVisualStyleBackColor = true;
btnApply.Click += button2_Click;
//
@@ -543,7 +557,7 @@
//
// fileToolStripMenuItem
//
fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { newToolStripMenuItem, openToolStripMenuItem, saveToolStripMenuItem, saveAsToolStripMenuItem, toolStripSeparator1, importTextToolStripMenuItem1, importImageToolStripMenuItem, exportToolStripMenuItem, exportFontLayoutPNGToolStripMenuItem, toolStripSeparator2, exitToolStripMenuItem });
fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { newToolStripMenuItem, openToolStripMenuItem, saveToolStripMenuItem, saveAsToolStripMenuItem, toolStripSeparator1, importTextToolStripMenuItem1, importImageToolStripMenuItem, exportToolStripMenuItem, exportFontLayoutPNGToolStripMenuItem, frameScreenshotToolStripMenuItem, toolStripSeparator2, exitToolStripMenuItem });
fileToolStripMenuItem.Name = "fileToolStripMenuItem";
fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
fileToolStripMenuItem.Text = "File";
@@ -635,6 +649,16 @@
exportFontLayoutPNGToolStripMenuItem.ToolTipText = "Create an image with all a table showing all 256 symbols";
exportFontLayoutPNGToolStripMenuItem.Click += ExportPNG;
//
// frameScreenshotToolStripMenuItem
//
frameScreenshotToolStripMenuItem.Image = Properties.Resources.picture_go;
frameScreenshotToolStripMenuItem.Name = "frameScreenshotToolStripMenuItem";
frameScreenshotToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P;
frameScreenshotToolStripMenuItem.Size = new System.Drawing.Size(224, 22);
frameScreenshotToolStripMenuItem.Text = "Frame Screenshot";
frameScreenshotToolStripMenuItem.ToolTipText = "Make a screenshot of the current frame";
frameScreenshotToolStripMenuItem.Click += frameScreenshotToolStripMenuItem_Click;
//
// toolStripSeparator2
//
toolStripSeparator2.Name = "toolStripSeparator2";
@@ -1065,7 +1089,7 @@
chkRectSelect.Text = " Select";
chkRectSelect.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
chkRectSelect.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
toolTip1.SetToolTip(chkRectSelect, "Turn on/off rectangle selection");
toolTip1.SetToolTip(chkRectSelect, "Turn on/off rectangle selection (Ctrl+R)");
chkRectSelect.UseVisualStyleBackColor = true;
chkRectSelect.CheckedChanged += chkRectSelect_CheckedChanged;
//
@@ -1078,7 +1102,7 @@
nudBrush.Name = "nudBrush";
nudBrush.Size = new System.Drawing.Size(47, 23);
nudBrush.TabIndex = 24;
toolTip1.SetToolTip(nudBrush, "Symbol height");
toolTip1.SetToolTip(nudBrush, "Symbol height (Alt+Scroll)");
nudBrush.Value = new decimal(new int[] { 1, 0, 0, 0 });
nudBrush.ValueChanged += nudBrush_ValueChanged;
//
@@ -1110,9 +1134,9 @@
lblSelection.Location = new System.Drawing.Point(5, 84);
lblSelection.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
lblSelection.Name = "lblSelection";
lblSelection.Size = new System.Drawing.Size(30, 15);
lblSelection.Size = new System.Drawing.Size(32, 15);
lblSelection.TabIndex = 24;
lblSelection.Text = "W,H";
lblSelection.Text = "WxH";
lblSelection.TextAlign = System.Drawing.ContentAlignment.TopRight;
lblSelection.Visible = false;
//
@@ -1208,6 +1232,7 @@
((System.ComponentModel.ISupportInitialize)nudX).EndInit();
((System.ComponentModel.ISupportInitialize)nudY).EndInit();
panel1.ResumeLayout(false);
panel1.PerformLayout();
cmMinilist.ResumeLayout(false);
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
@@ -1320,6 +1345,8 @@
private System.Windows.Forms.ToolStripMenuItem zerofyWidthToolStripMenuItem;
public System.Windows.Forms.NumericUpDown nudBrush;
private System.Windows.Forms.Label lblBrush;
private System.Windows.Forms.ToolStripMenuItem frameScreenshotToolStripMenuItem;
private System.Windows.Forms.TextBox tbFrameNote;
}
}

View File

@@ -18,11 +18,12 @@ namespace McBitFont {
[Serializable]
[MessagePackObject]
public struct FrameMiniature {
public FrameMiniature(int cc, int ww, int hh) {
public FrameMiniature(int cc, int ww, int hh, string frameNote = "") {
code = cc;
width = ww;
height = hh;
data = new bool[ww, hh];
note = frameNote;
}
[Key(0)]
public int code;
@@ -32,6 +33,8 @@ namespace McBitFont {
public int height;
[Key(3)]
public bool[,] data;
[Key(8)]
public string note;
};
[Serializable]
@@ -59,7 +62,7 @@ namespace McBitFont {
public bool monospaced = false;
private bool modified = false;
private bool prjModified = false;
public const string version = "2.6";
public const string version = "2.8";
public string prjName = "Untitled";
public string prjFileName = "";
public int codepage = 1251;
@@ -83,7 +86,7 @@ namespace McBitFont {
}
private void UpdateSelectionLabel(int width, int height) {
lblSelection.Text = width.ToString() + ',' + height.ToString();
lblSelection.Text = width.ToString() + 'x' + height.ToString();
}
public void SetModified(bool modif = true, bool prj = false) {
@@ -112,12 +115,12 @@ namespace McBitFont {
// Remember sidebar panels locations
private void SideBarRecalc() {
sidebarLocs[0, 0] = new Point(this.Width - 459, 31);
sidebarLocs[0, 1] = new Point(this.Width - 316, 24);
sidebarLocs[0, 2] = new Point(this.Width - 487, 31);
sidebarLocs[1, 0] = new Point(this.Width - panel1.Width - 70, 180);
sidebarLocs[1, 1] = new Point(this.Width - pnlInfo.Width - 110, 320);
sidebarLocs[1, 2] = new Point(dotPanel.Width + 17, 31);
sidebarLocs[0, 0] = new Point(this.Width - 459, 24); // tool panel
sidebarLocs[0, 1] = new Point(this.Width - 316, 24); // info panel
sidebarLocs[0, 2] = new Point(this.Width - 487, 31); // vertical scroll
sidebarLocs[1, 0] = new Point(this.Width - panel1.Width - 70, 180); // tool panel
sidebarLocs[1, 1] = new Point(this.Width - pnlInfo.Width - 110, 340); // info panel
sidebarLocs[1, 2] = new Point(dotPanel.Width + 17, 31); // vertical scroll
}
@@ -191,8 +194,10 @@ namespace McBitFont {
for (int j = 0; j <= selection2.Y - selection1.Y; j++) {
ff.data[i, j] = frame.data[i + selection1.X, j + selection1.Y];
}
} else
} else {
Array.Copy(frame.data, ff.data, frame.data.Length);
ff.note = frame.note;
}
return ff;
}
@@ -346,7 +351,7 @@ namespace McBitFont {
vScroll.Enabled = true;
}
dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap);
if (!chkRectSelect.Checked) dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap);
dotPanel.Refresh();
}
@@ -621,7 +626,7 @@ namespace McBitFont {
SetModified();
changed = true;
}
}
}
return changed;
@@ -717,6 +722,7 @@ namespace McBitFont {
string s = f.code.ToString().PadLeft(3, '0');
ilMiniatures.Images.RemoveByKey(s);
ilMiniatures.Images.Add(s, (Image)sizedBMP);
miniList.Items[miniList.Items.IndexOfKey(s)].ToolTipText = f.note;
sizedBMP.Dispose();
SetModified(false);
SetModified(true, true);
@@ -935,6 +941,7 @@ namespace McBitFont {
nudX.Value = ff.width;
nudY.Value = ff.height;
f = ff;
tbFrameNote.Text = ff.note;
history.Add(code);
@@ -983,7 +990,7 @@ namespace McBitFont {
var sHex = 'x' + Convert.ToString(f.code, 16).PadLeft(2, '0').ToUpper();
var sss = DecodeSymbol(f.code);
ilMiniatures.Images.Add(s, (Image)GetMiniPictue(f));
miniList.Items.Add(s, (chkHexCodes.Checked ? sHex : s) + ' ' + sss, s);
miniList.Items.Add(s, (chkHexCodes.Checked ? sHex : s) + ' ' + sss, s).ToolTipText = f.note;
}
}
@@ -1015,10 +1022,9 @@ namespace McBitFont {
nudX.ValueChanged += nudX_ValueChanged;
nudY.ValueChanged += nudY_ValueChanged;
f = CopyFrame(frames.First());
tbFrameNote.Text = frames.First().note;
dotPanel.Refresh();
miniList.Refresh();
SetModified(false);
SetModified(false, true);
prjFileName = filename;
prjName = Path.GetFileNameWithoutExtension(filename);
@@ -1037,6 +1043,8 @@ namespace McBitFont {
zerofyWidthToolStripMenuItem.Enabled = !monospaced;
tsmiCodeShift.Visible = frames.Count > 1;
CodeShiftToolStripMenuItem.Visible = frames.Count > 1;
SetModified(false);
SetModified(false, true);
Cursor.Current = Cursors.Default;
}
@@ -1394,6 +1402,10 @@ namespace McBitFont {
private void chkRectSelect_CheckedChanged(object sender, EventArgs e) {
lblSelection.Visible = lblSelectionLabel.Visible = chkRectSelect.Checked;
selectAllToolStripMenuItem.Enabled = chkRectSelect.Checked;
if (chkRectSelect.Checked) dotPanel.Cursor = McCursor.GetCursorSelect();
else dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap);
dotPanel.Refresh();
}
@@ -1688,7 +1700,20 @@ namespace McBitFont {
}
private void nudBrush_ValueChanged(object sender, EventArgs e) {
dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap);
if (!chkRectSelect.Checked) dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap);
}
private void frameScreenshotToolStripMenuItem_Click(object sender, EventArgs e) {
FrameScreenshot iform = new(f);
iform.ShowDialog();
iform.Dispose();
}
private void tbFrameNote_TextChanged(object sender, EventArgs e) {
if (tbFrameNote.Focused) {
f.note = tbFrameNote.Text;
SetModified();
}
}
}
}

147
McBitFont/FrameScreenshot.Designer.cs generated Normal file
View File

@@ -0,0 +1,147 @@
namespace McBitFont {
partial class FrameScreenshot {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
components = new System.ComponentModel.Container();
btnClose = new System.Windows.Forms.Button();
btnOK = new System.Windows.Forms.Button();
toolTip1 = new System.Windows.Forms.ToolTip(components);
nudUpscale = new System.Windows.Forms.NumericUpDown();
chkTransparent = new System.Windows.Forms.CheckBox();
dlgSaveImage = new System.Windows.Forms.SaveFileDialog();
lblUpscale = new System.Windows.Forms.Label();
chkBlackBG = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)nudUpscale).BeginInit();
SuspendLayout();
//
// btnClose
//
btnClose.Location = new System.Drawing.Point(144, 67);
btnClose.Name = "btnClose";
btnClose.Size = new System.Drawing.Size(88, 27);
btnClose.TabIndex = 3;
btnClose.Text = "Close";
btnClose.UseVisualStyleBackColor = true;
btnClose.Click += btnClose_Click;
//
// btnOK
//
btnOK.Location = new System.Drawing.Point(12, 67);
btnOK.Name = "btnOK";
btnOK.Size = new System.Drawing.Size(88, 27);
btnOK.TabIndex = 1;
btnOK.Text = "Save";
btnOK.UseVisualStyleBackColor = true;
btnOK.Click += btnOK_Click;
//
// toolTip1
//
toolTip1.AutoPopDelay = 10000;
toolTip1.InitialDelay = 500;
toolTip1.ReshowDelay = 100;
//
// nudUpscale
//
nudUpscale.Location = new System.Drawing.Point(12, 27);
nudUpscale.Maximum = new decimal(new int[] { 255, 0, 0, 0 });
nudUpscale.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
nudUpscale.Name = "nudUpscale";
nudUpscale.Size = new System.Drawing.Size(51, 23);
nudUpscale.TabIndex = 2;
toolTip1.SetToolTip(nudUpscale, "Pixel upscale factor (4 means that for each frame pixel there will be 4x4 pixels generated)");
nudUpscale.Value = new decimal(new int[] { 4, 0, 0, 0 });
//
// chkTransparent
//
chkTransparent.AutoSize = true;
chkTransparent.Location = new System.Drawing.Point(85, 18);
chkTransparent.Name = "chkTransparent";
chkTransparent.Size = new System.Drawing.Size(155, 19);
chkTransparent.TabIndex = 5;
chkTransparent.Text = "Transparent background";
toolTip1.SetToolTip(chkTransparent, "Make background transparent");
chkTransparent.UseVisualStyleBackColor = true;
chkTransparent.CheckedChanged += chkTransparent_CheckedChanged;
//
// dlgSaveImage
//
dlgSaveImage.DefaultExt = "png";
dlgSaveImage.Filter = "PNG Image|*.png;*.PNG";
//
// lblUpscale
//
lblUpscale.AutoSize = true;
lblUpscale.Location = new System.Drawing.Point(12, 9);
lblUpscale.Name = "lblUpscale";
lblUpscale.Size = new System.Drawing.Size(51, 15);
lblUpscale.TabIndex = 4;
lblUpscale.Text = "Upscale:";
//
// chkBlackBG
//
chkBlackBG.AutoSize = true;
chkBlackBG.Enabled = false;
chkBlackBG.Location = new System.Drawing.Point(85, 35);
chkBlackBG.Name = "chkBlackBG";
chkBlackBG.Size = new System.Drawing.Size(132, 19);
chkBlackBG.TabIndex = 6;
chkBlackBG.Text = "Background is black";
toolTip1.SetToolTip(chkBlackBG, "White color is considered as background by default. Check this to invert that");
chkBlackBG.UseVisualStyleBackColor = true;
//
// FrameScreenshot
//
AcceptButton = btnClose;
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
CancelButton = btnClose;
ClientSize = new System.Drawing.Size(244, 111);
Controls.Add(chkBlackBG);
Controls.Add(chkTransparent);
Controls.Add(nudUpscale);
Controls.Add(lblUpscale);
Controls.Add(btnClose);
Controls.Add(btnOK);
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
Name = "FrameScreenshot";
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
Text = "Frame Screenshot";
Load += FrameScreenshot_Load;
((System.ComponentModel.ISupportInitialize)nudUpscale).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.SaveFileDialog dlgSaveImage;
private System.Windows.Forms.Label lblUpscale;
private System.Windows.Forms.NumericUpDown nudUpscale;
private System.Windows.Forms.CheckBox chkTransparent;
private System.Windows.Forms.CheckBox chkBlackBG;
}
}

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static McBitFont.MainForm;
namespace McBitFont {
public partial class FrameScreenshot : Form {
private FrameMiniature f;
public FrameScreenshot(FrameMiniature frame) {
InitializeComponent();
f = frame;
}
private void btnOK_Click(object sender, EventArgs e) {
if (dlgSaveImage.ShowDialog() == DialogResult.OK) {
int upscale = (int)nudUpscale.Value;
int x, y;
bool transp = chkTransparent.Checked;
bool blackBG = chkBlackBG.Checked;
Bitmap bmp = new(f.width * upscale, f.height * upscale);
SolidBrush bb = new(Color.Black);
SolidBrush bw = new(Color.White);
using (Graphics g = Graphics.FromImage(bmp)) {
for (x = 0; x < f.width; x++) {
for (y = 0; y < f.height; y++) {
if (f.data[x, y]) {
if (!transp || (transp && !blackBG)) g.FillRectangle(bb, x * upscale, y * upscale, upscale, upscale);
} else
if (!transp || (transp && blackBG)) g.FillRectangle(bw, x * upscale, y * upscale, upscale, upscale);
}
}
}
bool err = false;
try {
bmp.Save(dlgSaveImage.FileName, ImageFormat.Png);
}
catch (Exception ex) {
err = true;
MessageBox.Show("There was an error during image save: " + ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
if (!err) MessageBox.Show("Screenshot has been saved!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void FrameScreenshot_Load(object sender, EventArgs e) {
btnOK.Focus();
}
private void btnClose_Click(object sender, EventArgs e) {
DialogResult = DialogResult.OK;
}
private void chkTransparent_CheckedChanged(object sender, EventArgs e) {
chkBlackBG.Enabled = chkTransparent.Checked;
}
}
}

View File

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="dlgSaveImage.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>115, 17</value>
</metadata>
</root>

View File

@@ -20,9 +20,9 @@
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<ApplicationIcon>icon_64.ico</ApplicationIcon>
<AssemblyVersion>2.6.0.0</AssemblyVersion>
<FileVersion>2.6.0.0</FileVersion>
<Version>$(VersionPrefix)2.6.0</Version>
<AssemblyVersion>2.8.0.0</AssemblyVersion>
<FileVersion>2.8.0.0</FileVersion>
<Version>$(VersionPrefix)2.8.0</Version>
<Copyright>Anton Mukhin</Copyright>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@@ -4,6 +4,7 @@ using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
@@ -101,5 +102,30 @@ namespace McBitFont {
return CreateCursorNoResize(bmp, cellSize / 2, cellSize / 2);
}
public static Cursor GetCursorSelect() {
Point[] arrow = { new(1, 1), new(12, 12), new(11, 13), new(6, 13), new(2, 17), new(1, 16) };
Point[] corner1 = { new(13, 6), new(20, 6), new(20, 13), new(17, 13), new(17, 9), new(13, 9) };
Point[] corner2 = { new(17, 16), new(20, 16), new(20, 23), new(13, 23), new(13, 20), new(17, 20) };
Point[] corner3 = { new(3, 16), new(6, 16), new(6, 20), new(10, 20), new(10, 23), new(3, 23) };
Point[] corner4 = { new(6, 6), new(10, 6), new(10, 9), new(6, 9) };
Bitmap bmp = new(21, 24);
Pen pb = new(Color.Black, 1);
SolidBrush bw = new (Color.White);
using (Graphics g = Graphics.FromImage(bmp)) {
g.FillPolygon(bw, corner1);
g.DrawPolygon(pb, corner1);
g.FillPolygon(bw, corner2);
g.DrawPolygon(pb, corner2);
g.FillPolygon(bw, corner3);
g.DrawPolygon(pb, corner3);
g.FillPolygon(bw, corner4);
g.DrawPolygon(pb, corner4);
g.FillPolygon(bw, arrow);
g.DrawPolygon(pb, arrow);
}
return CreateCursorNoResize(bmp, 1, 1);
}
}
}

View File

@@ -29,6 +29,8 @@ Some basic hints on the interface:
Download in the [Releases](https://gitea.mcflyer.ru/McFLY/McBitFont/releases) section!
Library example instructions to implement to STM32 code: [mctext](STM32_HAL_Lib/README.md)
#### Important:
**Since v2.0 new save file format is implemented. You can use [McBitFont v1.7](https://gitea.mcflyer.ru/McFLY/McBitFont/releases/tag/v1.7) to convert old saved files to the new format.**
@@ -62,3 +64,8 @@ Code Shift dialog
Font PNG export example
![PNG export example](/images/Font_Minecraft_Rus_5x7_vw.png)
Frame screenshot dialog
![Frame screenshot](/images/Screenshot_Frame-screenshot.png)

13
STM32_HAL_Lib/README.md Normal file
View File

@@ -0,0 +1,13 @@
# McText Library
- The library uses "Left to Right, Top to bottom" scan and "LSB Top" for pixels alignment
#### Instructions
To use the library you have to have a display driver with a function that paints a single pixel with X and Y coordinates and 0/1 color.<br>
Find "SET A FUNCTION NAME HERE!" text in *mctext.c* file and change the function name that suits your driver.<br>
**Note:** it is possible that you will have to change parameters in the function to match your driver.
**Note:** check the "include" in *mctext.h* file to match your HAL. (stm32f1xx_hal.h is fo STM32F1 MCU series)
Now use **mct_String** function to draw a string of text.

113
STM32_HAL_Lib/mctext.c Normal file
View File

@@ -0,0 +1,113 @@
/*
* mctext.c
*
* Created on: May 16, 2025
* Author: User
*/
#include "mctext.h"
#include "ST7565.h"
//=========================== SET A FUNCTION NAME HERE! ===========================//
// A function from display driver to set a pixel (x, y, color)
void (*mct_SetPixel)(uint8_t, uint8_t, uint8_t) = ST7565_SetPixel;
//=================================================================================//
// Draw a single character. Returns width of drawn character
uint8_t mct_CharT(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font, uint8_t transp) {
uint8_t pk = font[0]; // Is it a packed font?
uint8_t w = font[1]; // Font char width
uint8_t h = font[2]; // Font char height
uint8_t fc = font[4]; // First char code in the font
uint8_t lc = font[5]; // Last char code in the font
uint8_t i, j, p, s, b, seg; // i-cur.column, j-cur.row of 8, p-rows of 8, s-height in cur.row of 8, b-cur.bit in cur.row, seg-byte.segment
uint8_t bps; // Bytes per symbol for packed fonts
uint16_t o; // Current offset
if (c < fc || c > lc) return 0;
if (x > LCDWIDTH) return 0;
if (y+h > LCDHEIGHT) return 0;
// Calc the offset for desired symbol
if (pk) { // The font is packed
if (w) { // The font is monospaced
bps = w*h/8; // Bytes per symbol
if ((w*h)%8 > 0) bps++; // Correction for the last byte
o = FONT_HEADER+(c-fc)*bps; // Offset for desired symbol
} else { // The font is not monospaced
o = FONT_HEADER; // Starting offset
for (i=0; i<c-fc; i++) { // Going through every symbol
bps = font[o]*h/8; // Bytes per current symbol
if ((font[o]*h)%8 > 0) bps++; // Correction for the last byte
o += bps + 1; // Adding symbol's width to the offset (+ width byte)
}
w = font[o]; // Desired symbol's width
o++; // Offset for desired symbol's data
}
// Draw the packed symbol!
bps = w*h/8; // Bytes per current symbol
if ((w*h)%8 > 0) bps++; // Correction for the last byte
b = 0; // bit indexer in "current" byte
for (i=0; i<w; i++) { // Going through columns
if (x+i > LCDWIDTH) return i-1; // Check if we're out of display size
for (j=0; j<h; j++) { // Going through rows in column [i]
if (b == 0) seg = font[o];
if ((seg>>b) & 1) mct_SetPixel(x+i, y+j, color); // Paint the pixel
if (b < 7) b++; else {b = 0; o++;} // Track bits and bytes
}
}
} else { // The font is not packed
p = (h%8 > 0) ? h/8 + 1 : h/8; // Bytes in one column
if (w) { // The font is monospaced
o = FONT_HEADER+(c-fc)*w*p; // Offset for desired symbol
} else { // The font is not monospaced
o = FONT_HEADER; // Starting offset
for (i=0; i<c-fc; i++) { // Going through every symbol
o += font[o]*p + 1; // Adding symbol's width to the offset
}
w = font[o]; // Desired symbol's width
o++; // Offset for desired symbol's data
}
// Draw the symbol
for (i=0; i<w; i++) { // Going through columns
if (x+i > LCDWIDTH) return i-1; // Check if we're out of display size
for (j=0; j<p; j++) { // Going through bytes in single column
s = (h - j*8 >= 8) ? 8 : (h - j*8) % 8; // Clac the amount of pixels in current byte
seg = font[o];
for (b=0; b<s; b++) { // Going through the byte and paint the pixel if the bit is 1
if ((seg>>b) & 1) mct_SetPixel(x+i, y+j*8+b, color);
else if (!transp) mct_SetPixel(x+i, y+j*8+b, !color);
}
o++;
}
//mct_SetPixel(x+i, y, color); // For testing purposes
}
}
return w;
}
// Draw a single character. Transparent background. Returns width of drawn character
uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font) {
return mct_CharT(x, y, c, color, font, 1);
}
// Draw a string of characters
void mct_String(uint8_t x, uint8_t y, const char *c, uint8_t color, const uint8_t *font) {
uint8_t w = font[1]; // Font char width
uint8_t h = font[2]; // Font char height
uint8_t s = font[3]; // Font space between characters
if (y+h > LCDHEIGHT) return;
while (c[0] != 0) {
if (x+w > LCDWIDTH) return;
w = mct_Char(x, y, (unsigned char)*c, color, font);
c++;
x += w + s;
}
}

21
STM32_HAL_Lib/mctext.h Normal file
View File

@@ -0,0 +1,21 @@
/*
* mctext.h
*
* Created on: May 16, 2025
* Author: User
*/
#ifndef INC_MCTEXT_H_
#define INC_MCTEXT_H_
#include "stm32f1xx_hal.h"
// Draw a single character. Returns width of drawn character
uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font);
// Draw a string of characters
void mct_String(uint8_t x, uint8_t y, const char *c, uint8_t color, const uint8_t *font);
#endif /* INC_MCTEXT_H_ */

View File

@@ -1,7 +1,9 @@
Application:
- Consider migrating to WPF in order to make DPI aware UI
- Cursor for rectangular selection tool
Functionality:
V Screensot a frame function
V Frame note field to store a frame description
Bugs:

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 54 KiB