-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anthony Rivera
committed
Aug 29, 2020
1 parent
a31fe08
commit 1ad3479
Showing
6 changed files
with
150 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace PdfMakeNet | ||
{ | ||
public enum SourceImageFormat | ||
{ | ||
JPEG, | ||
PNG | ||
} | ||
} |
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,18 @@ | ||
namespace PdfMakeNet.Extensions | ||
{ | ||
public static class SourceImageFormatExtensions | ||
{ | ||
public static string GetMimeType(this SourceImageFormat sourceImageFormat) | ||
{ | ||
if (sourceImageFormat == SourceImageFormat.JPEG) | ||
{ | ||
return "image/jpeg"; | ||
} | ||
else if (sourceImageFormat == SourceImageFormat.PNG) | ||
{ | ||
return "image/png"; | ||
} | ||
return null; | ||
} | ||
} | ||
} |
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,31 @@ | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace PdfMakeNet.Extensions | ||
{ | ||
public static class StreamExtensions | ||
{ | ||
public static byte[] ToByteArray(this Stream stream) | ||
{ | ||
var streamLength = (int)stream.Length; | ||
var data = new byte[streamLength]; | ||
stream.Read(data, 0, streamLength); | ||
return data; | ||
} | ||
public static async Task<byte[]> ToByteArrayAsync(this Stream stream) | ||
{ | ||
var streamLength = (int)stream.Length; | ||
var data = new byte[streamLength]; | ||
await stream.ReadAsync(data, 0, streamLength); | ||
return data; | ||
} | ||
public static async Task<byte[]> ToByteArrayAsync(this Stream stream, CancellationToken cancellationToken) | ||
{ | ||
var streamLength = (int)stream.Length; | ||
var data = new byte[streamLength]; | ||
await stream.ReadAsync(data, 0, streamLength, cancellationToken); | ||
return data; | ||
} | ||
} | ||
} |
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