You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Image.cs 1.1 kB

8 years ago
123456789101112131415161718192021222324252627282930313233343536
  1. using System.IO;
  2. namespace Discord
  3. {
  4. /// <summary>
  5. /// An image that will be uploaded to Discord.
  6. /// </summary>
  7. public struct Image
  8. {
  9. public Stream Stream { get; }
  10. public ImageFormat Format { get; }
  11. /// <summary>
  12. /// Create the image with a Stream.
  13. /// </summary>
  14. /// <param name="stream">This must be some type of stream with the contents of a file in it.</param>
  15. public Image(Stream stream, ImageFormat format = ImageFormat.Jpeg)
  16. {
  17. Stream = stream;
  18. Format = format;
  19. }
  20. #if FILESYSTEM
  21. /// <summary>
  22. /// Create the image from a file path.
  23. /// </summary>
  24. /// <remarks>
  25. /// This file path is NOT validated, and is passed directly into a <see cref="File.OpenRead(string)"/>
  26. /// </remarks>
  27. /// <param name="path">The path to the file.</param>
  28. public Image(string path, ImageFormat format = ImageFormat.Jpeg)
  29. {
  30. Stream = File.OpenRead(path);
  31. Format = format;
  32. }
  33. #endif
  34. }
  35. }