(Try using the table below to decipher this!)


Introduction

Not too long ago(while reading Code by Charles Petzold, which I recommend), I became particularly interested in Braille code. I decided it was time for me to write a little application in Visual Basic, which I later ported over to C# for this article(To Do). The book goes on to describe, how in Braille Code, that each symbol is represented by 6 binary values. The layout of a Braille symbol is as follows: 


Knowing that either each one of the 6 cells is going to be either darkened or invisible, you can deduce two possible values for a cell:  Either darkened, or invisible, meaning either on or off, or 1 or zero. This means that each cell is binary in nature. Since we know that there are 6 cells, and in the picture above each cell has a number corresponding to that cells' position, we can also easily represent a Braille symbol using a binary string of ones and zeros.

Below is a picture that shows how the cell positions in a binary symbol relate to the bit positions in a binary string.


Braille to Binary Table

The following is a table that shows the binary representation for each Braille symbol. *Please note that this table does not cover shorthand Braille code.

A 100000 I 010100 Q 111110 Y 101111 7 011011 ) 011111 \ 110011 @ 000100
B 110000 J 010110 R 111010 Z 101011 8 011001 * 100001 [ 010101 ^ 000110
C 100100 K 101000 S 011100 1 010000 9 001010 < 110001 / 001100 _ 000111
D 100110 L 111000 T 011110 2 011000 0 001011 % 100101 + 001101 " 000010
E 100010 M 101100 U 101001 3 010010 & 111101 ? 100111 # 001111 . 000101
F 110100 N 101110 V 111001 4 010011 = 111111 : 100011 > 001110 ; 000011
G 110110 O 101010 W 010111 5 010001 ( 111011 $ 110101 ' 001000 , 000001
H 110010 P 111100 X 101101 6 011010 ! 011101 ] 110111 - 001001
  000000

Example Code(Visual Basic)

Knowing all of this, we can create a simple program that will draw these symbols using GDI. 
In order to keep things less complicated, I have extracted the main function(ToBraille) from my example, and I will explain that via in-code comments. At the end of this article you will find a link that leads you to the entire project that I created.

 

 
C#Visual Basic
Edit|Remove
using System; 
using System.Collections.Genericusing System.ComponentModelusing System.Datausing System.Drawingusing System.Linqusing System.Textusing System.Threading.Tasksusing System.Windows.Formsusing System.Drawing.Drawing2Dnamespace WindowsFormsApplication2 
{ 
    public partial class Form1 : Form 
    { 
        public Form1() 
        { 
            InitializeComponent(); 
        } 
                private void Form1_Load(object sender, EventArgs e) 
        { 
            this.BackgroundImageLayout = ImageLayout.None; 
            this.BackgroundImage = ToBraille("hello World"10, Color.Black, Color.White, truethis); 
        } 
        private static Bitmap ToBraille(string text, int fontSize, Color backColor, Color foreColor, bool drawBlanks, Control parent) 
        { 
            string[] lines = { 
        }; 
            int dotSize = fontSize - 2; 
            int pad = dotSize / 2; 
            int characterWidth = (fontSize * 2) + (pad * 2); 
            int characterHeight = (fontSize * 3) + (pad * 2); 
            Color crColor = Color.FromArgb(2552552550); 
            Color lfColor = Color.FromArgb(2550255255); 
            Color unknownColor = Color.FromArgb(2552550255); 
            try 
            { 
                lines = text.Split(new string[] { "\r\n""\n" }, StringSplitOptions.None); 
            } 
            catch 
            { 
                Bitmap bm = new Bitmap(11); 
                Graphics g = Graphics.FromImage(bm); 
                g.Clear(parent.BackColor); 
                return bm; 
            } 
            Size maxSize = new Size(0, lines.Count() * characterHeight); 
            foreach (string line in lines) 
            { 
                if ((line.Length * characterWidth) > maxSize.Width) 
                    maxSize.Width = (line.Length * characterWidth); 
            } 
            List<Image> images = new List<Image>(); 
            Bitmap finalBM = null; 
            try 
            { 
                finalBM = new Bitmap(maxSize.Width, maxSize.Height); 
            } 
            catch 
            { 
                Bitmap bm = new Bitmap(11); 
                Graphics g = Graphics.FromImage(bm); 
                g.Clear(parent.BackColor); 
                return bm; 
            } 
            Graphics finalG = Graphics.FromImage(finalBM); 
            finalG.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; 
            finalG.Clear(backColor); 
            if (string.IsNullOrEmpty(text)) 
                return finalBM; 
            foreach (char s in text.ToLower()) 
            { 
                string keyCode = string.Empty; 
                Bitmap bm = new Bitmap(characterWidth, characterHeight); 
                Graphics g = Graphics.FromImage(bm); 
                int x = 0; 
                int y = -fontSize; 
                string s3 = s.ToString(); 
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; 
                g.Clear(backColor); 
                switch (s3) 
                { 
                    case "a": 
                        keyCode = "100000"; 
                        break; 
                    case "b": 
                        keyCode = "110000"; 
                        break; 
                    case "c": 
                        keyCode = "100100"; 
                        break; 
                    case "d": 
                        keyCode = "100110"; 
                        break; 
                    case "e": 
                        keyCode = "100010"; 
                        break; 
                    case "f": 
                        keyCode = "110100"; 
                        break; 
                    case "g": 
                        keyCode = "110110"; 
                        break; 
                    case "h": 
                        keyCode = "110010"; 
                        break; 
                    case "i": 
                        keyCode = "010100"; 
                        break; 
                    case "j": 
                        keyCode = "010110"; 
                        break; 
                    case "k": 
                        keyCode = "101000"; 
                        break; 
                    case "l": 
                        keyCode = "111000"; 
                        break; 
                    case "m": 
                        keyCode = "101100"; 
                        break; 
                    case "n": 
                        keyCode = "101110"; 
                        break; 
                    case "o": 
                        keyCode = "101010"; 
                        break; 
                    case "p": 
                        keyCode = "111100"; 
                        break; 
                    case "q": 
                        keyCode = "111110"; 
                        break; 
                    case "r": 
                        keyCode = "111010"; 
                        break; 
                    case "s": 
                        keyCode = "011100"; 
                        break; 
                    case "t": 
                        keyCode = "011110"; 
                        break; 
                    case "u": 
                        keyCode = "101001"; 
                        break; 
                    case "v": 
                        keyCode = "111001"; 
                        break; 
                    case "w": 
                        keyCode = "010111"; 
                        break; 
                    case "x": 
                        keyCode = "101101"; 
                        break; 
                    case "y": 
                        keyCode = "101111"; 
                        break; 
                    case "z": 
                        keyCode = "101011"; 
                        break; 
                    case "1": 
                        keyCode = "010000"; 
                        break; 
                    case "2": 
                        keyCode = "011000"; 
                        break; 
                    case "3": 
                        keyCode = "010010"; 
                        break; 
                    case "4":  
                        keyCode = "010011"; 
                        break; 
                    case "5": 
                        keyCode = "010001"; 
                        break; 
                    case "6": 
                        keyCode = "011010"; 
                        break; 
                    case "7": 
                        keyCode = "011011"; 
                        break; 
                    case "8": 
                        keyCode = "011001"; 
                        break; 
                    case "9": 
                        keyCode = "001010"; 
                        break; 
                    case "0": 
                        keyCode = "001011"; 
                        break; 
                    case "&": 
                        keyCode = "111101"; 
                        break; 
                    case "=": 
                        keyCode = "111111"; 
                        break; 
                    case "(": 
                        keyCode = "111011"; 
                        break; 
                    case "!": 
                        keyCode = "011101"; 
                        break; 
                    case ")": 
                        keyCode = "011111"; 
                        break; 
                    case "*": 
                        keyCode = "100001"; 
                        break; 
                    case "<": 
                        keyCode = "110001"; 
                        break; 
                    case "%": 
                        keyCode = "100101"; 
                        break; 
                    case "?": 
                        keyCode = "100111"; 
                        break; 
                    case ":": 
                        keyCode = "100011"; 
                        break; 
                    case "$": 
                        keyCode = "110101"; 
                        break; 
                    case "]": 
                        keyCode = "110111"; 
                        break; 
                    case "\\": 
                        keyCode = "110011"; 
                        break; 
                    case "[": 
                        keyCode = "010101"; 
                        break; 
                    case "/": 
                        keyCode = "001100"; 
                        break; 
                    case "+": 
                        keyCode = "001101"; 
                        break; 
                    case "#": 
                        keyCode = "001111"; 
                        break; 
                    case ">": 
                        keyCode = "001110"; 
                        break; 
                    case "'": 
                        keyCode = "001000"; 
                        break; 
                    case "-": 
                        keyCode = "001001"; 
                        break; 
                    case "@": 
                        keyCode = "000100"; 
                        break; 
                    case "^": 
                        keyCode = "000110"; 
                        break; 
                    case "_": 
                        keyCode = "000111"; 
                        break; 
                    case "\"": 
                        keyCode = "000010"; 
                        break; 
                    case ".": 
                        keyCode = "000101"; 
                        break; 
                    case ";": 
                        keyCode = "000011"; 
                        break; 
                    case ",": 
                        keyCode = "000001"; 
                        break; 
                    case " ": 
                        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; 
                        g.Clear(backColor); 
                        images.Add(bm); 
                        continue; 
                    //'\r' is carriage return. 
                    //'\n' is new line. 
                    case "\r": 
                        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; 
                        g.Clear(Color.White); 
                        bm.SetPixel(00, crColor); 
                        images.Add(bm); 
                        continue; 
                    case "\n": 
                        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; 
                        g.Clear(Color.White); 
                        bm.SetPixel(00, lfColor); 
                        images.Add(bm); 
                        continue; 
                    default: 
                        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; 
                        g.Clear(Color.White); 
                        bm.SetPixel(00, unknownColor); 
                        images.Add(bm); 
                        continue; 
                } 
                foreach (char s2 in keyCode.ToCharArray()) 
                { 
                    y += fontSize; 
                    if (y > (fontSize * 2)) 
                    { 
                        y = 0; 
                        x += fontSize; 
                    } 
                    if (s2 == "1".ToCharArray()[0]) 
                    { 
                        g.FillEllipse(new SolidBrush(foreColor), new Rectangle(new Point(x + pad, y + pad), new Size(dotSize, dotSize))); 
                    } 
                    else 
                    { 
                        if (drawBlanks) 
                        { 
                            g.DrawEllipse(new Pen(new SolidBrush(foreColor)), new Rectangle(new Point(x + pad, y + pad), new Size(dotSize, dotSize))); 
                        } 
                    } 
 
                } 
                images.Add(bm); 
            } 
            int left = -images[0].Width; 
            int top = 0; 
            foreach (Bitmap Image in images) 
            { 
                Color color = Image.GetPixel(00); 
                if (color == crColor) 
                { 
                    left = -Image.Width; 
                    top += Image.Height; 
                    continue; 
                } 
                else if (color == lfColor) 
                { 
                    continue; 
                } 
                else if (color == unknownColor) 
                { 
                    //    MsgBox("unknown!") 
                    continue; 
                } 
                left += Image.Width; 
                if ((left + Image.Width) > maxSize.Width) 
                { 
                    left = 0; 
                    top += Image.Height; 
                } 
                Point location = new Point(left, top); 
                finalG.DrawImage(Image, location); 
            } 
            return finalBM; 
        } 
    } 
} 
Screen Shot of Example Project:


Summary

 


Braille code can be represented as binary code, and translated to a symbol using GDI



I hope you find this helpful


Please check out my TechNet Wiki articles!

Summary
 

At declaration, taking extra consideration into selecting a numeric datatype may be beneficial, and help to reduce unnecessary memory consumption.

I hope you find this helpful, Please edit if you find any errors or omissions.

very good counter  
Please check out my other TechNet Wiki articles!