ImageFileMaxSizeChecker.cs 554 B

1234567891011121314151617181920
  1. using System.Windows.Media.Imaging;
  2. namespace PixiEditor.Models.IO
  3. {
  4. internal class ImageFileMaxSizeChecker
  5. {
  6. public int MaxAllowedWidthInPixels { get; init; } = 2048;
  7. public int MaxAllowedHeightInPixels { get; init; } = 2048;
  8. public ImageFileMaxSizeChecker()
  9. {
  10. }
  11. public bool IsFileUnderMaxSize(WriteableBitmap fileToCheck)
  12. {
  13. return fileToCheck.PixelWidth <= MaxAllowedWidthInPixels
  14. && fileToCheck.PixelHeight <= MaxAllowedHeightInPixels;
  15. }
  16. }
  17. }