渲染目标位图质量问题 [英] Render target bitmap quality issues

查看:139
本文介绍了渲染目标位图质量问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这是一个简单的情况,我使用RenderTargetBitmap @分辨率600 * 600 @ 96 dpi渲染了一个viewport3d对象,问题是视口和保存的图像之间在质量上存在很大的差异:

这是一些代码:

ok, it''s a simple case, i rendered a viewport3d object using RenderTargetBitmap @ resolution 600 * 600 @ 96 dpi, the problem is there are a big deference in quality between the view port and the saved image:

here are some code:

''rendering viewport3D to image
Dim viewportPlate As New RenderTargetBitmap(600, 600, 96 , 96 , PixelFormats.Pbgra32)
viewportPlate.Render(viewport3d)

''path to save
Dim path As String = imgSave
Dim fs As FileStream = New FileStream(path, FileMode.Create)

''encoding to PNG and saving
Dim encoder As BitmapEncoder = New PngBitmapEncoder()
encoder.Frames.Add(BitmapFrame.Create(viewportPlate))
encoder.Save(fs)





现在我尝试渲染到较大的分辨率,然后将其缩小以使其更好,但是出现了新的问题,即渲染时间长(由于软件渲染)和内存不足问题!!

我使用的是.net 4.0,是否有一种清晰的方法来实现更好的抗锯齿解决方案和渲染时间,就像GDI +一样,我认为这是WPF以外的一种好方法???

任何提示都将受到欢迎:)





now i tried to render to a larger resolution then scale it down and it got better, but a new problem arises of the big render time (because of the software rendering) and the out of memory issues!!!

i''m using .net 4.0, is there a clear way to achieve a better anti-aliased solutions and render times, as it was for GDI+ which i consider is a bless besides WPF?????

any tips will be welcome :)

推荐答案

首先,我必须道歉,因为我要向您展示的扩展方法是C#,但不应这样做.将其转换为VB并不难.
First of all, I must apologise because the extension method I''m going to show you is C#, but it shouldn''t be too hard for you to convert it into VB.
public static RenderTargetBitmap RenderBitmap(this Visual visualToRender)
{
  double scale = 600 / 96;
  RenderTargetBitmap bmp = new RenderTargetBitmap
  (
    (int)(scale * (visualToRender.ActualWidth + 1)),
    (int)(scale * (visualToRender.ActualHeight + 1)),
    scale * 96,
    scale * 96,
    PixelFormats.Default
  );
  bmp.Render(visualToRender);
  return bmp;
}


OP无法使用此代码示例,因为他需要再次缩放图像,并且过程缓慢.

您这里遇到的问题是RenderTargetBitmap不使用硬件渲染.它完全是软件渲染的,因此渲染速度过慢的原因也很重要(这也可以解释为什么质量降低).如果您愿意在应用程序中引入外部资源,则可以使用SlimDX(免费的DirectX包装器)从应用程序渲染视口.


The OP cannot use this code sample because he needs to scale the image again, and the process is slow.

The issue you have here is that RenderTargetBitmap does not use hardware rendering. It is entirely software rendered, hence the reason that it is prohibitively slow to render (this also counts to explain why the quality is reduced). If you could bear to introduce an external resource into your application, you could use SlimDX (a free DirectX wrapper) to render the viewport from your application.


这篇关于渲染目标位图质量问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆