@@ -20,7 +20,7 @@ public void ShouldThrowExceptionWhenCollectionIsEmpty()
2020 }
2121
2222 [ Fact ]
23- public void ShouldCombineSeparatedImages ( )
23+ public void ShouldCombineRgbImage ( )
2424 {
2525 using var rose = new MagickImage ( Files . Builtin . Rose ) ;
2626 using var images = new MagickImageCollection ( ) ;
@@ -31,6 +31,45 @@ public void ShouldCombineSeparatedImages()
3131 using var image = images . Combine ( ) ;
3232
3333 Assert . Equal ( rose . TotalColors , image . TotalColors ) ;
34+ Assert . Equal ( 3U , image . ChannelCount ) ;
35+ Assert . Equal ( 0U , image . MetaChannelCount ) ;
36+ Assert . False ( image . HasAlpha ) ;
37+ }
38+
39+ [ Fact ]
40+ public void ShouldCombineRgbaImage ( )
41+ {
42+ using var rose = new MagickImage ( Files . MagickNETIconPNG ) ;
43+ using var images = new MagickImageCollection ( ) ;
44+ images . AddRange ( rose . Separate ( Channels . RGBA ) ) ;
45+
46+ Assert . Equal ( 4 , images . Count ) ;
47+
48+ using var image = images . Combine ( ) ;
49+
50+ Assert . Equal ( rose . TotalColors , image . TotalColors ) ;
51+ Assert . Equal ( 4U , image . ChannelCount ) ;
52+ Assert . Equal ( 0U , image . MetaChannelCount ) ;
53+ Assert . True ( image . HasAlpha ) ;
54+ }
55+
56+ [ Fact ]
57+ public void ShouldCombineRgbaImageWithMetaChannels ( )
58+ {
59+ using var icon = new MagickImage ( Files . MagickNETIconPNG ) ;
60+ using var images = new MagickImageCollection ( ) ;
61+ images . AddRange ( icon . Separate ( Channels . RGBA ) ) ;
62+ images . Add ( new MagickImage ( MagickColors . Black , icon . Width , icon . Height ) ) ;
63+
64+ Assert . Equal ( 5 , images . Count ) ;
65+
66+ using var image = images . Combine ( ) ;
67+
68+ Assert . Equal ( 0.0 , icon . Compare ( image , ErrorMetric . RootMeanSquared ) ) ;
69+ Assert . Equal ( icon . TotalColors , image . TotalColors ) ;
70+ Assert . Equal ( 5U , image . ChannelCount ) ;
71+ Assert . Equal ( 1U , image . MetaChannelCount ) ;
72+ Assert . True ( image . HasAlpha ) ;
3473 }
3574
3675 [ Fact ]
@@ -43,7 +82,49 @@ public void ShouldCombineCmykImage()
4382 Assert . Equal ( 4 , images . Count ) ;
4483
4584 using var image = images . Combine ( ColorSpace . CMYK ) ;
85+
4686 Assert . Equal ( 0.0 , cmyk . Compare ( image , ErrorMetric . RootMeanSquared ) ) ;
87+ Assert . Equal ( cmyk . TotalColors , image . TotalColors ) ;
88+ Assert . Equal ( 4U , image . ChannelCount ) ;
89+ Assert . Equal ( 0U , image . MetaChannelCount ) ;
90+ Assert . False ( image . HasAlpha ) ;
91+ }
92+
93+ [ Fact ]
94+ public void ShouldCombineCmykaImage ( )
95+ {
96+ using var cmyk = new MagickImage ( Files . CMYKJPG ) ;
97+ using var images = new MagickImageCollection ( ) ;
98+ images . AddRange ( cmyk . Separate ( Channels . CMYKA ) ) ;
99+ images . Add ( new MagickImage ( MagickColors . Black , cmyk . Width , cmyk . Height ) ) ;
100+
101+ Assert . Equal ( 5 , images . Count ) ;
102+
103+ using var image = images . Combine ( ColorSpace . CMYK ) ;
104+
105+ Assert . Equal ( cmyk . TotalColors , image . TotalColors ) ;
106+ Assert . Equal ( 5U , image . ChannelCount ) ;
107+ Assert . Equal ( 0U , image . MetaChannelCount ) ;
108+ Assert . True ( image . HasAlpha ) ;
109+ }
110+
111+ [ Fact ]
112+ public void ShouldCombineCmykaImageWithMetaChannels ( )
113+ {
114+ using var cmyk = new MagickImage ( Files . CMYKJPG ) ;
115+ using var images = new MagickImageCollection ( ) ;
116+ images . AddRange ( cmyk . Separate ( Channels . CMYKA ) ) ;
117+ images . Add ( new MagickImage ( MagickColors . Black , cmyk . Width , cmyk . Height ) ) ;
118+ images . Add ( new MagickImage ( MagickColors . Purple , cmyk . Width , cmyk . Height ) ) ;
119+
120+ Assert . Equal ( 6 , images . Count ) ;
121+
122+ using var image = images . Combine ( ColorSpace . CMYK ) ;
123+
124+ Assert . Equal ( cmyk . TotalColors , image . TotalColors ) ;
125+ Assert . Equal ( 6U , image . ChannelCount ) ;
126+ Assert . Equal ( 1U , image . MetaChannelCount ) ;
127+ Assert . True ( image . HasAlpha ) ;
47128 }
48129 }
49130}
0 commit comments