Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8632365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:20:32+00:00 2026-06-12T09:20:32+00:00

I have a C header file that contains 10×12 pixel bitmap font characters in

  • 0

I have a C header file that contains 10×12 pixel bitmap font characters in an array of 2×12 (for a mono color lcd). This wastes the lower 6-bits of every other byte, not to mention being harder to render for having to skip the paddings.

What is the easiest way to convert this to simple serialized bits without the padded bits?

the solution that I see has a lot of complicated bit banging. Is there an easy way to do perform this?

0x00,0x00,  /*  ................  */
0x30,0x00,  /*  ..@@............  */
0x78,0x00,  /*  .@@@@...........  */
0x48,0x00,  /*  .@..@...........  */
0xCC,0x00,  /*  @@..@@..........  */
0xCC,0x00,  /*  @@..@@..........  */
0xCC,0x00,  /*  @@..@@..........  */
0xFC,0x00,  /*  @@@@@@..........  */
0xCC,0x00,  /*  @@..@@..........  */
0xCC,0x00,  /*  @@..@@..........  */
0x00,0x00,  /*  ................  */
0x00,0x00   /*  ................  */
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:20:32+00:00Added an answer on June 12, 2026 at 9:20 am

    A simplified version can create a producer consumer going one bit at a time which keeps the bit banging to a sane level. Here’s what I ended up doing:

    #define CHAR_W 10
    #define CHAR_H 12
    #define NUM_CHARS 100
    #define CEILING(x,y) (((x) + (y) - 1) / (y))
    #define BYTES CEILING(CHAR_W, 8)
    #define BIT(x, n) ( ((1 << n) & x) >> n )
    #define COPYBIT(b,x,n) (((0x1 & b) << n) | x)
    #define CHAR_BYTES CEILING(CHAR_H * CHAR_W, 8)
    #define OUTBYTES NUM_CHARS * CHAR_BYTES
    
    int main()
    {
        int totinbit = 0;
        int locinbit = 0;
        int locoutbit = 7;  // start with msb 
        int totoutbit = 0;
        int bytes = BYTES;
    
        unsigned char c = 0;
        unsigned char o = 0;
        unsigned char buf[OUTBYTES];
    
        while (totoutbit < NUM_CHARS * CHAR_H * CHAR_W)
        {
            c = fontArray[totinbit / 8];
            locinbit = 7 - totinbit % 8;
    
            o = COPYBIT(BIT(c,locinbit),o,locoutbit);
    
            // reset out counter, full byte produced
            if (--locoutbit < 0)
            {
                locoutbit = 7;
                buf[totoutbit  / 8] = o;
                o = 0;
            }
    
            // skip over the padding bits
            if ((totoutbit % CHAR_W) == (CHAR_W - 1))
                totinbit =  CEILING(totinbit,8) * 8 - 1;
    
            totinbit++;     
            // character boundary
            if ( (totinbit % (bytes * 8 * CHAR_H)) == 0 && totinbit > 0)
            {
                                // pad the last byte in the character if necessary
                if (locoutbit != 7)
                        locoutbit = 7;
            }
    
            totoutbit++;
    
    
            }
     // at this point buf contains the converted bitmap array
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class header file called Grid.h that contains the following 2 private
.Hi, I have a nib file that contains an header that will be used
I have a tab delimited file that contains date, header row, some values, empty
I have a C++ header file that contains the following definitions: #define CACHE_NUM_WAYS (1<<1)
In my game I have a header file that contains properties and functions for
I have a header file that contains a class. Within that class, I have
I have a header file, lets say Common.h, that is included in all of
I have a c++ implementation file (my.cpp) that indirectly includes a header file (b.h)
I have a file called header.php that I am including on every page on
I have a file that I include on all my webpages that contains the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.