How can I create arrays for bitmap characters of a font..

Total Post:31

Points:217
VB.Net 
 1268  View(s)
Ratings:
Rate this:
hai..

How can I create arrays for bitmap characters of a font..

Which should be like a grid, width in pixels by the height in pixels of the font size. With thoise pixels should make shape of a character in the grid.

for example:
// Font data is Times New Roman 10pt
// Character bitmaps for Times New Roman 10pt
const uint_8 timesNewRoman_10ptBitmaps[] = 
{
// @0 'a' (5 pixels wide)
0x00, // 
0x00, // 
0x00, // 
0x60, // ## 
0x90, // # # 
0x70, // ### 
0x90, // # # 
0x90, // # # 
0x78, // ####
// @9 'b' (6 pixels wide)
0x40, // # 
0xC0, // ## 
0x40, // # 
0x58, // # ## 
0x64, // # # #
0x44, // # #
0x44, // # #
0x44, // # #
0x38, // ### 

Is there any possible way to it.. Can anyone help me in doing this process.

Thank U 
  1. Post:194

    Points:1396
    Re: How can I create arrays for bitmap characters of a font..

    Hey if i understand you right you need something like this:

    //Create String-Array
    string[] a = {"A", "B", "C"}; 
    //Create a Image-Object on which we can paint
    Image bmp = new Bitmap(100, 100); 
    //Create the Graphics-Object to paint on the Bitmap
    Graphics g = Graphics.FromImage(bmp); 
    //Here we get the random string
    //Random.Next() gives us the next integer value
    //Because we dont want to get IndexOutOfBoundException we give the Array length to the Next method
    //So just the numbers from 0 - Array.Length can be choosen from Next method
    string randomString = a[new Random().Next(a.Length)]; 
    //Your custom Font (6f = 6px)!
    Font myFont = new Font("Arial", 6f) 
    //Get the perfect Image-Size so that Image-Size = String-Size
    SizeF size = g.MeasureString(randomString, myFont);
    PointF rect = new PointF(size.Width, size.Height);    
    //Use this to become better Text-Quality on Bitmap.
    g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
    g.PixelOffsetMode = PixelOffsetMode.HighQuality; 
    //Here we draw the string on the Bitmap
    g.DrawString(randomString, myFont, new SolidBrush(Color.Black), rect); 

    You can use the bmp object in your Program. For example:

    picturebox.Image = bmp;

    I hope you can understand it now :) If you have a problem to understand the Objectdesign you should read a book at first. This is for free ;)

      Modified On Apr-09-2018 04:05:22 AM
  1. Post:31

    Points:217
    Re: How can I create arrays for bitmap characters of a font..

    hai..


          I need this in vb.net..

      Modified On Apr-09-2018 04:04:34 AM
  1. Post:194

    Points:1396
    Re: How can I create arrays for bitmap characters of a font..

    Dim a As String() = {"A", "B", "C"}
    Dim bmp As Image = New Bitmap(100, 100)
    Dim g As Graphics = Graphics.FromImage(bmp)
    Dim randomString As String = a(New Random().[Next](a.Length))
    Dim myFont As New Font("Arial", 6F)
    Dim size As SizeF = g.MeasureString(randomString, myFont)
    Dim rect As New PointF(size.Width, size.Height)
    g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias
    g.InterpolationMode = InterpolationMode.HighQualityBicubic
    g.PixelOffsetMode = PixelOffsetMode.HighQuality
    g.DrawString(randomString, myFont, New SolidBrush(Color.Black), rect)
    picturebox.Image = bmp

  1. Post:31

    Points:217
    Re: How can I create arrays for bitmap characters of a font..

    hai..


      I need with the format of pixel representation ( Ie) Whenever i give a input text it should b converted as a bitmap with height,width of a font..

     Suppose if i give my input as "a" means that string should be displayed in 8*8 matrix.. the filled area of "a" should be given as 1 and others should represent 0..

    for example please see this C# coding I need the same to be displayed in vb.net..
    I need only the conversion of text..
    www.eran.io/the-dot-factory-an-lcd-font-and-image-generator/

      Modified On Apr-09-2018 04:04:21 AM
  1. Post:194

    Points:1396
    Re: How can I create arrays for bitmap characters of a font..

    Madhu can u show me your code so that i can analyze the problem and try to fix it

  1. Post:31

    Points:217
    Re: How can I create arrays for bitmap characters of a font..

    Sorry Sir,

        Still i donot start up with my code..I dono from where to start with coding.. I just saw that sample c# program which was related to my project..
       So I need help in starting this process.. 


    Thank U

Answer