DpiValue::DpiValue() { #if defined(_DEBUG) && defined(DPI_144) SetDpi(144,144); #else SetDpi(96,96); #endif }
DpiValue::DpiValue() { #if defined(_DEBUG) && defined(DPI_DEBUG_CUSTOM) SetDpi(DPI_DEBUG_CUSTOM,DPI_DEBUG_CUSTOM); #else SetDpi(96,96); #endif }
DpiValue::DpiValue(WPARAM wParam) { #if defined(_DEBUG) && defined(DPI_144) SetDpi(144,144); #else SetDpi(96,96); #endif OnDpiChanged(wParam); }
DpiValue::DpiValue(WPARAM wParam) { #if defined(_DEBUG) && defined(DPI_DEBUG_CUSTOM) SetDpi(DPI_DEBUG_CUSTOM,DPI_DEBUG_CUSTOM); #else SetDpi(96,96); #endif OnDpiChanged(wParam); }
void DpiValue::OnDpiChanged(WPARAM wParam) { // That comes from WM_DPICHANGED notification message if ((int)LOWORD(wParam) > 0 && (int)HIWORD(wParam) > 0) { SetDpi((int)LOWORD(wParam), (int)HIWORD(wParam)); _ASSERTE(Ydpi >= 96 && Xdpi >= 96); } }
void FrameworkView::UpdateLogicalDPI() { ComPtr<ABI::Windows::Graphics::Display::IDisplayPropertiesStatics> dispProps; HRESULT hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(), dispProps.GetAddressOf()); AssertHRESULT(hr); FLOAT value; AssertHRESULT(dispProps->get_LogicalDpi(&value)); SetDpi(value); }
static std::shared_ptr<CanvasSwapChainDrawingSessionAdapter> Create( ICanvasDevice* owner, IDXGISwapChain1* swapChainResource, D2D1_COLOR_F const& clearColor, float dpi, ID2D1DeviceContext1** outDeviceContext) { auto deviceContext = As<ICanvasDeviceInternal>(owner)->CreateDeviceContextForDrawingSession(); DXGI_SWAP_CHAIN_DESC1 swapChainDescription; ThrowIfFailed(swapChainResource->GetDesc1(&swapChainDescription)); ComPtr<IDXGISurface2> backBufferSurface; ThrowIfFailed(swapChainResource->GetBuffer(0, IID_PPV_ARGS(&backBufferSurface))); ComPtr<ID2D1Bitmap1> d2dTargetBitmap; D2D1_BITMAP_PROPERTIES1 bitmapProperties = D2D1::BitmapProperties1(); bitmapProperties.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW; bitmapProperties.pixelFormat.format = swapChainDescription.Format; bitmapProperties.pixelFormat.alphaMode = ConvertDxgiAlphaModeToD2DAlphaMode(swapChainDescription.AlphaMode); ThrowIfFailed(deviceContext->CreateBitmapFromDxgiSurface(backBufferSurface.Get(), &bitmapProperties, &d2dTargetBitmap)); deviceContext->SetTarget(d2dTargetBitmap.Get()); deviceContext->BeginDraw(); // // If this function fails then we need to call EndDraw // auto endDrawWarden = MakeScopeWarden([&] { ThrowIfFailed(deviceContext->EndDraw()); }); ThrowIfFailed(deviceContext.CopyTo(outDeviceContext)); auto adapter = std::make_shared<CanvasSwapChainDrawingSessionAdapter>(); deviceContext->Clear(&clearColor); deviceContext->SetDpi(dpi, dpi); // // This function can't fail now, so we can dismiss the end draw warden. // endDrawWarden.Dismiss(); return adapter; }
void DpiValue::SetDpi(const DpiValue& dpi) { SetDpi(dpi.Xdpi, dpi.Ydpi); }
DpiValue::DpiValue(int xdpi, int ydpi) { SetDpi(xdpi, ydpi); }