如何在Windows Phone的像素/ C#工作 [英] How to work with pixels in Windows Phone/C#

查看:138
本文介绍了如何在Windows Phone的像素/ C#工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用比例因子值的Windows Phone 8秤元素,因此所有的像素都是虚拟的,以800×480和价值观,如 ActualWidth的/的ActualHeight 返回假的800x400值。

Windows Phone 8 scales elements using the scale factor value so all pixels are virtual to 800x480 and values such as ActualWidth/ActualHeight return the "fake" 800x400 value.

我显示 WritableBitmap 是动态构造我的UI的背景,并希望它被建造所有可用的像素不是缩放为800x480的图像。我如何禁用缩放和虚拟像素映射是真实的设备像素?

I'm displaying a WritableBitmap that is constructed dynamically on the background of my UI and would like it to be constructed of all available pixels not a scaled 800x480 image. How do I "disable" the scaling and map the virtual pixels to be real device pixels?

我知道如何从比例因子计算的价值,但我想它正确地与图像背景中使用,最好完全禁用,因为它不需要我们的具体使用情况下的功能。

I know how to calculate the value from the scale factor but I'd like it to be used properly with the image background and ideally disable that functionality entirely since its unnecessary for our specific use case.

推荐答案

据看来是没有办法实际上是做到这一点。 。我最终什么事做了伪造它,如果有人有更好的答案,我会很乐意接受

It seems there is no way to "actually" do this. What I ended up doing was faking it, if someone has a better answer I'll be happy to accept that.

我用的比例因子这样的值:

I used the value of ScaleFactor as such:

scaleFactor = ((double)Application.Current.Host.Content.ScaleFactor) / 100.0;



然后我创建可写的位图这样的:

Then I created the writeable bitmap as such:

screen = new WriteableBitmap((int)(cl.ActualWidth * scaleFactor), (int)(cl.ActualHeight * scaleFactor));



并把它放在与背景:

And placed it in the background with:

backgroundImage.Stretch = Stretch.Fill;



看来,这实际上是用正确的图像和图像到屏幕的映射像素,而不是扩展他们。这是一个有点hackish所以如果有一个更好的解决方案,我会很高兴听到这个消息。

It seems that this is actually using the image properly and mapping pixels of the image to the screen rather than scaling them. This is a bit hackish so if there is a better solution I'd be glad to hear it.

这篇关于如何在Windows Phone的像素/ C#工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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