File tree 12 files changed +134
-11
lines changed
12 files changed +134
-11
lines changed Original file line number Diff line number Diff line change @@ -231,5 +231,7 @@ public static string GetUserDefaultLocaleName()
231
231
public static Direct2dFactory Direct2dFactory => s_direct2dFactory ??= new ( ) ;
232
232
public static DirectWriteFactory DirectWriteFactory => s_directWriteFactory ??= new ( ) ;
233
233
public static DirectWriteGdiInterop DirectWriteGdiInterop => s_directWriteGdiInterop ??= new ( ) ;
234
+
235
+ /// <inheritdoc cref="Windows.Win32.Graphics.Imaging.ImagingFactory"/>
234
236
public static ImagingFactory ImagingFactory => s_imagingFactory ??= new ( ) ;
235
237
}
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public ActiveXControl(
40
40
_classId = classId ;
41
41
IUnknown * unknown = ComHelpers . CreateComClass ( classId ) ;
42
42
_instance = new ( unknown , takeOwnership : true ) ;
43
- _instanceAsActiveObject = unknown ->QueryAgileInterface < IOleInPlaceActiveObject > ( ) ;
43
+ _instanceAsActiveObject = unknown ->TryQueryAgileInterface < IOleInPlaceActiveObject > ( ) ;
44
44
45
45
using ComScope < IOleObject > oleObject = ComScope < IOleObject > . QueryFrom ( unknown ) ;
46
46
if ( oleObject . Pointer ->GetMiscStatus ( DVASPECT . DVASPECT_CONTENT , out OLEMISC status ) . Succeeded )
Original file line number Diff line number Diff line change @@ -248,6 +248,8 @@ IsWindowEnabled
248
248
IsWindowVisible
249
249
IUIAutomationElement
250
250
IUnknown
251
+ IWICBitmapDecoderInfo
252
+ IWICComponentInfo
251
253
IWICImagingFactory2
252
254
KEY_INFORMATION_CLASS
253
255
KEY_NAME_INFORMATION
@@ -386,6 +388,7 @@ UpdateWindow
386
388
USER_DEFAULT_SCREEN_DPI
387
389
VARIANT_*
388
390
VIRTUAL_KEY
391
+ WICComponentEnumerateOptions
389
392
WIN32_ERROR
390
393
WINDOWPOS
391
394
WM_*
Original file line number Diff line number Diff line change 3
3
4
4
namespace Windows . Win32 . Graphics . Imaging ;
5
5
6
+ /// <summary>
7
+ /// WIC Bitmap Decoder.
8
+ /// </summary>
6
9
public unsafe class BitmapDecoder : DirectDrawBase < IWICBitmapDecoder >
7
10
{
8
11
public BitmapDecoder ( IWICBitmapDecoder * pointer ) : base ( pointer ) { }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Jeremy W. Kuhne. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ using Windows . Win32 . System . Com ;
5
+
6
+ namespace Windows . Win32 . Graphics . Imaging ;
7
+
8
+ public unsafe class ComponentEnumerator : DirectDrawBase < IEnumUnknown >
9
+ {
10
+ public ComponentEnumerator ( IEnumUnknown * pointer ) : base ( pointer ) { }
11
+
12
+ public ComponentEnumerator ( WICComponentType componentType )
13
+ : base ( CreateComponentEnumerator ( Application . ImagingFactory , componentType ) )
14
+ {
15
+ }
16
+
17
+ public static IEnumUnknown * CreateComponentEnumerator ( ImagingFactory factory , WICComponentType componentType )
18
+ {
19
+ IEnumUnknown * enumerator ;
20
+ factory . Pointer ->CreateComponentEnumerator (
21
+ ( uint ) componentType ,
22
+ ( uint ) WICComponentEnumerateOptions . WICComponentEnumerateDefault ,
23
+ & enumerator ) . ThrowOnFailure ( ) ;
24
+
25
+ GC . KeepAlive ( factory ) ;
26
+ return enumerator ;
27
+ }
28
+
29
+ public static implicit operator IEnumUnknown * ( ComponentEnumerator d ) => d . Pointer ;
30
+
31
+ public bool Next ( [ NotNullWhen ( true ) ] out ComponentInfo ? componentInfo )
32
+ {
33
+ componentInfo = null ;
34
+ IEnumUnknown * enumerator = this ;
35
+ if ( enumerator is null )
36
+ {
37
+ return false ;
38
+ }
39
+
40
+ uint fetched ;
41
+ using ComScope < IUnknown > unknown = new ( null ) ;
42
+ HRESULT result = enumerator ->Next ( 1 , unknown , & fetched ) ;
43
+ if ( result != HRESULT . S_OK || fetched != 1 )
44
+ {
45
+ return false ;
46
+ }
47
+
48
+ componentInfo = new ( unknown . Pointer ->QueryInterface < IWICComponentInfo > ( ) ) ;
49
+ return true ;
50
+ }
51
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Jeremy W. Kuhne. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ namespace Windows . Win32 . Graphics . Imaging ;
5
+
6
+ public unsafe class ComponentInfo : DirectDrawBase < IWICComponentInfo >
7
+ {
8
+ public ComponentInfo ( IWICComponentInfo * pointer ) : base ( pointer ) { }
9
+
10
+ public ComponentInfo ( Guid componentClassId )
11
+ : base ( CreateComponentInfo ( Application . ImagingFactory , componentClassId ) )
12
+ {
13
+ }
14
+
15
+ public static IWICComponentInfo * CreateComponentInfo ( ImagingFactory factory , Guid componentClassId )
16
+ {
17
+ IWICComponentInfo * info ;
18
+ factory . Pointer ->CreateComponentInfo ( & componentClassId , & info ) . ThrowOnFailure ( ) ;
19
+ GC . KeepAlive ( factory ) ;
20
+ return info ;
21
+ }
22
+
23
+ public string FriendlyName
24
+ {
25
+ get
26
+ {
27
+ uint length ;
28
+ Pointer ->GetFriendlyName ( 0 , null , & length ) . ThrowOnFailure ( ) ;
29
+ char * name = stackalloc char [ ( int ) length ] ;
30
+ Pointer ->GetFriendlyName ( length , name , & length ) . ThrowOnFailure ( ) ;
31
+ return new string ( name ) ;
32
+ }
33
+ }
34
+
35
+ public static implicit operator IWICComponentInfo * ( ComponentInfo d ) => d . Pointer ;
36
+ }
Original file line number Diff line number Diff line change 6
6
7
7
namespace Windows . Win32 . Graphics . Imaging ;
8
8
9
+ /// <summary>
10
+ /// WIC Imaging Factory.
11
+ /// </summary>
9
12
public unsafe class ImagingFactory : DirectDrawBase < IWICImagingFactory2 >
10
13
{
11
14
public ImagingFactory ( ) : base ( Create ( ) ) { }
Original file line number Diff line number Diff line change @@ -9,17 +9,24 @@ namespace Windows.Win32.System.Com;
9
9
10
10
public unsafe partial struct IUnknown : IVTable < IUnknown , IUnknown . Vtbl >
11
11
{
12
- public TInterface * QueryInterface < TInterface > ( ) where TInterface : unmanaged, IComIID
12
+ public TInterface * TryQueryInterface < TInterface > ( ) where TInterface : unmanaged, IComIID
13
13
{
14
14
TInterface * @interface = default ;
15
15
QueryInterface ( IID . Get < TInterface > ( ) , ( void * * ) & @interface ) ;
16
16
return @interface ;
17
17
}
18
18
19
- public AgileComPointer < TInterface > ? QueryAgileInterface < TInterface > ( )
19
+ public TInterface * QueryInterface < TInterface > ( ) where TInterface : unmanaged, IComIID
20
+ {
21
+ TInterface * @interface = default ;
22
+ QueryInterface ( IID . Get < TInterface > ( ) , ( void * * ) & @interface ) . ThrowOnFailure ( ) ;
23
+ return @interface ;
24
+ }
25
+
26
+ public AgileComPointer < TInterface > ? TryQueryAgileInterface < TInterface > ( )
20
27
where TInterface : unmanaged, IComIID
21
28
{
22
- TInterface * @interface = QueryInterface < TInterface > ( ) ;
29
+ TInterface * @interface = TryQueryInterface < TInterface > ( ) ;
23
30
return @interface is null ? null : new ( @interface , takeOwnership : true ) ;
24
31
}
25
32
Original file line number Diff line number Diff line change 13
13
</ItemGroup >
14
14
15
15
<ItemGroup >
16
- <PackageReference Include =" Microsoft.Windows.CsWin32" Version =" 0.3.85-beta " >
16
+ <PackageReference Include =" Microsoft.Windows.CsWin32" Version =" 0.3.106 " >
17
17
<PrivateAssets >all</PrivateAssets >
18
18
<IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
19
19
</PackageReference >
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Jeremy W. Kuhne. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ namespace Windows . Win32 . Graphics . Imaging ;
5
+
6
+ public class ComponentInfoTests
7
+ {
8
+ [ Fact ]
9
+ public void EnumerateDecoders ( )
10
+ {
11
+ ComponentEnumerator enumerator = new ( WICComponentType . WICDecoder ) ;
12
+ while ( enumerator . Next ( out ComponentInfo ? info ) )
13
+ {
14
+ Assert . NotNull ( info ) ;
15
+ Assert . NotNull ( info . FriendlyName ) ;
16
+ }
17
+ }
18
+ }
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ public void StandardDispatch_ImplDoesNotProvideEx()
38
38
& standard ) . ThrowOnFailure ( ) ;
39
39
40
40
// StdDispatch does not provide an implementation of IDispatchEx.
41
- IDispatchEx * dispatchEx = standard ->QueryInterface < IDispatchEx > ( ) ;
41
+ IDispatchEx * dispatchEx = standard ->TryQueryInterface < IDispatchEx > ( ) ;
42
42
Assert . True ( dispatchEx is null ) ;
43
43
44
44
standard ->Release ( ) ;
Original file line number Diff line number Diff line change 9
9
</PropertyGroup >
10
10
11
11
<ItemGroup >
12
- <PackageReference Include =" FluentAssertions" Version =" 6.8 .0" />
13
- <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.4 .0" />
14
- <PackageReference Include =" xunit" Version =" 2.4.2 " />
15
- <PackageReference Include =" xunit.runner.visualstudio" Version =" 2.4.5 " >
12
+ <PackageReference Include =" FluentAssertions" Version =" 6.12 .0" />
13
+ <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.10 .0" />
14
+ <PackageReference Include =" xunit" Version =" 2.9.0 " />
15
+ <PackageReference Include =" xunit.runner.visualstudio" Version =" 2.8.2 " >
16
16
<IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
17
17
<PrivateAssets >all</PrivateAssets >
18
18
</PackageReference >
19
- <PackageReference Include =" coverlet.collector" Version =" 3.2.0 " >
19
+ <PackageReference Include =" coverlet.collector" Version =" 6.0.2 " >
20
20
<IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
21
21
<PrivateAssets >all</PrivateAssets >
22
22
</PackageReference >
You can’t perform that action at this time.
0 commit comments