Merge pull request #596 from GiovanniNova/master

Support for full-size images without specifing size
This commit is contained in:
Eliot Jones
2023-04-11 20:43:33 +02:00
committed by GitHub

View File

@@ -520,11 +520,14 @@
/// <summary>
/// Adds the JPEG image represented by the input stream at the specified location.
/// </summary>
public AddedImage AddJpeg(Stream fileStream, PdfRectangle placementRectangle)
public AddedImage AddJpeg(Stream fileStream, PdfRectangle placementRectangle = default)
{
var startFrom = fileStream.Position;
var info = JpegHandler.GetInformation(fileStream);
if (placementRectangle.Equals(default(PdfRectangle)))
placementRectangle = new PdfRectangle(0, 0, info.Width, info.Height);
byte[] data;
using (var memory = new MemoryStream())
{
@@ -612,10 +615,13 @@
/// <summary>
/// Adds the PNG image represented by the input stream at the specified location.
/// </summary>
public AddedImage AddPng(Stream pngStream, PdfRectangle placementRectangle)
public AddedImage AddPng(Stream pngStream, PdfRectangle placementRectangle = default)
{
var png = Png.Open(pngStream);
if (placementRectangle.Equals(default(PdfRectangle)))
placementRectangle = new PdfRectangle(0, 0, png.Width, png.Height);
byte[] data;
var pixelBuffer = new byte[3];
using (var memoryStream = new MemoryStream())