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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:26:18+00:00 2026-06-06T05:26:18+00:00

Currently I am working on a program that lets me handle data in form

  • 0

Currently I am working on a program that lets me handle data in form of an image.
Let’s say I have datapoints that correspond to an image (maybe 300 x 300) and the values range from 0 to 10000 and I would like to display the image in grey values. That would be all fine, if I just split the value range (0-10000) into 256 pieces and assigned them according grey values in bitmap form (I used rgb by setting all colours to be equal).

However, the user has to be able to change the contrast and the brightness. By that I mean:
Let’s say the value that corresponds to black is 3000 (and obviously all values below are also black) and the values that correspond to white are 5000+. The values in between should have a linear dependence on the grey colour. The user will have two sliders, one to change the range of observable values (in this case 2000) and one to shift the range lets say from 3000-5000 to 5000-7000.
The problem is actually to make the sliders work in real time. I tried to simulate the image with one rectangle for each pixel but looping through all rectangles and changing their colours is simply too slow.
Does anyone have any idea, how to make it work nice and smooth?

  • 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-06T05:26:20+00:00Added an answer on June 6, 2026 at 5:26 am

    First, you need to convert your array of double values to an array of byte values. Then you can write this array of byte values to a WriteableBitmap. If you don’t need to repeatedly update the contents of the WriteableBitmap, you should also freeze it to increase performance:

    public static ImageSource GetImage(byte[] rawImageBytes, int width, int height)
    {
        int channels = 1;
        int stride = width * channels;
        var image = new WriteableBitmap(width, height, 96, 96, PixelFormats.Gray8, null);
        image.WritePixels(new Int32Rect(0, 0, width, height), rawImageBytes, stride, 0);
        image.Freeze();
        return image;
    }
    

    If you want to update the content of the WriteableBitmap, you can just call WritePixels on the same instance without freezing the object instance.

    To display the WriteableBitmap in your WPF application, just assign it to the Source property of an Image control.

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

Sidebar

Related Questions

I have a python program that I am currently working on which is working
I have a (C#) genetic program that uses financial time-series data and it's currently
I am currently working on a program, that can handle Minecraft servers. I am
I am currently working on program that must read data from a XML stream
I'm currently working on a C# program that creates a List, of object Task,
I'm working on a program that will sort files based on extension I currently
I'm currently working on a Program, that presses buttons for me. I'm working on
I'm currently working on an a program idea I've had that involves desktop remoting.
I'm currently working on a C++ program in Windows XP that processes large sets
Currently I'm working on an assignment that requires that I create a program 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.