Hello all. I'd like to create a WriteableBitmap object that I can then assign to an "Image" control. I need to be able to (repetitively) alter the actual physical pixels in a 1:1 fashion in the Image control i.e. I don't want the system to perform any scaling. To do this, I'm querying the Image control's "ActualWidth" and "ActualHeight" properties and determining the height/width in pixels as follows:
HwndSource windowHandleSource = PresentationSource.FromVisual(this) as HwndSource; PixelHeight = (Int32)Math.Round(image1.Height * windowHandleSource.CompositionTarget.TransformToDevice.M22); PixelWidth = (Int32)Math.Round(image1.Width * windowHandleSource.CompositionTarget.TransformToDevice.M11);
I then create a WriteableBitmap of dimensions PixelHeight x PixelWidth...but I'm confused about the dpiX and dpiY arguments I need to pass into the WriteableBitmap constructor. Should these arguments be:
Double DpiX = 96.0 * windowHandleSource.CompositionTarget.TransformToDevice.M11; Double DpiY = 96.0 * windowHandleSource.CompositionTarget.TransformToDevice.M22;
?
Again, I'm just trying to generate a WriteableBitmap object to assign to an "Image" controls "Source" property such that I can perform a 1:1 pixel alteration for monitors of various dpi. Thanks in advance.