File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed
src/Magick.NET/Formats/Tiff
tests/Magick.NET.Tests/Formats/Tiff/TiffReadDefinesTests Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,11 @@ namespace ImageMagick.Formats;
1111/// </summary>
1212public sealed class TiffReadDefines : IReadDefines
1313{
14+ /// <summary>
15+ /// Gets or sets a value indicating whether to assume that a single extra sample is an alpha channel (tiff:assume-alpha).
16+ /// </summary>
17+ public bool ? AssumeAlpha { get ; set ; }
18+
1419 /// <summary>
1520 /// Gets the format where the defines are for.
1621 /// </summary>
@@ -49,6 +54,9 @@ public IEnumerable<IDefine> Defines
4954 {
5055 get
5156 {
57+ if ( AssumeAlpha is not null )
58+ yield return new MagickDefine ( Format , "assume-alpha" , AssumeAlpha . Value ) ;
59+
5260 if ( IgnoreExifProperties . Equals ( true ) )
5361 yield return new MagickDefine ( Format , "exif-properties" , false ) ;
5462
Original file line number Diff line number Diff line change 1+ // Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
2+ // Licensed under the Apache License, Version 2.0.
3+
4+ using ImageMagick ;
5+ using ImageMagick . Formats ;
6+ using Xunit ;
7+
8+ namespace Magick . NET . Tests ;
9+
10+ public partial class TiffReadDefinesTests
11+ {
12+ public class TheAssumeAlphaProperty
13+ {
14+ [ Fact ]
15+ public void ShouldSetTheDefine ( )
16+ {
17+ using var image = new MagickImage ( ) ;
18+ image . Settings . SetDefines ( new TiffReadDefines
19+ {
20+ AssumeAlpha = true ,
21+ } ) ;
22+
23+ Assert . Equal ( "true" , image . Settings . GetDefine ( MagickFormat . Tiff , "assume-alpha" ) ) ;
24+ }
25+ }
26+ }
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ public void ShouldNotSetAnyDefine()
1717 using var image = new MagickImage ( ) ;
1818 image . Settings . SetDefines ( new TiffReadDefines ( ) ) ;
1919
20+ Assert . Null ( image . Settings . GetDefine ( MagickFormat . Tiff , "assume-alpha" ) ) ;
2021 Assert . Null ( image . Settings . GetDefine ( MagickFormat . Tiff , "exif-properties" ) ) ;
2122 Assert . Null ( image . Settings . GetDefine ( MagickFormat . Tiff , "ignore-layers" ) ) ;
2223 Assert . Null ( image . Settings . GetDefine ( MagickFormat . Tiff , "ignore-tags" ) ) ;
You can’t perform that action at this time.
0 commit comments