@@ -19,25 +19,25 @@ internal static class AlphaEncoder
19
19
/// Data is either compressed as lossless webp image or uncompressed.
20
20
/// </summary>
21
21
/// <typeparam name="TPixel">The pixel format.</typeparam>
22
- /// <param name="image ">The <see cref="ImageFrame{TPixel}"/> to encode from.</param>
22
+ /// <param name="frame ">The <see cref="ImageFrame{TPixel}"/> to encode from.</param>
23
23
/// <param name="configuration">The global configuration.</param>
24
24
/// <param name="memoryAllocator">The memory manager.</param>
25
25
/// <param name="skipMetadata">Whether to skip metadata encoding.</param>
26
26
/// <param name="compress">Indicates, if the data should be compressed with the lossless webp compression.</param>
27
27
/// <param name="size">The size in bytes of the alpha data.</param>
28
28
/// <returns>The encoded alpha data.</returns>
29
29
public static IMemoryOwner < byte > EncodeAlpha < TPixel > (
30
- Image < TPixel > image ,
30
+ ImageFrame < TPixel > frame ,
31
31
Configuration configuration ,
32
32
MemoryAllocator memoryAllocator ,
33
33
bool skipMetadata ,
34
34
bool compress ,
35
35
out int size )
36
36
where TPixel : unmanaged, IPixel < TPixel >
37
37
{
38
- int width = image . Width ;
39
- int height = image . Height ;
40
- IMemoryOwner < byte > alphaData = ExtractAlphaChannel ( image , configuration , memoryAllocator ) ;
38
+ int width = frame . Width ;
39
+ int height = frame . Height ;
40
+ IMemoryOwner < byte > alphaData = ExtractAlphaChannel ( frame , configuration , memoryAllocator ) ;
41
41
42
42
if ( compress )
43
43
{
@@ -58,9 +58,9 @@ public static IMemoryOwner<byte> EncodeAlpha<TPixel>(
58
58
// The transparency information will be stored in the green channel of the ARGB quadruplet.
59
59
// The green channel is allowed extra transformation steps in the specification -- unlike the other channels,
60
60
// that can improve compression.
61
- using Image < Rgba32 > alphaAsImage = DispatchAlphaToGreen ( image , alphaData . GetSpan ( ) ) ;
61
+ using ImageFrame < Rgba32 > alphaAsFrame = DispatchAlphaToGreen ( frame , alphaData . GetSpan ( ) ) ;
62
62
63
- size = lossLessEncoder . EncodeAlphaImageData ( alphaAsImage , alphaData ) ;
63
+ size = lossLessEncoder . EncodeAlphaImageData ( alphaAsFrame , alphaData ) ;
64
64
65
65
return alphaData ;
66
66
}
@@ -73,19 +73,19 @@ public static IMemoryOwner<byte> EncodeAlpha<TPixel>(
73
73
/// Store the transparency in the green channel.
74
74
/// </summary>
75
75
/// <typeparam name="TPixel">The pixel format.</typeparam>
76
- /// <param name="image ">The <see cref="ImageFrame{TPixel}"/> to encode from.</param>
76
+ /// <param name="frame ">The <see cref="ImageFrame{TPixel}"/> to encode from.</param>
77
77
/// <param name="alphaData">A byte sequence of length width * height, containing all the 8-bit transparency values in scan order.</param>
78
- /// <returns>The transparency image .</returns>
79
- private static Image < Rgba32 > DispatchAlphaToGreen < TPixel > ( Image < TPixel > image , Span < byte > alphaData )
78
+ /// <returns>The transparency frame .</returns>
79
+ private static ImageFrame < Rgba32 > DispatchAlphaToGreen < TPixel > ( ImageFrame < TPixel > frame , Span < byte > alphaData )
80
80
where TPixel : unmanaged, IPixel < TPixel >
81
81
{
82
- int width = image . Width ;
83
- int height = image . Height ;
84
- Image < Rgba32 > alphaAsImage = new ( width , height ) ;
82
+ int width = frame . Width ;
83
+ int height = frame . Height ;
84
+ ImageFrame < Rgba32 > alphaAsFrame = new ImageFrame < Rgba32 > ( Configuration . Default , width , height ) ;
85
85
86
86
for ( int y = 0 ; y < height ; y ++ )
87
87
{
88
- Memory < Rgba32 > rowBuffer = alphaAsImage . DangerousGetPixelRowMemory ( y ) ;
88
+ Memory < Rgba32 > rowBuffer = alphaAsFrame . DangerousGetPixelRowMemory ( y ) ;
89
89
Span < Rgba32 > pixelRow = rowBuffer . Span ;
90
90
Span < byte > alphaRow = alphaData . Slice ( y * width , width ) ;
91
91
for ( int x = 0 ; x < width ; x ++ )
@@ -95,23 +95,23 @@ private static Image<Rgba32> DispatchAlphaToGreen<TPixel>(Image<TPixel> image, S
95
95
}
96
96
}
97
97
98
- return alphaAsImage ;
98
+ return alphaAsFrame ;
99
99
}
100
100
101
101
/// <summary>
102
102
/// Extract the alpha data of the image.
103
103
/// </summary>
104
104
/// <typeparam name="TPixel">The pixel format.</typeparam>
105
- /// <param name="image ">The <see cref="ImageFrame{TPixel}"/> to encode from.</param>
105
+ /// <param name="frame ">The <see cref="ImageFrame{TPixel}"/> to encode from.</param>
106
106
/// <param name="configuration">The global configuration.</param>
107
107
/// <param name="memoryAllocator">The memory manager.</param>
108
108
/// <returns>A byte sequence of length width * height, containing all the 8-bit transparency values in scan order.</returns>
109
- private static IMemoryOwner < byte > ExtractAlphaChannel < TPixel > ( Image < TPixel > image , Configuration configuration , MemoryAllocator memoryAllocator )
109
+ private static IMemoryOwner < byte > ExtractAlphaChannel < TPixel > ( ImageFrame < TPixel > frame , Configuration configuration , MemoryAllocator memoryAllocator )
110
110
where TPixel : unmanaged, IPixel < TPixel >
111
111
{
112
- Buffer2D < TPixel > imageBuffer = image . Frames . RootFrame . PixelBuffer ;
113
- int height = image . Height ;
114
- int width = image . Width ;
112
+ Buffer2D < TPixel > imageBuffer = frame . PixelBuffer ;
113
+ int height = frame . Height ;
114
+ int width = frame . Width ;
115
115
IMemoryOwner < byte > alphaDataBuffer = memoryAllocator . Allocate < byte > ( width * height ) ;
116
116
Span < byte > alphaData = alphaDataBuffer . GetSpan ( ) ;
117
117
0 commit comments