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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:56:16+00:00 2026-06-05T06:56:16+00:00

I am currently having the following problem: I want to convert a byte array

  • 0

I am currently having the following problem: I want to convert a byte array that comes from a file with the following configuration:

Byte1: R color of pixel 0,0.
Byte2: G color of pixel 0,0.
Byte3: B color of pixel 0,0.
Byte4: R color of pixel 0,1.

...
ByteN: R color of pixel n,n.

So what I want to do is convert these bytes into a bitmap without having to set pixel by pixel with bitmap.setPixel because it takes too long.

Any suggestions? Thanks in advance!

  • 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-05T06:56:17+00:00Added an answer on June 5, 2026 at 6:56 am

    If you have the byte[] of the pixels, and the width and height, then you can use BitmapData to write the bytes to the bitmap since you also know the format. Here’s an example:

    //Your actual bytes
    byte[] bytes = {255, 0, 0, 0, 0, 255};
    var width = 2;
    var height = 1;
    //Make sure to clean up resources
    var bitmap = new Bitmap(width, height);
    var data = bitmap.LockBits(new Rectangle(Point.Empty, bitmap.Size), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
    Marshal.Copy(bytes, 0, data.Scan0, bytes.Length);
    bitmap.UnlockBits(data);
    

    This is a very fast operation.

    You will need to import these three namespaces at the top of your C# file, at minimum:

    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Runtime.InteropServices;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method that currently returns a string converted from a byte array:
I have a method that currently returns a string converted from a byte array:
I'm currently having the following problem: I've got a TableView that is given TableRow's
I'm currently having a small problem with the following regex in PHP: preg_match_all('/(.*)(XS|S|M|XL|XXL|L)(.*)/i', '00236XL00',
I'm currently having following error message when executing a .sql file with about 26MB
Hi currently I have a nested XMl , having the following Structure : <?xml
im currently having troubles on my codes in C#. I want to split strings
I'm currently having a problem in displaying some stuff in ListView . I have
I'm currently having problems having the UI refresh when I'm getting new data from
I'm having problem at mipmapping the textures on different hardware. I use the following

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.