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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:31:58+00:00 2026-06-09T19:31:58+00:00

After spending much time researching about this on Google, I could not come across

  • 0

After spending much time researching about this on Google, I could not come across an example of converting a Wbmp image to Png format in C#
I have download some Wbmp images from the internet and I am viewing them using a Binary Editor.

Does anyone have an algorithm that will assist me in doing so or any code will also help.

Things I know so far:

  1. First byte is type* (0 for monochrome images)
  2. Second byte is called a “fixed-header” and is 0
  3. Third byte is the width of the image in pixels*
  4. Fourth byte is the height of the image in pixels*
  5. Data bytes arranged in rows – one bit per pixel:
    Where the row length is not divisible by 8, the row is 0-padded to
    the byte boundary

I am fully lost so any help will be appreciated


Some of the other code:

using System.Drawing;
using System.IO;

class GetPixel
{
   public static void Main(string[] args)
   {
      foreach ( string s in args )
      {
         if (File.Exists(s))
         {
            var image = new Bitmap(s);
            Color p = image.GetPixel(0, 0);
            System.Console.WriteLine("R: {0} G: {1} B: {2}", p.R, p.G, p.B);
         }
      }
   }
}

And

class ConfigChecker
{
   public static void Main()
   {
      string drink = "Nothing";
      try
      {
         System.Configuration.AppSettingsReader configurationAppSettings 
            = new System.Configuration.AppSettingsReader();
         drink = ((string)(configurationAppSettings.GetValue("Drink", typeof(string))));
      }
      catch ( System.Exception )
      {
      }
      System.Console.WriteLine("Drink: " + drink);
   } // Main
} // class ConfigChecker

Process :

  1. Did research on Wbmp

  2. Open up X.wbmp to check details first

  3. Work out how you find the width and height of the WBMP file (so that you can later write the code). Note that the simplest way to convert a collection of length bytes (once the MSB is cleared) is to treat the entity as base-128.

  4. Look at sample code I updated.

  5. I am trying to create an empty Bitmap object and set its width and height to what we worked out in (3)

  6. For every bit of data, will try and do a SetPixel on the Bitmap object created.

  7. Padded 0s when the WBMP width is not a multiple of 8.

  8. Save Bitmap using the Save() method.

Example usage of the application. It is assumed that the application is called Wbmp2Png. In command line:

Wbmp2Png IMG_0001.wbmp IMG_0002.wbmp IMG_0003.wbmp

The application converts each of IMG_0001.wbmp, IMG_0002.wbmp, and IMG_0003.wbmp to PNG files.

  • 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-09T19:31:59+00:00Added an answer on June 9, 2026 at 7:31 pm

    This seems to get the job done.

    using System.Drawing;
    using System.IO;
    
    namespace wbmp2png
    {
        class Program
        {
            static void Main(string[] args)
            {
                foreach (string file in args)
                {
                    if (!File.Exists(file))
                    {
                        continue;
                    }
                    byte[] data = File.ReadAllBytes(file);
                    int width = 0;
                    int height = 0;
                    int i = 2;
                    for (; data[i] >> 7 == 1; i++)
                    {
                        width = (width << 7) | (data[i] & 0x7F);
                    }
                    width = (width << 7) | (data[i++] & 0x7F);
                    for (; data[i] >> 7 == 1; i++)
                    {
                        height = (height << 7) | (data[i] & 0x7F);
                    }
                    height = (height << 7) | (data[i++] & 0x7F);
                    int firstPixel = i;
                    Bitmap png = new Bitmap(width, height);
                    for (int y = 0; y < height; y++)
                    {
                        for (int x = 0; x < width; x++)
                        {
                            png.SetPixel(x, y, (((data[firstPixel + (x / 8) + (y * ((width - 1) / 8 + 1))] >> (7 - (x % 8))) & 1) == 1) ? Color.White : Color.Black);
                        }
                    }
                    png.Save(Path.ChangeExtension(file, "png"));
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

django has this complex ORM built in to it, but after spending much time
EDIT: After spending several hours researching this, I don't think I'm going to find
After spending so much time in jQuery, I'm rusty on my old fashioned JS...
After just now spending too much time debugging why my jQuery animate() calls stopped
After spending roughly two days on this, I'm getting a little rattled. Although by
After spending some time wireframing my ideas, I want to start building my rails
After spending a good 3 to 4 hours on google trying to find any
After spending a lot of time and code on programming in Swing, I thought
After spending quite a bit of time trying to design my way around the
After spending three weeks learning Objective-C and Cocoa programming for my work, I've been

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.