Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Imaging;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace textblit
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- Ptn[] ptn;
- private class Ptn
- {
- public string fn;
- public string asc;
- public Ptn(string f, string a)
- {
- fn = f;
- asc = a;
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- Timer t = new Timer();
- t.Interval = 100;
- t.Start();
- t.Tick += t_Tick;
- }
- void t_Tick(object sender, EventArgs e)
- {
- ((Timer)sender).Stop();
- gp.BackgroundImage = null;
- List<Ptn> lptn = new List<Ptn>();
- string[] strs = System.IO.File.ReadAllLines(@"C:\inc\b64\db\dbdb.lst");
- foreach (string str in strs)
- {
- int i = str.IndexOf(' ');
- string a = str.Substring(i + 1);
- lptn.Add(new Ptn(str.Substring(0, i),
- a.Length == 1 ? a :
- a[0] == '"' ? a.Substring(1, a.Length - 2) :
- ((char)Convert.ToInt32(a, 16)).ToString()));
- }
- ptn = lptn.ToArray();
- Array.Sort(ptn, (x,y) =>
- x.asc.Length == 1 && y.asc.Length == 1 ? x.asc[0] - y.asc[0] :
- x.asc.Length == y.asc.Length ? x.asc.CompareTo(y.asc) :
- x.asc.Length - y.asc.Length);
- set(0);
- }
- void fuck()
- {
- Bitmap bsrc = new Bitmap("src.png");
- Bitmap bout = new Bitmap(bsrc.Width * 2, bsrc.Height, bsrc.PixelFormat);
- BitmapData dsrc = bsrc.LockBits(new Rectangle(0, 0, bsrc.Width, bsrc.Height), ImageLockMode.ReadOnly, bsrc.PixelFormat);
- BitmapData dout = bsrc.LockBits(new Rectangle(0, 0, bout.Width, bout.Height), ImageLockMode.WriteOnly, bout.PixelFormat);
- int sz = dsrc.Stride * dsrc.Height;
- byte[] ci = new byte[dsrc.Stride];
- byte[] co = new byte[dout.Stride];
- for (int x = 0; x < ci.Length; x++) ci[x] = 255;
- for (int x = 0; x < co.Length; x++) co[x] = 255;
- for (int y = 0; y < bsrc.Height; y++)
- {
- System.Runtime.InteropServices.Marshal.Copy(dsrc.Scan0, ci, dsrc.Stride * y, dsrc.Stride);
- for (int x = 0; x < bsrc.Width; x++)
- {
- co[x] = ci[x];
- }
- System.Runtime.InteropServices.Marshal.Copy(co, 0, dout.Scan0 + dout.Stride * y, dout.Stride);
- }
- bsrc.UnlockBits(dsrc);
- bout.UnlockBits(dout);
- bout.Save("test.bmp");
- }
- private void gn_KeyDown(object sender, KeyEventArgs e)
- {
- int i = 0;
- try
- {
- i = Convert.ToInt32(gn.Text);
- if (e.KeyCode == Keys.Down) i--;
- if (e.KeyCode == Keys.Up) i++;
- set(i);
- }
- catch { }
- }
- private void gs_KeyUp(object sender, KeyEventArgs e)
- {
- int dir = 0;
- int ofs = 0;
- Int32.TryParse(gn.Text, out ofs);
- if (e.KeyCode == Keys.Down) dir--;
- if (e.KeyCode == Keys.Up) dir++;
- if (dir != 0)
- {
- for (ofs += dir; dir > 0 ? ofs < ptn.Length : ofs > 1; ofs += dir)
- {
- if (gs.Text == ptn[ofs].asc)
- {
- set(ofs);
- return;
- }
- }
- }
- if (e.KeyCode == Keys.Enter)
- {
- ptn[ofs].asc = gs.Text;
- set(ofs);
- }
- }
- void set(int i)
- {
- byte[] data = System.IO.File.ReadAllBytes(@"C:\inc\b64\db\db" + ptn[i].fn);
- gn.Text = i.ToString();
- gt.Text = gs.Text = ptn[i].asc;
- gs.SelectionStart = gs.Text.Length;
- label1.Text = ptn[i].fn;
- string res = null;
- int a = 3;
- for (; a < 90; a++)
- {
- if (data[a] == '\n')
- {
- res = Encoding.UTF8.GetString(data, 3, a - 3);
- break;
- }
- }
- if (string.IsNullOrEmpty(res)) return;
- string[] ress = res.Split(' ');
- Bitmap bm = new Bitmap(
- Convert.ToInt32(ress[0]),
- Convert.ToInt32(ress[1]));
- int x = 0, y = 0; //a--;
- while (++a < data.Length)
- {
- for (int n = 7; n >= 0; n--)
- {
- bool black = (data[a] & (1 << n)) == 0;
- bm.SetPixel(x, y, black ? Color.Black : Color.White);
- if (++x >= bm.Width)
- {
- x = 0;
- n = 0;
- if (++y >= bm.Height)
- {
- goto lolgoto;
- }
- }
- }
- }
- lolgoto:
- if (gp.BackgroundImage != null)
- gp.BackgroundImage.Dispose();
- gp.BackgroundImage = bm;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement