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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:58:44+00:00 2026-05-17T01:58:44+00:00

I am trying to read in the pixel data from an image file as

  • 0

I am trying to read in the pixel data from an image file as a byte[], for in-memory storage. (The byte array will later be fed to a bitmap image object, but I want the data in memory so that there’s no I/O holdup.)

This is what I’m currently doing:

private byte[] GetImageBytes(Uri imageUri) {

     //arraySize and stride previously defined

    var pixelArray = new byte[arraySize];
    new BitmapImage(imageUri).CopyPixels(pixelArray , stride, 0);

    return pixelArray ;
}

I am wondering if someone knows of a way to get the byte[] data other than making a BitmapImage and then copying all of the bytes out. I.e. is there a .NET class that will just stream pixel data from the file? (I was originally using File.ReadAllBytes, but that brings in other stuff like the image metadata, and wasn’t working out.)

  • 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-17T01:58:44+00:00Added an answer on May 17, 2026 at 1:58 am

    I will answer my own question, in case anyone else finds it useful:

    The reason I had originally wanted to read the data into a byte array was so that I could do the file or network IO on a background thread. But I have since learned about the Freeze() method, which lets the image be read on a background thread and then shared across threads.

    So if I freeze the BitmapImage, the impetus for temporarily storing the data in a byte[] goes away, and the problem is solved.

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

Sidebar

Related Questions

I'm trying to read variables from a batch file for later use in the
I am trying to read a single file from a java.util.zip.ZipInputStream , and copy
I am trying to read an XML-file from another server. However the the company
I'm currently trying to read in an XML file, make some minor changes (alter
I'm trying to read a .doc file into a database so that I can
I am trying to read ASCII text response from a tcp open streaming socket
I'm trying to read a file to produce a DOM Document, but the file
I'm trying to read a 16-bit greyscale TIFF file (BitsPerSample=16) using a small C
I'm trying to get the pixel rgb values from a 64 x 48 bit
I am trying to expose a buffer of image pixel information (32 bit RGBA)

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.