WPF中的位图处理 [英] Bitmap handling in WPF

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

问题描述

我有来自相机的灰度光栅图像数据.我想在WPF应用程序中显示此数据.我使用BitmapSource.Create(...)从原始"数据创建图像,然后将其显示在Image控件中.不幸的是,即使显示尺寸和图像尺寸相同,WPF也会对图像进行插值,并且插值会丢失像素.

我找到了另一种选择:托管WinForms PictureBox控件,该控件似乎在不进行插值的情况下渲染位图.这是可行的,但是很丑.

I have gray-scale raster image data from a camera. I want to display this data in my WPF application. I''ve used BitmapSource.Create(...) to create the image from the ''raw'' data, and then displayed it in an Image control. Unfortunately, WPF interpolates the image, and the interpolation loses pixels, even when the display size and the image size are identical.

I''ve found an alternative: hosting a WinForms PictureBox control, which seems to render the bitmap without interpolation. This is workable but ugly.

Is there a WPF way to render a bitmap without the interpolation?

推荐答案

虽然可能不太漂亮,但您可以尝试调整Image控件的大小以使其完全匹配的大小.放置在其中的图像.

这可能会阻止它对图像进行插值.
While it may not be pretty, you could try sizing your Image control to exactly match the size of the image placed in it.

This may prevent it from interpolating the image.


您在WPF中面临的另一个问题是,它会检查图像的DPI并进行相应缩放.这是一场噩梦,您无能为力,也无能为力地设置图像的DPI.也许您的DPI需要与屏幕DPI匹配才能不进行拉伸?
One other issue you face in WPF is that it checks the DPI of your image and scales it accordingly. This is a NIGHTMARE, there''s nothing you can do about it, and nothing you can do to easily set the DPI of an image. Perhaps your DPI needs to match the screen DPI in order for no stretching to take place ?


这篇关于WPF中的位图处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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