How to work with pixels in Windows Phone / C #

Windows Phone 8 scales elements using a scale factor value, so all pixels are virtual up to 800x480, and values ​​such as ActualWidth/ActualHeightreturn a fake 800x400 value.

I show WritableBitmapwhich is dynamically created against the background of my user interface and would like it to be built from all available pixels, and not a scaled 800x480 image. How to "disable" the scaling and display virtual pixels in the real pixels of the device?

I know how to calculate the value from the scaling factor, but I would like it to be used correctly with the background of the image and ideally disable this functionality completely, since it is not needed for our specific use case.

+3
source share
1 answer

There seems to be no way to "actually" do this. What I finished is fake, if anyone has a better answer, I will be happy to accept this.

I used the ScaleFactor value as such:

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

Then I created a recordable 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;

, , . , , , .

+1

All Articles