DpiHelper Class

Visual Studio 2015
 

A helper class for scaling coordinates and images according to current DPI scaling set in Windows for the screen.

Namespace:   Microsoft.VisualStudio.Utilities.Dpi
Assembly:  Microsoft.VisualStudio.Utilities (in Microsoft.VisualStudio.Utilities.dll)


public class DpiHelper

NameDescription
System_CAPS_protmethodDpiHelper(Double)

Initializes a new instance of DpiHelper.

NameDescription
System_CAPS_pubpropertyBitmapScalingMode

The BitmapScalingMode.

System_CAPS_pubpropertySystem_CAPS_staticDefault

eturns a DpiHelper class suitable for scaling images designed for 100% DPI zoom levels (96dpi).

System_CAPS_pubpropertyDeviceDpiX

Gets the screen's (device) current horizontal DPI.

System_CAPS_pubpropertyDeviceDpiY

The screen's (device) current vertical DPI.

System_CAPS_pubpropertyDeviceToLogicalUnitsScalingFactorX

Converts to the horizontal logical units scaling factor.

System_CAPS_pubpropertyDeviceToLogicalUnitsScalingFactorY

Converts to the vertical logical units scaling factor.

System_CAPS_pubpropertyDpiScalePercentX

System_CAPS_pubpropertyDpiScalePercentY

System_CAPS_pubpropertyImageScalingMode

Gets the ImageScalingMode algorithm to be used for resizing images in WinForms/Win32. This allows the shell to control the algorithm depending on the DPI zoom scale, and allows the user to override it via registry settings like General\ImageScalingXXX = (ImageScalingMode)value, with XXX the zoom factor in percents, e.g. ImageScaling150, etc.

System_CAPS_pubpropertyIsScalingRequired

Determines whether scaling is required when converting between logical-device units

System_CAPS_pubpropertyLogicalDpiX

Gets the helper's logical horizontal DPI.

System_CAPS_pubpropertyLogicalDpiY

Gets the helper's vertical horizontal DPI.

System_CAPS_pubpropertyLogicalToDeviceUnitsScalingFactorX

System_CAPS_pubpropertyLogicalToDeviceUnitsScalingFactorY

System_CAPS_pubpropertyPreScaledImageLayoutTransformScaleX

Gets the horizontal scale value that should be used with a LayoutTransform/ScaleTransform to scale back an image pre-scaled in HighDPI with DpiPrescaleImageSourceConverter in order to obtain crisp results.

System_CAPS_pubpropertyPreScaledImageLayoutTransformScaleY

Gets the vertical scale value that should be used with a LayoutTransform/ScaleTransform to scale back an image pre-scaled in HighDPI with DpiPrescaleImageSourceConverter in order to obtain crisp results.

System_CAPS_pubpropertyTransformFromDevice

System_CAPS_pubpropertyTransformToDevice

System_CAPS_pubpropertyUsePreScaledImages

Determines whether images should be pre-scaled at zoom levels higher than 200%, using NearestNeighbor up to the largest multiple of 100%

NameDescription
System_CAPS_pubmethodCreateDeviceFromLogicalImage(Bitmap, Size, Color, ImageScalingMode)

Creates and returns a new bitmap strip from the logical Bitmap scaled for the device units. When displayed on the device, the scaled image strip will have same size as the original image strip would have when displayed at 96dpi. This should be used for converting imagelists bitmap strips instead of simply scaling the bitmap, because the resultant bitmap strip size may be different from just upscaling as bitmap N * Math.Round(width * dpiscale) != Math.Round(N * width * dpiscale). This may happen depending on the image width because dpiscale is a double not an int.

System_CAPS_pubmethodCreateDeviceFromLogicalImage(Bitmap, Size, ImageScalingMode)

Creates and returns a new bitmap strip from the logical Bitmap scaled for the device units. When displayed on the device, the scaled image strip will have same size as the original image strip would have when displayed at 96dpi. This should be used for converting imagelists bitmap strips instead of simply scaling the bitmap, because the resultant bitmap strip size may be different from just upscaling as bitmap N * Math.Round(width * dpiscale) != Math.Round(N * width * dpiscale). This may happen depending on the image width because dpiscale is a double not an int.

System_CAPS_pubmethodCreateDeviceFromLogicalImage(Icon, ImageScalingMode)

Creates and returns a new icon scaled for the device units. When displayed on the device, the scaled icon will have same size as the original icon would have when displayed at 96dpi.

System_CAPS_pubmethodCreateDeviceFromLogicalImage(Image, Color, ImageScalingMode)

Creates and returns a new ImageList scaled for the device units. When displayed on the device, the scaled ImageList will have same size as the original ImageList would have when displayed at 96dpi.

System_CAPS_pubmethodCreateDeviceFromLogicalImage(Image, ImageScalingMode)

Creates and returns a new bitmap or metafile from the logical Image scaled for the device units. When displayed on the device, the scaled image will have same size as the original image would have when displayed at 96dpi.

System_CAPS_pubmethodCreateDeviceFromLogicalImage(ImageList, Color, ImageScalingMode)

Creates and returns a new ImageList scaled for the device units. When displayed on the device, the scaled ImageList will have same size as the original imagelist would have when displayed at 96dpi.

System_CAPS_pubmethodCreateDeviceFromLogicalImage(ImageList, ImageScalingMode)

Creates and returns a new ImageList scaled for the device units. When displayed on the device, the scaled ImageList will have same size as the original ImageList would have when displayed at 96dpi.

System_CAPS_pubmethodDeviceToLogicalUnits(Point)

Returns a new Point with the input's coordinates converted from device units to logical units.

System_CAPS_pubmethodDeviceToLogicalUnits(Rect)

Returns a new Rect with the input's coordinates converted from device units to logical units.

System_CAPS_pubmethodDeviceToLogicalUnits(Size)

Returns a new Size with the input's dimensions converted from device units to logical units.

System_CAPS_pubmethodDeviceToLogicalUnits(Thickness)

Returns a new Thickness with the input's dimensions converted from device units to logical units.

System_CAPS_pubmethodDeviceToLogicalUnitsX(Double)

Transforms a horizontal coordinate from device to logical units.

System_CAPS_pubmethodDeviceToLogicalUnitsX(Int32)

Transforms a horizontal integer coordinate from device to logical units.

System_CAPS_pubmethodDeviceToLogicalUnitsX(Single)

System_CAPS_pubmethodDeviceToLogicalUnitsY(Double)

Transforms a vertical coordinate from device to logical units.

System_CAPS_pubmethodDeviceToLogicalUnitsY(Int32)

Transforms a vertical coordinate from device to logical units.

System_CAPS_pubmethodDeviceToLogicalUnitsY(Single)

Transforms a vertical coordinate from device to logical units.

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_protmethodGetBitmapScalingModeOverride(Int32, BitmapScalingMode)

Gets the bitmap scaling mode override.

System_CAPS_pubmethodGetDeviceActualSize(FrameworkElement)

Gets the FrameworkElement's Size in device units.

System_CAPS_pubmethodGetDeviceHeight(Window)

Gets the window's height in device units.

System_CAPS_pubmethodGetDeviceLeft(Window)

Gets the window's left coordinate in device units.

System_CAPS_pubmethodGetDeviceRect(Window)

Gets the window's rectangle in device units.

System_CAPS_pubmethodGetDeviceTop(Window)

Gets the window's top in device units.

System_CAPS_pubmethodGetDeviceWidth(Window)

Gets the window's width in device units.

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticGetHelper(Int32)

System_CAPS_protmethodGetImageScalingModeOverride(Int32, ImageScalingMode)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_protmethodGetUsePreScaledImagesOverride(Int32, Boolean)

System_CAPS_pubmethodLogicalToDeviceUnits(Bitmap, Color, ImageScalingMode)

System_CAPS_pubmethodLogicalToDeviceUnits(Bitmap, ImageScalingMode)

System_CAPS_pubmethodLogicalToDeviceUnits(Bitmap, Size, Color, ImageScalingMode)

System_CAPS_pubmethodLogicalToDeviceUnits(Bitmap, Size, ImageScalingMode)

System_CAPS_pubmethodLogicalToDeviceUnits(Icon, ImageScalingMode)

System_CAPS_pubmethodLogicalToDeviceUnits(Image, Color, ImageScalingMode)

System_CAPS_pubmethodLogicalToDeviceUnits(Image, ImageScalingMode)

System_CAPS_pubmethodLogicalToDeviceUnits(ImageList, Color, ImageScalingMode)

System_CAPS_pubmethodLogicalToDeviceUnits(ImageList, ImageScalingMode)

System_CAPS_pubmethodLogicalToDeviceUnits(Point)

System_CAPS_pubmethodLogicalToDeviceUnits(Point)

System_CAPS_pubmethodLogicalToDeviceUnits(PointF)

System_CAPS_pubmethodLogicalToDeviceUnits(Rect)

System_CAPS_pubmethodLogicalToDeviceUnits(Rectangle)

System_CAPS_pubmethodLogicalToDeviceUnits(RectangleF)

System_CAPS_pubmethodLogicalToDeviceUnits(Size)

System_CAPS_pubmethodLogicalToDeviceUnits(Size)

System_CAPS_pubmethodLogicalToDeviceUnits(SizeF)

System_CAPS_pubmethodLogicalToDeviceUnits(Thickness)

System_CAPS_pubmethodLogicalToDeviceUnitsX(Double)

System_CAPS_pubmethodLogicalToDeviceUnitsX(Int32)

System_CAPS_pubmethodLogicalToDeviceUnitsX(Single)

System_CAPS_pubmethodLogicalToDeviceUnitsY(Double)

System_CAPS_pubmethodLogicalToDeviceUnitsY(Int32)

System_CAPS_pubmethodLogicalToDeviceUnitsY(Single)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodRoundToDeviceUnitsX(Double)

System_CAPS_pubmethodRoundToDeviceUnitsY(Double)

System_CAPS_pubmethodScaleLogicalImageForDeviceSize(ImageSource, Size, BitmapScalingMode)

System_CAPS_pubmethodSetDeviceHeight(Window, Double)

System_CAPS_pubmethodSetDeviceLeft(Window, Double)

System_CAPS_pubmethodSetDeviceTop(Window, Double)

System_CAPS_pubmethodSetDeviceWidth(Window, Double)

System_CAPS_pubmethodToString()

(Inherited from Object.)

NameDescription
System_CAPS_protfieldSystem_CAPS_staticDefaultLogicalDpi

The default logical DPI.

This class can be used in assemblies that can't take a dependency on Microsoft.VisualStudio.Shell.14.0 (or later). This class doesn't use any Visual Studio-specific interfaces or services. The code running in Visual Studio or other appids should not be using this class. Instead, it should use the static DpiHelper class from Microsoft.VisualStudio.PlatformUI namespace from the Visual Studio Framework assembly. Usually the code needing Dpi scaling functionality provided by this class should access it by calling the members of the static DpiHelper.Default instance.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: