//---------------------------------------------------------------------------------------------------------------------- // DPI functions //---------------------------------------------------------------------------------------------------------------------- template T DPIScaleWidth(T pixelWidth) { // Calculate a scale value for pixel values based on the current screen DPI settings float dpiScaleX; float dpiScaleY; DPIGetScreenScaleFactors(dpiScaleX, dpiScaleY); // Scale the supplied values based on the DPI scale values pixelWidth = (T)(((float)pixelWidth * dpiScaleX) + 0.5f); // Return the scaled value return pixelWidth; } //---------------------------------------------------------------------------------------------------------------------- template T DPIScaleHeight(T pixelHeight) { // Calculate a scale value for pixel values based on the current screen DPI settings float dpiScaleX; float dpiScaleY; DPIGetScreenScaleFactors(dpiScaleX, dpiScaleY); // Scale the supplied values based on the DPI scale values pixelHeight = (T)(((float)pixelHeight * dpiScaleY) + 0.5f); // Return the scaled value return pixelHeight; } //---------------------------------------------------------------------------------------------------------------------- template T DPIReverseScaleWidth(T pixelWidth) { // Calculate a scale value for pixel values based on the current screen DPI settings float dpiScaleX; float dpiScaleY; DPIGetScreenScaleFactors(dpiScaleX, dpiScaleY); // Scale the supplied values based on the DPI scale values pixelWidth = (T)(((float)pixelWidth / dpiScaleX) + 0.5f); // Return the scaled value return pixelWidth; } //---------------------------------------------------------------------------------------------------------------------- template T DPIReverseScaleHeight(T pixelHeight) { // Calculate a scale value for pixel values based on the current screen DPI settings float dpiScaleX; float dpiScaleY; DPIGetScreenScaleFactors(dpiScaleX, dpiScaleY); // Scale the supplied values based on the DPI scale values pixelHeight = (T)(((float)pixelHeight / dpiScaleY) + 0.5f); // Return the scaled value return pixelHeight; }