mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-21 05:18:38 +00:00
Fixed the TTF2OPFF converter.
This commit is contained in:
parent
6167e246b2
commit
371c96edb5
2 changed files with 27 additions and 5 deletions
13
source2/Tools/TTF2OPFF Converter/Form1.Designer.cs
generated
13
source2/Tools/TTF2OPFF Converter/Form1.Designer.cs
generated
|
|
@ -35,6 +35,8 @@
|
|||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.BrowseButton = new System.Windows.Forms.Button();
|
||||
this.ConvertButton = new System.Windows.Forms.Button();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
|
|
@ -97,11 +99,20 @@
|
|||
this.ConvertButton.UseVisualStyleBackColor = true;
|
||||
this.ConvertButton.Click += new System.EventHandler(this.ConvertButton_Click);
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Location = new System.Drawing.Point(344, 106);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(32, 32);
|
||||
this.pictureBox1.TabIndex = 6;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(449, 363);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.Controls.Add(this.ConvertButton);
|
||||
this.Controls.Add(this.BrowseButton);
|
||||
this.Controls.Add(this.textBox1);
|
||||
|
|
@ -111,6 +122,7 @@
|
|||
this.Name = "Form1";
|
||||
this.Text = "Orvid\'s TTF to OPFF Converter";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
|
@ -125,6 +137,7 @@
|
|||
private System.Windows.Forms.TextBox textBox1;
|
||||
private System.Windows.Forms.Button BrowseButton;
|
||||
private System.Windows.Forms.Button ConvertButton;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Drawing;
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace TTF2OPFF_Converter
|
||||
{
|
||||
|
|
@ -66,7 +67,7 @@ namespace TTF2OPFF_Converter
|
|||
strm.WriteByte(0);
|
||||
strm.WriteByte(0);
|
||||
strm.WriteByte(0);
|
||||
|
||||
|
||||
string FontName = (string)FontComboBox.SelectedItem;
|
||||
|
||||
byte[] buffer = ASCIIEncoding.ASCII.GetBytes(FontName);
|
||||
|
|
@ -106,9 +107,11 @@ namespace TTF2OPFF_Converter
|
|||
int prevChar = 0;
|
||||
foreach (KeyValuePair<int, int> ch in chars)
|
||||
{
|
||||
Graphics g = Graphics.FromImage(new Bitmap(32, 32));
|
||||
Bitmap Backend = new Bitmap(32, 32);
|
||||
Graphics g = Graphics.FromImage(Backend);
|
||||
g.Clear(Color.White);
|
||||
g.DrawString(new String(new char[] { (char)ch.Key }), f, new SolidBrush(Color.Black), 0, 0);
|
||||
g.Flush(System.Drawing.Drawing2D.FlushIntention.Flush);
|
||||
if (prevChar + 1 == ch.Key)
|
||||
{
|
||||
strm.WriteByte(255); // write that it's incremented from the previous char.
|
||||
|
|
@ -119,11 +122,16 @@ namespace TTF2OPFF_Converter
|
|||
buffer = BitConverter.GetBytes(ch.Key);
|
||||
strm.Write(buffer, 0, buffer.Length); // Write the char number.
|
||||
}
|
||||
pictureBox1.Image = Image.FromHbitmap(Backend.GetHbitmap());
|
||||
pictureBox1.Refresh();
|
||||
//for (int isoa = 0; isoa < 10000; isoa++)
|
||||
//{
|
||||
//}
|
||||
strm.WriteByte(1); // write that it's normal style.
|
||||
strm.WriteByte(32); // write the height
|
||||
strm.WriteByte(32); // write the width
|
||||
int len = 128;
|
||||
buffer = ConvertToByteArray(new Bitmap(32, 32, g));
|
||||
buffer = ConvertToByteArray(Backend);
|
||||
strm.Write(buffer, 0, len);
|
||||
prevChar = ch.Key;
|
||||
}
|
||||
|
|
@ -131,7 +139,8 @@ namespace TTF2OPFF_Converter
|
|||
strm.Flush();
|
||||
strm.Close();
|
||||
strm.Dispose();
|
||||
|
||||
//pictureBox1.Image = null;
|
||||
|
||||
MessageBox.Show("Conversion Completed Successfully!");
|
||||
}
|
||||
else
|
||||
|
|
@ -149,7 +158,7 @@ namespace TTF2OPFF_Converter
|
|||
{
|
||||
for (int y = 0; y < b.Height; y++)
|
||||
{
|
||||
if (b.GetPixel(x, y) == Color.Black)
|
||||
if (b.GetPixel(x, y) == Color.FromArgb(255, 255, 255))
|
||||
{
|
||||
bits[bitnum] = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue