Support for full-size images without specifing size

This commit is contained in:
GiovanniNova 2023-04-10 11:14:20 -03:00
parent 2e0622b652
commit cdc91eeef7

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())