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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:15:31+00:00 2026-06-10T16:15:31+00:00

So Im trying trying to load an image into a WriteableBitmap but I’m getting

  • 0

So Im trying trying to load an image into a WriteableBitmap but I’m getting a NullReferenceException. Can’t figure out why because I think this used to work before

BitmapImage b = new BitmapImage(new Uri(@"images/Car.jpg", Urikind.Relative));
WriteableBitmap wb = new WriteableBitmap(b);

thats it. I have the car image as a resource in my project. It works fine as I can create a Image control and set its source to the BitmapImage and display it.
Thanks

  • 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-10T16:15:33+00:00Added an answer on June 10, 2026 at 4:15 pm

    As seen from other SO questions, it seems that the reason you get the null reference exception is that BitmapImage.CreateOptions Property default value is BitmapCreateOptions.DelayCreation. You can set it to BitmapCreateOptions.None and create WriteableBitmap after image loaded:

    BitmapImage img = new BitmapImage(new Uri("somepath",UriKind.Relative));
    img.CreateOptions = BitmapCreateOptions.None;
    img.ImageOpened += (s, e) =>
       {
           WriteableBitmap wbm = new WriteableBitmap((BitmapImage)s);
       };
    

    Using that code, the WritableBitmap will wait until the BitmapImage is loaded, and then it will be able to be assigned to the WritableBitmap.

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

Sidebar

Related Questions

I'm trying to load an image into an UIImageView from the internet. This is
I'm trying to load about 600 small images into memory. Size of each image
I am trying to load an image but it is showing the error message
I am trying to load an image in memory but might have memory issues
I'm trying to load an image through PHP, but I don't know how. The
I am trying to load the image in the following way. But when I
I'm trying to load a local image into a JTextPane, and the program relentlessly
I am trying to load an svg image into canvas for pixel manipulation I
I am trying to load big image files in Java and i am getting
I'm trying to load an image into the cell, The following code is working

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.