-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial multi-page TIFF support #190
- Loading branch information
Showing
4 changed files
with
160 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using ImageMagick; | ||
|
||
namespace PicView.Core.ImageDecoding; | ||
|
||
public static class TiffManager | ||
{ | ||
public static bool IsTiff(string path) | ||
{ | ||
return path.EndsWith(".tif", StringComparison.OrdinalIgnoreCase) || | ||
path.EndsWith(".tiff", StringComparison.OrdinalIgnoreCase); | ||
} | ||
|
||
public static MagickImageCollection? LoadTiffPages(string path) | ||
{ | ||
using var image = new MagickImage(path); | ||
var settings = new MagickReadSettings | ||
{ | ||
// Specify that we want to read a TIFF format image | ||
Format = MagickFormat.Tiff | ||
}; | ||
|
||
var pageCollection = new MagickImageCollection(path, settings); | ||
foreach (var page in pageCollection) | ||
{ | ||
page.Quality = 100; | ||
} | ||
|
||
return pageCollection; | ||
} | ||
|
||
public class TiffNavigationInfo : IDisposable | ||
{ | ||
public int PageCount { get; set; } | ||
public int CurrentPage { get; set; } | ||
|
||
public MagickImageCollection? Pages { get; set; } | ||
|
||
#region IDisposable | ||
|
||
public void Dispose() | ||
{ | ||
Dispose(true); | ||
GC.SuppressFinalize(this); | ||
} | ||
|
||
private void Dispose(bool disposing) | ||
{ | ||
if (!disposing) | ||
{ | ||
return; | ||
} | ||
|
||
if (Pages == null) | ||
{ | ||
return; | ||
} | ||
|
||
Pages.Dispose(); | ||
Pages = null; | ||
} | ||
|
||
#endregion | ||
} | ||
} |