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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:20:49+00:00 2026-06-17T12:20:49+00:00

I am doing some image processing on a custom class representing 16 bit gray-scale

  • 0

I am doing some image processing on a custom class representing 16 bit gray-scale images.
The intensity of the pixels is stored in a single dimension ushort array: ushort[] data
I also have the width, the height, the dpi, the stride, if necessary.

My motivation is the following: I show the results of certain operations quite fast, but the conversion from the array to the bitmapsource to the image object is too lengthy, so I was thinking of an Image object which drew its “source” directly from the array. I could thus write a method “update()” instead of doing multiple conversions.

1/ Is this possible?

2/ Would it be faster?

3/ How would I go about doing it?

The way I currently draw the image is with the following code (there’s a bit more to that, but essetially that the heart of it)

BitmapSource bmps = BitmapSource.Create(Width, Height, Dpi, Dpi, PixelFormats.Gray16, null,
                                     data, stride); 
image.Source=bmps;

Thank you!

  • 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-17T12:20:50+00:00Added an answer on June 17, 2026 at 12:20 pm

    Instead of using a separate array to store pixels and then creating a BitmapSource to show the results, I think it would be better using a WriteableBitmap, this way you can store pixel data (16-bit greyscale values) directly in its BackBuffer. Thus you can code something like this:

        // You create "bmp" just once and then update its content when needed
        var bmp = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Gray16, null);
        var imgRect = new Int32Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight);
    

    Then you update the image:

        bmp.Lock();
        ApplySomeFilter(bmp.BackBuffer, ImageFilter.Blur);   // this is just an example ;)
        bmp.AddDirtyRect(imgRect);
        bmp.Unlock();
    

    The ApplySomeFilter method can use unsafe code to modify pixel data of the WriteableBitmap.


    For example, if ApplySomeFilter is defined like this:

        unsafe public void ApplySomeFilter(void* imgBuffer, ImageFilter filter)
        {
            // code that modifies pixels goes here
        }
    

    then you can call it this way:

        ApplySomeFilter(bmp.BackBuffer.ToPointer(), ImageFilter.Blur);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After doing some processing on an audio or image array, it needs to be
Basically, I'm doing some sort of image processing using a screen-sized rectangle made of
Im doing some image processing and I have the coordinates of the 4 points
Basically, I'm doing some image processing and using a QImage in a QLabel to
So, I'm doing some image processing in MATLAB, and attempting to save a file
I'm doing some work on an image processing app (for fun) and am struggling
I'm playing with some manual (walk-the-pixels) image processing, and I'm recreating the standard overlay
I'm really confused here. I am doing some image processing in Cocoa Touch and
I am doing some image processing code in C#, but I cant use any
I am doing some image processing of previews captured by the camera. It is

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.