Question

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.

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.

Was it helpful?

Solution

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;

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top