@@ -23,13 +23,30 @@ public static DrawingCanvas<TPixel> CreateCanvas<TPixel>(
2323 DrawingOptions options ,
2424 params IPath [ ] clipPaths )
2525 where TPixel : unmanaged, IPixel < TPixel >
26+ => CreateCanvas ( frame , frame . Configuration , options , clipPaths ) ;
27+
28+ /// <summary>
29+ /// Creates a drawing canvas over an existing frame.
30+ /// </summary>
31+ /// <typeparam name="TPixel">The pixel format.</typeparam>
32+ /// <param name="frame">The frame backing the canvas.</param>
33+ /// <param name="configuration">The configuration to use for this canvas instance.</param>
34+ /// <param name="options">Initial drawing options for this canvas instance.</param>
35+ /// <param name="clipPaths">Initial clip paths for this canvas instance.</param>
36+ /// <returns>A drawing canvas targeting <paramref name="frame"/>.</returns>
37+ public static DrawingCanvas < TPixel > CreateCanvas < TPixel > (
38+ this ImageFrame < TPixel > frame ,
39+ Configuration configuration ,
40+ DrawingOptions options ,
41+ params IPath [ ] clipPaths )
42+ where TPixel : unmanaged, IPixel < TPixel >
2643 {
2744 Guard . NotNull ( frame , nameof ( frame ) ) ;
2845 Guard . NotNull ( options , nameof ( options ) ) ;
2946 Guard . NotNull ( clipPaths , nameof ( clipPaths ) ) ;
3047
3148 return new DrawingCanvas < TPixel > (
32- frame . Configuration ,
49+ configuration ,
3350 new Buffer2DRegion < TPixel > ( frame . PixelBuffer , frame . Bounds ) ,
3451 options ,
3552 clipPaths ) ;
@@ -50,13 +67,32 @@ public static DrawingCanvas<TPixel> CreateCanvas<TPixel>(
5067 DrawingOptions options ,
5168 params IPath [ ] clipPaths )
5269 where TPixel : unmanaged, IPixel < TPixel >
70+ => CreateCanvas ( image , frameIndex , image . Configuration , options , clipPaths ) ;
71+
72+ /// <summary>
73+ /// Creates a drawing canvas over a specific frame of an image.
74+ /// </summary>
75+ /// <typeparam name="TPixel">The pixel format.</typeparam>
76+ /// <param name="image">The image containing the frame.</param>
77+ /// <param name="frameIndex">The zero-based frame index to target.</param>
78+ /// <param name="configuration">The configuration to use for this canvas instance.</param>
79+ /// <param name="options">Initial drawing options for this canvas instance.</param>
80+ /// <param name="clipPaths">Initial clip paths for this canvas instance.</param>
81+ /// <returns>A drawing canvas targeting the selected frame.</returns>
82+ public static DrawingCanvas < TPixel > CreateCanvas < TPixel > (
83+ this Image < TPixel > image ,
84+ int frameIndex ,
85+ Configuration configuration ,
86+ DrawingOptions options ,
87+ params IPath [ ] clipPaths )
88+ where TPixel : unmanaged, IPixel < TPixel >
5389 {
5490 Guard . NotNull ( image , nameof ( image ) ) ;
5591 Guard . NotNull ( options , nameof ( options ) ) ;
5692 Guard . NotNull ( clipPaths , nameof ( clipPaths ) ) ;
5793 Guard . MustBeBetweenOrEqualTo ( frameIndex , 0 , image . Frames . Count - 1 , nameof ( frameIndex ) ) ;
5894
59- return image . Frames [ frameIndex ] . CreateCanvas ( options , clipPaths ) ;
95+ return image . Frames [ frameIndex ] . CreateCanvas ( configuration , options , clipPaths ) ;
6096 }
6197
6298 /// <summary>
@@ -72,11 +108,28 @@ public static DrawingCanvas<TPixel> CreateCanvas<TPixel>(
72108 DrawingOptions options ,
73109 params IPath [ ] clipPaths )
74110 where TPixel : unmanaged, IPixel < TPixel >
111+ => CreateCanvas ( image , image . Configuration , options , clipPaths ) ;
112+
113+ /// <summary>
114+ /// Creates a drawing canvas over the root frame of an image.
115+ /// </summary>
116+ /// <typeparam name="TPixel">The pixel format.</typeparam>
117+ /// <param name="image">The image whose root frame should be targeted.</param>
118+ /// <param name="configuration">The configuration to use for this canvas instance.</param>
119+ /// <param name="options">Initial drawing options for this canvas instance.</param>
120+ /// <param name="clipPaths">Initial clip paths for this canvas instance.</param>
121+ /// <returns>A drawing canvas targeting the root frame.</returns>
122+ public static DrawingCanvas < TPixel > CreateCanvas < TPixel > (
123+ this Image < TPixel > image ,
124+ Configuration configuration ,
125+ DrawingOptions options ,
126+ params IPath [ ] clipPaths )
127+ where TPixel : unmanaged, IPixel < TPixel >
75128 {
76129 Guard . NotNull ( image , nameof ( image ) ) ;
77130 Guard . NotNull ( options , nameof ( options ) ) ;
78131 Guard . NotNull ( clipPaths , nameof ( clipPaths ) ) ;
79132
80- return image . Frames . RootFrame . CreateCanvas ( options , clipPaths ) ;
133+ return image . Frames . RootFrame . CreateCanvas ( configuration , options , clipPaths ) ;
81134 }
82135}
0 commit comments