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

  • Home
  • SEARCH
  • 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 157693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:32:58+00:00 2026-05-11T10:32:58+00:00

I don’t know a better title, but I’ll describe the problem. A piece of

  • 0

I don’t know a better title, but I’ll describe the problem.

A piece of hardware we use has the ability to display images. It can display a black and white image with a resolution of 64 x 256.

The problem is the format of the image we have to send to the device. It is not a standard bitmap format, but instead it is simply an array of bytes representing each pixel of the image.

0 = black, 1 = white.

So if we had an image with the size: 4 x 4 the byte array might look something like:

1000 0100 0010 0001

And the image would look like:

Bitmap http://www.mediafire.com/imgbnc.php/6ee6a28148d0170708cb10ec7ce6512e4g.jpg

The problem is that we need to create this image by creating a monochrome bitmap in C# and then convert it to the file format understood by the device.

For example, one might to display text on the device. In order to do so he would have to create a bitmap and write text to it:

var bitmap = new Bitmap(256, 64);  using (var graphics = Graphics.FromImage(bitmap)) {     graphics.DrawString('Hello World', new Font('Courier', 10, FontStyle.Regular), new SolidBrush(Color.White), 1, 1); } 

There are 2 problems here:

  1. The generated bitmap isn’t monochrome
  2. The generated bitmap has a different binary format

So I need a way to:

  1. Generate a monochrome bitmap in .NET
  2. Read the individual pixel colors for each pixel in the bitmap

I have found that you can set the pixel depth to 16, 24, or 32 bits, but haven’t found monochrome and I have no idea how to read the pixel data.

Suggestions are welcome.

UPDATE: I cannot use Win32 PInvokes… has to be platform neutral!

FOLLOW UP: The following code works for me now. (Just in case anybody needs it)

private static byte[] GetLedBytes(Bitmap bitmap) {     int threshold = 127;     int index = 0;     int dimensions = bitmap.Height * bitmap.Width;      BitArray bits = new BitArray(dimensions);      //Vertically     for (int y = 0; y < bitmap.Height; y++)     {         //Horizontally         for (int x = 0; x < bitmap.Width; x++)         {             Color c = bitmap.GetPixel(x, y);             int luminance = (int)(c.R * 0.3 + c.G * 0.59 + c.B * 0.11);             bits[index] = (luminance > threshold);             index++;         }     }      byte[] data = new byte[dimensions / 8];     bits.CopyTo(data, 0);     return data; } 
  • 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. 2026-05-11T10:32:59+00:00Added an answer on May 11, 2026 at 10:32 am

    I’d compute the luminance of each pixel a then compare it to some threshold value.

    y=0.3*R+0.59G*G+0.11*B 

    Say the threshold value is 127:

    const int threshold = 127; Bitmap bm = { some source bitmap };  byte[,] buffer = new byte[64,256];  for(int y=0;y<bm.Height;y++) {   for(int x=0;x<bm.Width;x++)   {    Color c=source.GetPixel(x,y);    int luminance = (int)(c.R*0.3 + c.G*0.59+ c.B*0.11);    buffer[x,y] = (luminance  > 127) ? 1 : 0;   } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know if anyone has seen this issue before but I'm just stumped.
I don't know if this has been asked before, but what i'd like to
I don't know why, but there is a problem I'm encountering with $.parseJSON when
I don't want PHP errors to display /html, but I want them to display
Don't know if this has been answered before. Have custom routes to users. If
I don't like Jackson. I want to use ajax but with Google Gson. So
I don't know when to add to a dataset a tableadapter or a query
I don't remember whether I was dreaming or not but I seem to recall
I don't expect a straightforward silver bullet answer to this, but what are the
I don't currently use ajax.net though I would be open to it if it

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.