WPF rendering a Viewport3D to RenterTargetBitmap changes RGB values

Thomas V 6 Reputation points

I'm trying to render a Viewport3D with textured triangles to a RenderTargerBitmap.

But the colors in the bitmap are different than in the viewport:


  • Right side: an actual in-app Viewport3D.
  • Left side: the RenderTargetBitmap shown in a Image Stretch="None". All colors have lower RGB values from the viewport (and the original textures) The antialiased grays are a lot darker than the original, making it seem like aliasing issues (which it isn't). But also the filling colors are shifted.

I use this code to make the bitmap:

var renderTarget = new RenderTargetBitmap(500, 500, 144, 144, PixelFormats.Default);  
yield return renderTarget;  

I have a 150% zoom set in Windows, so I use 144 dpi (gotten via PresentationSource), but it's the same issue with 96: the pixel colors shift.

I converted my entire app from WPF .net core to .net framework hoping it was a bug in core, but i get the exact same color shifting.

2 questions:

  • Any ideas how to fix this?
  • Alternatives to get the actual pixel values of the Viewport3D?
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
759 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Thomas V 6 Reputation points

    I have done more testing in a small new WPF app. It seems all rendering of WPF visuals to a RenderTargetBitmap are off

    These are 2 real buttons, and below it, a bitmap render of those 2 buttons:


    I'm starting to think the RenderTargetBitmap.Render uses an entirely different rendering pipeline (software maybe?), showing a lot of differences.

    So, unusable for my animation app.. :(

    0 comments No comments