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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:35:11+00:00 2026-06-09T20:35:11+00:00

I want to create a bitmap from a byte array of pixel in metro

  • 0

I want to create a bitmap from a byte array of pixel in metro Apps. Earlier below function was used for the same:

//Here create the Bitmap to the know height, width and format
  Bitmap bmp = new Bitmap( 352, 288, PixelFormat.Format24bppRgb);  

  //Create a BitmapData and Lock all pixels to be written 
  BitmapData bmpData = bmp.LockBits(
                       new Rectangle(0, 0, bmp.Width, bmp.Height),   
                       ImageLockMode.WriteOnly, bmp.PixelFormat);

  //Copy the data from the byte array into BitmapData.Scan0
  Marshal.Copy(data, 0, bmpData.Scan0, data.Length);


  //Unlock the pixels
  bmp.UnlockBits(bmpData);


  //Return the bitmap 
  return bmp;

but BitmapData class is not present in windows 8 now. Please suggest any alternate way for the same.

thanks,
Pankaj

  • 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-09T20:35:13+00:00Added an answer on June 9, 2026 at 8:35 pm

    If I am not entirely mistaken, part of the code above is taken from the Evil DICOM library, from the ImageHelper.GetBitmap method.

    I have myself made an attempt to port this code to Metro (or whatever Microsoft is going to call it eventually), and here is what the Metro analogue of ImageHelper.GetBitmap looks like in my port:

    public static BitmapSource GetBitmap(float[] pixels, ImageProperties properties)
    {
        var bmp = new WriteableBitmap(properties.Rows, properties.Columns);
    
        using (var stream = bmp.PixelBuffer.AsStream())
        {
            var bytes = new byte[4 * pixels.Length];
            for (int i = 0; i < pixels.Length; i++)
            {
                var greyness = properties.WindowAndLevel.GetValue(pixels[i]);
                bytes[4 * i] = greyness;
                bytes[4 * i + 1] = greyness;
                bytes[4 * i + 2] = greyness;
                bytes[4 * i + 3] = 0xff;
            }
    
            stream.Write(bytes, 0, bytes.Length);
        }
    
        return bmp;
    }
    

    (Actually, I am using stream.WriteAsync in my own code, requiring the method to be declared as async. However, this is irrelevant for the above question as such.)

    This answer is similar to Diogo’s, but if you are not already “there” hopefully this answer can lead you more directly to your goal.

    UPDATE

    I have now published my Evil Dicom port to Metro on Github. You can find the repository here, and here is also a display from a very simple Metro application where I have used this Evil Dicom Metro port:

    Metro DICOM Viewer

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

Sidebar

Related Questions

I want to create a PNG file from a System.Drawing.Bitmap with the colours defined
I want to create a bitmap from a bytearray . I tried the following
I want to load a palette from a bitmap file I have created. The
I want to create a huge resolution Bitmap-image so that to load it into
i want create multiple search where statement $where_search is a multiple condition from post
i want create a custom json data from the mssql 2008 results so that
I want to create an 8-bit indexed image from a regular 32-bit Image object.
I'm using an Uri returned from image gallery to create a Bitmap. I have
I have a 1000x1500 pixel bitmap of which I want to make a mutable
I want to create cube model of a 32x32 bitmap in opengl. For example,

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.