terrafx / terrafx.interop.windows

Interop bindings for Windows.
MIT License
250 stars 31 forks source link

Transcription bug in SetDpiCompensatedEffectInput #336

Closed rickbrew closed 1 year ago

rickbrew commented 1 year ago

The check for inputBitmap != null should be inputBitmap == null. Otherwise this method does nothing when given a bitmap, or will AV when given null when it calls inputBitmap->GetDpi(...):

public unsafe static HRESULT SetDpiCompensatedEffectInput(ID2D1DeviceContext* deviceContext, ID2D1Effect* effect, uint inputIndex, ID2D1Bitmap* inputBitmap, D2D1_INTERPOLATION_MODE interpolationMode = D2D1_INTERPOLATION_MODE.D2D1_INTERPOLATION_MODE_LINEAR, D2D1_BORDER_MODE borderMode = D2D1_BORDER_MODE.D2D1_BORDER_MODE_HARD)
{
    HRESULT hr = 0;
    ID2D1Effect* dpiCompensationEffect = null;
    if (inputBitmap != null)
    {
        effect->SetInput(inputIndex, null, 1);
        return hr;
    }
        ...
}
rickbrew commented 1 year ago

I think @Sergio0694 has been writing code for ComputeSharp.D2D1 / Win2D that makes use of this.