mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-20 03:17:57 +08:00
load images eagerly for marked content
when a marked content region contains an image we load it eagerly since we won't have access to the necessary classes at evaluation time. we also default image colorspace to the active graphics state colorspace if the dictionary doesn't contain a valid entry.
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
using Graphics.Operations;
|
||||
using Tokenization.Scanner;
|
||||
using XObjects;
|
||||
using Geometry;
|
||||
|
||||
/// <summary>
|
||||
/// Wraps content parsed from a page content stream for access.
|
||||
@@ -24,7 +23,6 @@
|
||||
private readonly IPdfTokenScanner pdfScanner;
|
||||
private readonly IFilterProvider filterProvider;
|
||||
private readonly IResourceStore resourceStore;
|
||||
private readonly bool isLenientParsing;
|
||||
|
||||
internal IReadOnlyList<IGraphicsStateOperation> GraphicsStateOperations { get; }
|
||||
|
||||
@@ -38,8 +36,7 @@
|
||||
IReadOnlyList<MarkedContentElement> markedContents,
|
||||
IPdfTokenScanner pdfScanner,
|
||||
IFilterProvider filterProvider,
|
||||
IResourceStore resourceStore,
|
||||
bool isLenientParsing)
|
||||
IResourceStore resourceStore)
|
||||
{
|
||||
GraphicsStateOperations = graphicsStateOperations;
|
||||
Letters = letters;
|
||||
@@ -49,17 +46,14 @@
|
||||
this.pdfScanner = pdfScanner ?? throw new ArgumentNullException(nameof(pdfScanner));
|
||||
this.filterProvider = filterProvider ?? throw new ArgumentNullException(nameof(filterProvider));
|
||||
this.resourceStore = resourceStore ?? throw new ArgumentNullException(nameof(resourceStore));
|
||||
this.isLenientParsing = isLenientParsing;
|
||||
}
|
||||
|
||||
public IEnumerable<IPdfImage> GetImages()
|
||||
{
|
||||
foreach (var image in images)
|
||||
{
|
||||
|
||||
IPdfImage result = null;
|
||||
image.Match(x => { result = XObjectFactory.ReadImage(x, pdfScanner, filterProvider, resourceStore, isLenientParsing); },
|
||||
x => { result = x; });
|
||||
var result = image.Match<IPdfImage>(x => XObjectFactory.ReadImage(x, pdfScanner, filterProvider, resourceStore),
|
||||
x => x);
|
||||
|
||||
yield return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user