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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:58:52+00:00 2026-05-12T21:58:52+00:00

I need to convert a PNG Image loaded from a file into an 8

  • 0

I need to convert a PNG Image loaded from a file into an 8 bit-per-pixel byte array used by another device (embedded programming).

I’m copying over pixel by pixel into a new Image created with a 16-bit color – Format16bppRgb565, but I need Format8bpp, which is not present in the .NET Framework. (I cannot use Format8bppIndexed since the other device cannot handle indexed bitmaps)

 Bitmap img = new Bitmap(imgPath);
 Bitmap img8 = new Bitmap(imgW, imgH, PixelFormat.Format16bppRgb565);
 for (int I = 0; I <= img.Width - 1; I++) {
     for (int J = 0; J <= img.Height - 1; J++) {
         img8.SetPixel(I, J, img.GetPixel(I, J));
     }
 }

So how can I convert an Image into an 8-bit per pixel byte array?

  • Can I use the 8-bit indexed format and extract the bytes? – Format8bppIndexed
  • Can I calculate the pixel colors by reducing the 32-bit color R,G,B values to 8-bit?
  • Is there a C# library that does this already?
  • “The easiest way is to create a new 8 bit bitmap, and draw your 24 bit image onto it.” – how?
  • 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-12T21:58:52+00:00Added an answer on May 12, 2026 at 9:58 pm

    Although I’m not sure how to do it with plain vanilla C# you can use the FreeImage Project libraries to convert images formats:

    FreeImage is an Open Source library
    project for developers who would like
    to support popular graphics image
    formats like PNG, BMP, JPEG, TIFF and
    others as needed by today’s multimedia
    applications. FreeImage is easy to
    use, fast, multithreading safe,
    compatible with all 32-bit versions of
    Windows, and cross-platform (works
    both with Linux and Mac OS X).

    It’s written in C++ but has good .NET wrappers you can use.

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

Sidebar

Related Questions

I need to convert image sequences(ie,png) to video file in iPhone. How i can
I have an transparent .PNG image that I need to convert into an .CUR
Need to convert pdf file to image file (jpg, png, gif) to show on
I want to convert the input 24 bit PNG image to 8 bit, I
I need to efficiently convert a JPG image to a PNG image with index
I need to convert from PNG to JPG. However, iMagick adds a black background
I need to upload an image from a rails form using Ajax and convert
I need to convert the video into png images. I did that using ffmepg.
I need to convert PNG file to BMP file on runtime. I can't do
I need to convert SVG content to a raster image (preferably a PNG) in

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.