44namespace SixLabors . ImageSharp . Formats . Icon . Cur ;
55
66/// <summary>
7- /// IcoFrameMetadata. TODO: Remove base class and merge into this class.
7+ /// IcoFrameMetadata.
88/// </summary>
9- public class CurFrameMetadata : IconFrameMetadata , IDeepCloneable < CurFrameMetadata > , IDeepCloneable
9+ public class CurFrameMetadata : IDeepCloneable < CurFrameMetadata > , IDeepCloneable
1010{
1111 /// <summary>
1212 /// Initializes a new instance of the <see cref="CurFrameMetadata"/> class.
@@ -15,38 +15,92 @@ public CurFrameMetadata()
1515 {
1616 }
1717
18- /// <summary>
19- /// Initializes a new instance of the <see cref="CurFrameMetadata"/> class.
20- /// </summary>
21- /// <param name="metadata">metadata</param>
22- public CurFrameMetadata ( IconFrameMetadata metadata )
23- : base ( metadata )
24- {
25- }
26-
2718 /// <summary>
2819 /// Initializes a new instance of the <see cref="CurFrameMetadata"/> class.
2920 /// </summary>
3021 /// <param name="width">width</param>
3122 /// <param name="height">height</param>
3223 /// <param name="colorCount">colorCount</param>
33- /// <param name="field1">field1</param>
34- /// <param name="field2">field2</param>
35- public CurFrameMetadata ( byte width , byte height , byte colorCount , ushort field1 , ushort field2 )
36- : base ( width , height , colorCount , field1 , field2 )
24+ /// <param name="hotspotX">hotspotX</param>
25+ /// <param name="hotspotY">hotspotY</param>
26+ public CurFrameMetadata ( byte width , byte height , byte colorCount , ushort hotspotX , ushort hotspotY )
3727 {
28+ this . EncodingWidth = width ;
29+ this . EncodingHeight = height ;
30+ this . ColorCount = colorCount ;
31+ this . HotspotX = hotspotX ;
32+ this . HotspotY = hotspotY ;
3833 }
3934
35+ /// <inheritdoc cref="CurFrameMetadata()"/>
36+ public CurFrameMetadata ( CurFrameMetadata metadata )
37+ {
38+ this . EncodingWidth = metadata . EncodingWidth ;
39+ this . EncodingHeight = metadata . EncodingHeight ;
40+ this . ColorCount = metadata . ColorCount ;
41+ this . HotspotX = metadata . HotspotX ;
42+ this . HotspotY = metadata . HotspotY ;
43+ this . Compression = metadata . Compression ;
44+ }
45+
46+ /// <summary>
47+ /// Gets or sets icoFrameCompression.
48+ /// </summary>
49+ public IconFrameCompression Compression { get ; set ; }
50+
51+ /// <summary>
52+ /// Gets or sets ColorCount field. <br />
53+ /// Specifies number of colors in the color palette. Should be 0 if the image does not use a color palette.
54+ /// </summary>
55+ // TODO: BmpMetadata does not supported palette yet.
56+ public byte ColorCount { get ; set ; }
57+
4058 /// <summary>
4159 /// Gets or sets Specifies the horizontal coordinates of the hotspot in number of pixels from the left.
4260 /// </summary>
43- public ushort HotspotX { get => this . Field1 ; set => this . Field1 = value ; }
61+ public ushort HotspotX { get ; set ; }
4462
4563 /// <summary>
4664 /// Gets or sets Specifies the vertical coordinates of the hotspot in number of pixels from the top.
4765 /// </summary>
48- public ushort HotspotY { get => this . Field2 ; set => this . Field2 = value ; }
66+ public ushort HotspotY { get ; set ; }
67+
68+ /// <summary>
69+ /// Gets or sets Height field. <br />
70+ /// Specifies image height in pixels. Can be any number between 0 and 255. Value 0 means image height is 256 pixels.
71+ /// </summary>
72+ public byte EncodingHeight { get ; set ; }
73+
74+ /// <summary>
75+ /// Gets or sets Width field. <br />
76+ /// Specifies image width in pixels. Can be any number between 0 and 255. Value 0 means image width is 256 pixels.
77+ /// </summary>
78+ public byte EncodingWidth { get ; set ; }
79+
80+ /// <inheritdoc cref="Bmp.BmpMetadata.BitsPerPixel" />
81+ public Bmp . BmpBitsPerPixel BitsPerPixel { get ; set ; } = Bmp . BmpBitsPerPixel . Pixel24 ;
4982
5083 /// <inheritdoc/>
51- public override CurFrameMetadata DeepClone ( ) => new ( this ) ;
84+ public CurFrameMetadata DeepClone ( ) => new ( this ) ;
85+
86+ /// <inheritdoc/>
87+ IDeepCloneable IDeepCloneable . DeepClone ( ) => this . DeepClone ( ) ;
88+
89+ internal void FromIconDirEntry ( in IconDirEntry entry )
90+ {
91+ this . EncodingWidth = entry . Width ;
92+ this . EncodingHeight = entry . Height ;
93+ this . ColorCount = entry . ColorCount ;
94+ this . HotspotX = entry . Planes ;
95+ this . HotspotY = entry . BitCount ;
96+ }
97+
98+ internal IconDirEntry ToIconDirEntry ( ) => new ( )
99+ {
100+ Width = this . EncodingWidth ,
101+ Height = this . EncodingHeight ,
102+ ColorCount = this . ColorCount ,
103+ Planes = this . HotspotX ,
104+ BitCount = this . HotspotY ,
105+ } ;
52106}
0 commit comments