TODO feature: Screensot a frame function

This commit is contained in:
Anton Mukhin
2025-07-02 20:06:14 +03:00
parent 67be566605
commit 4115455a54
7 changed files with 374 additions and 16 deletions

View File

@@ -69,6 +69,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();
@@ -543,7 +544,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 +636,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";
@@ -664,7 +675,7 @@
undoToolStripMenuItem.Image = Properties.Resources.arrow_undo;
undoToolStripMenuItem.Name = "undoToolStripMenuItem";
undoToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z;
undoToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
undoToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
undoToolStripMenuItem.Text = "Undo";
undoToolStripMenuItem.ToolTipText = "Undo last canvas change";
undoToolStripMenuItem.Click += undoToolStripMenuItem_Click;
@@ -674,7 +685,7 @@
redoToolStripMenuItem.Image = Properties.Resources.arrow_redo;
redoToolStripMenuItem.Name = "redoToolStripMenuItem";
redoToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y;
redoToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
redoToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
redoToolStripMenuItem.Text = "Redo";
redoToolStripMenuItem.ToolTipText = "Redo canvas change";
redoToolStripMenuItem.Click += redoToolStripMenuItem_Click;
@@ -685,7 +696,7 @@
copyToolStripMenuItem.Name = "copyToolStripMenuItem";
copyToolStripMenuItem.ShortcutKeyDisplayString = "";
copyToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C;
copyToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
copyToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
copyToolStripMenuItem.Text = "Copy";
copyToolStripMenuItem.ToolTipText = "Copy current symbol to clipboard";
copyToolStripMenuItem.Click += copyToolStripMenuItem_Click;
@@ -696,7 +707,7 @@
pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
pasteToolStripMenuItem.ShortcutKeyDisplayString = "";
pasteToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V;
pasteToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
pasteToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
pasteToolStripMenuItem.Text = "Paste";
pasteToolStripMenuItem.ToolTipText = "Paste from clipboard to current symbol";
pasteToolStripMenuItem.Click += pasteToolStripMenuItem_Click;
@@ -706,7 +717,7 @@
selectToolStripMenuItem.Image = Properties.Resources.fam_rectt;
selectToolStripMenuItem.Name = "selectToolStripMenuItem";
selectToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.R;
selectToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
selectToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
selectToolStripMenuItem.Text = "Select";
selectToolStripMenuItem.ToolTipText = "Toggle Rectangle selection tool";
selectToolStripMenuItem.Click += selectToolStripMenuItem_Click;
@@ -717,7 +728,7 @@
selectAllToolStripMenuItem.Image = Properties.Resources.arrow_out;
selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem";
selectAllToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A;
selectAllToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
selectAllToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
selectAllToolStripMenuItem.Text = "Select All";
selectAllToolStripMenuItem.ToolTipText = "Select entire canvas";
selectAllToolStripMenuItem.Click += selectAllToolStripMenuItem_Click;
@@ -1320,6 +1331,7 @@
private System.Windows.Forms.ToolStripMenuItem zerofyWidthToolStripMenuItem;
public System.Windows.Forms.NumericUpDown nudBrush;
private System.Windows.Forms.Label lblBrush;
private System.Windows.Forms.ToolStripMenuItem frameScreenshotToolStripMenuItem;
}
}

View File

@@ -59,7 +59,7 @@ namespace McBitFont {
public bool monospaced = false;
private bool modified = false;
private bool prjModified = false;
public const string version = "2.7";
public const string version = "2.8";
public string prjName = "Untitled";
public string prjFileName = "";
public int codepage = 1251;
@@ -621,7 +621,7 @@ namespace McBitFont {
SetModified();
changed = true;
}
}
}
return changed;
@@ -1694,5 +1694,11 @@ namespace McBitFont {
private void nudBrush_ValueChanged(object sender, EventArgs e) {
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();
}
}
}

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.7.0.0</AssemblyVersion>
<FileVersion>2.7.0.0</FileVersion>
<Version>$(VersionPrefix)2.7.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

@@ -1,10 +1,8 @@
Application:
- Consider migrating to WPF in order to make DPI aware UI
V Cursor for rectangular selection tool
V Icons for tool buttons
V Tooltips now has keyboard shortcuts info
Functionality:
V Screensot a frame function
Bugs:
V Fix selection info: change comma to x