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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:19:35+00:00 2026-06-04T09:19:35+00:00

I have to draw a bitmap image using DrawingContext.DrawImage method. Using the code below

  • 0

I have to draw a bitmap image using DrawingContext.DrawImage method.

Using the code below everything is working correctly:

BitmapImage myImage = new BitmapImage();
myImage.BeginInit();
myImage.UriSource = new Uri("image.png", UriKind.Relative);
myImage.EndInit();

Rect area = new Rect(new Size(myImage.PixelWidth, myImage.PixelHeight));
DrawingVisual myVisual = new DrawingVisual();

using (DrawingContext context = myVisual.RenderOpen())
{ context.DrawImage(myImage, area); }

But only if the image does not exceed 2Mb about, i.e. the area (myImage.PixelWidth x myImage.PixelHeight) is not larger than 10000×10000. In this case the screen remains blank and no any exception is thrown (so I can not tell if there was an error).

How could I fix this problem?
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-04T09:19:37+00:00Added an answer on June 4, 2026 at 9:19 am

    Looks like larger images aren’t yet loaded when you render them. Try the following to load the bitmap:

    BitmapSource myImage = BitmapFrame.Create(
        new Uri("image.png"),
        BitmapCreateOptions.None,
        BitmapCacheOption.OnLoad);
    

    Or this desperate attempt:

    using (Stream fileStream = new FileStream("image.png", FileMode.Open))
    {
        BitmapSource myImage = BitmapFrame.Create(
            fileStream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bitmap object and draw some curves on it by setpixel method.
I have some code that creates a graph using the Bitmap class. The quality
I am using the following code to draw text onto a jpg image but
I have a Format32bppArgb backbuffer, where I draw some lines: var g = Graphics.FromImage(bitmap);
I have tried to draw a bar in a cell of my table. Everything
I have tried to draw Polygon using Drawing Manager and send the Polygon Coordinates
I have this code to draw an ellipse in the screen but I don't
I have a function that draw an image on graphics: private void DrawSmallImage(Graphics g)
How can I create a 256x256 color space image using graphics draw? Currently I'm
I am using a GDI+ Graphic to draw a 4000*3000 image to screen, but

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.