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);
renderTarget.Render(SceneViewport);
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?