smourier / DirectN

Direct interop Code for .NET Framework, .NET Core and .NET 5+ : DXGI, WIC, DirectX 9 to 12, Direct2D, Direct Write, Direct Composition, Media Foundation, WASAPI, CodecAPI, GDI, Spatial Audio, DVD, Windows Media Player, UWP DXInterop, WinUI3, etc.
MIT License
315 stars 28 forks source link

System.ComponentModel.Win32Exception when set D2D1_STRAIGHTEN_PROP.D2D1_STRAIGHTEN_PROP_MAINTAIN_SIZE in Direct2DEffects.CLSID_D2D1Straighten #60

Closed Charltsing closed 2 months ago

Charltsing commented 3 months ago

System.ComponentModel.Win32Exception HResult=0x80004005 Message=参数错误。 Source=DirectNStandard StackTrace: 在 DirectN.HRESULT.ThrowOnErrorExcept(IEnumerable`1 exceptedValues, Boolean throwOnError)

在 DirectN.HRESULT.ThrowOnError(Boolean throwOnError)

在 DirectN.ID2D1PropertiesExtensions.SetValue(ID2D1Properties properties, Int32 index, Object value)

在 DirectN.ID2D1PropertiesExtensions.SetValue(IComObject`1 properties, Int32 index, Object value)

捕获

DirectN 1.16.1

How should I set D2D1_STRAIGHTEN_PROP_MAINTAIN_SIZE parameters ?

smourier commented 3 months ago

Hi,

There's a small bug in extensions methods for boolean value, you can set it more directly like this:

false:

fx.SetValue((int)D2D1_STRAIGHTEN_PROP.D2D1_STRAIGHTEN_PROP_MAINTAIN_SIZE,
    D2D1_PROPERTY_TYPE.D2D1_PROPERTY_TYPE_BOOL,
    BitConverter.GetBytes(0));

true:

fx.SetValue((int)D2D1_STRAIGHTEN_PROP.D2D1_STRAIGHTEN_PROP_MAINTAIN_SIZE,
    D2D1_PROPERTY_TYPE.D2D1_PROPERTY_TYPE_BOOL,
    BitConverter.GetBytes(1));
Charltsing commented 3 months ago

Thanks for your reply. I am waiting for the bug be fixed in future versions.

smourier commented 2 months ago

It should be fixed by latest commit https://github.com/smourier/DirectN/commit/46512bb160e0dfe5917c12974bc1fd147dac7191