mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-04-05 20:55:01 +08:00
Add IPdfImage.RawBytes
This commit is contained in:
parent
bd95adf4bc
commit
49c155cca2
@ -39,6 +39,11 @@
|
||||
/// </summary>
|
||||
ReadOnlyMemory<byte> RawMemory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The encoded memory span of the image with all filters still applied.
|
||||
/// </summary>
|
||||
ReadOnlySpan<byte> RawBytes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The color rendering intent to be used when rendering the image.
|
||||
/// </summary>
|
||||
@ -90,10 +95,10 @@
|
||||
ColorSpaceDetails? ColorSpaceDetails { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Get the decoded bytes of the image if applicable. For JPEG images and some other types the
|
||||
/// Get the decoded memory of the image if applicable. For JPEG images and some other types the
|
||||
/// <see cref="RawMemory"/> should be used directly.
|
||||
/// </summary>
|
||||
bool TryGetMemory(out ReadOnlyMemory<byte> bytes);
|
||||
bool TryGetMemory(out ReadOnlyMemory<byte> memory);
|
||||
|
||||
/// <summary>
|
||||
/// Try to convert the image to PNG. Doesn't support conversion of JPG to PNG.
|
||||
|
@ -49,7 +49,10 @@
|
||||
public bool Interpolate { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public ReadOnlyMemory<byte> RawMemory { get; }
|
||||
public ReadOnlyMemory<byte> RawMemory { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public ReadOnlySpan<byte> RawBytes => RawMemory.Span;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ColorSpaceDetails ColorSpaceDetails { get; }
|
||||
@ -61,7 +64,7 @@
|
||||
RenderingIntent renderingIntent,
|
||||
bool interpolate,
|
||||
IReadOnlyList<double> decode,
|
||||
ReadOnlyMemory<byte> bytes,
|
||||
ReadOnlyMemory<byte> rawMemory,
|
||||
IReadOnlyList<IFilter> filters,
|
||||
DictionaryToken streamDictionary,
|
||||
ColorSpaceDetails colorSpaceDetails)
|
||||
@ -75,8 +78,7 @@
|
||||
RenderingIntent = renderingIntent;
|
||||
Interpolate = interpolate;
|
||||
ImageDictionary = streamDictionary;
|
||||
|
||||
RawMemory = bytes;
|
||||
RawMemory = rawMemory;
|
||||
ColorSpaceDetails = colorSpaceDetails;
|
||||
|
||||
var supportsFilters = true;
|
||||
@ -91,14 +93,14 @@
|
||||
|
||||
memoryFactory = supportsFilters ? new Lazy<ReadOnlyMemory<byte>>(() =>
|
||||
{
|
||||
var b = bytes.ToArray();
|
||||
var b = rawMemory.Span;
|
||||
for (var i = 0; i < filters.Count; i++)
|
||||
{
|
||||
var filter = filters[i];
|
||||
b = filter.Decode(b, streamDictionary, i);
|
||||
}
|
||||
|
||||
return b;
|
||||
return b.ToArray();
|
||||
}) : null;
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,9 @@
|
||||
/// <inheritdoc />
|
||||
public ReadOnlyMemory<byte> RawMemory { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public ReadOnlySpan<byte> RawBytes => RawMemory.Span;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ColorSpaceDetails? ColorSpaceDetails { get; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user