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 7036927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:28:56+00:00 2026-05-28T01:28:56+00:00

For a mobile application I have to generate a 1-bit-bitmap out of a 24-bit-bitmap.

  • 0

For a mobile application I have to generate a 1-bit-bitmap out of a 24-bit-bitmap. The problem is, that the result isn’t correct, so i made this little project to try it on my desktop-pc. the creation works, but the result isn’t ok, as you can see.

You can hardly read anything because a lot of bits aren’t at the right position anymore but moved some pixels left or right.

This is the code i use for creation:

int z = 0;
int bitNumber = 0;
//the new 1Bit-byte-Array 
byte[] oneBitImage = new byte[(bmp.Height * bmp.Width) / 8];

BitmapData bmData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
unsafe
{
  byte* p = (byte*)(void*)bmData.Scan0.ToPointer();
  int stopAddress = (int)p + bmp.Height * bmData.Stride;
  while ((int)p != stopAddress)
  {
    if (*p < 128) // is black
    oneBitImage[z] = (byte)(oneBitImage[z] | Exp(bitNumber));   //Set a Bit on the specified position
    p += 3;

    bitNumber++;

    if (bitNumber == 8)
    {
      bitNumber = 0;
      z++;
    }
  }
}

bmp.UnlockBits(bmData);

//Convert into 1-bit-bmp to check result
Bitmap newbmp = new Bitmap(bmp.Width, bmp.Height, PixelFormat.Format1bppIndexed);

BitmapData bmpData = newbmp.LockBits(
                             new Rectangle(0, 0, newbmp.Width, newbmp.Height),
                             ImageLockMode.WriteOnly, newbmp.PixelFormat);

Marshal.Copy(oneBitImage, 0, bmpData.Scan0, oneBitImage.Length);

newbmp.UnlockBits(bmpData);

newbmp.Save(fileName, ImageFormat.Bmp);

Short explanation:
I run through every third byte, and if this byte – the first one of a 3-byte-group (pixel in 24-bit) – is lower than 128 I put a bit at the specified position.
EXP gives me the exponent…

  • 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-05-28T01:28:57+00:00Added an answer on May 28, 2026 at 1:28 am

    Switch the bits in every output byte around. Bit 7 should be bit 0, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a Mobile application that connect to my Web Servie via RESTful
I have the following problem: I implemented a managed mobile application for Windows Mobile
I have a view like this in my Flex mobile Application: <s:View xmlns:fx=http://ns.adobe.com/mxml/2009 xmlns:s=library://ns.adobe.com/flex/spark
I have to write a simple mobile application that is able to receive broadcast
I have a mobile application that I'm using with Facebook connect. I'm having trouble
I'm creating this mobile portal/application using (ASP + WML) were I need to generate
I have a mobile application that needs to be ported for a Japanese audience.
I am building a web application that will have a fair bit of forms.
We have a mobile Application in a very unsteady WLan Environment. Sending Data to
I have a Java Mobile application using CLDC 1.0 and MIDP 2.0 and I

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.