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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:35:11+00:00 2026-06-15T22:35:11+00:00

I have an array of raw bytes and I want to make a bmp

  • 0

I have an array of raw bytes and I want to make a bmp file from those bytes. That is, I have to fill bitmap header structre and other things, then write down the bytes so I have a bmp file in the proper format.

As I need this for some quick check only, I wonder if there is a portable method to do this – take raw bytes and save them as a bmp file. Any Windows version won’t do as I’m writing that on Unix.

Alternatively, I can save those bytes as any other image format – I only need to have a quick look at the resulting picture.

  • 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-15T22:35:13+00:00Added an answer on June 15, 2026 at 10:35 pm

    The following will give you a .ppm image from a byte array. The "P6" specifies binary format 3 byte per pixel, but plain text is also supported and various forms of grayscale. The reason you should use this is that it is easy as can be and most *nix systems have a bunch of ppmto*-tools: ppmtobmp, ppmtojpeg, …, ppmtopng… you name it.

    typedef struct {
        int width;
        int height;
        uint8_t *data;
        size_t size;
    } ppm_image;
    
    size_t ppm_save(ppm_image *img, FILE *outfile) {
        size_t n = 0;
        n += fprintf(outfile, "P6\n# THIS IS A COMMENT\n%d %d\n%d\n", 
                     img->width, img->height, 0xFF);
        n += fwrite(img->data, 1, img->width * img->height * 3, outfile);
        return n;
    }
    

    There is also ppmtocad… who would have guessed?

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

Sidebar

Related Questions

I have dynamic array filled with bytes, which are read from .raw file with
I have a list of bytes that represent raw samples read in from an
I have a file reader that reads n bytes from a file and returns
I have an array of raw sound data samples, and I'm trying to make
I have a array of raw bytes which i need to tokenize to a
I have an array, named Images and want to get on value from it.
I have flv files that contain audio tags with a aac raw data. Each
I have a C function that does some pixel manipulation on a raw 2D
I have a problem with converting raw-bytes values into java types. I am receiving
I'm trying to create a Managed Array of doubles from an array of bytes.

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.