/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc.
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using System.Drawing;
using UVtools.Core.Extensions;
namespace UVtools.Core.Printer
{
///
/// Utility methods over a printer screen
///
public static class Screen
{
///
/// Gets the pixel size in mm
///
/// Resolution in pixels
/// Display size in mm
/// Pixel size in mm
public static float GetPixelSize(int resolution, float displaySize) => resolution == 0 ? 0 : displaySize / resolution;
///
/// Gets the pixel size in microns
///
/// Resolution in pixels
/// Display size in mm
/// Pixel size in microns
public static ushort GetPixelSizeMicrons(int resolution, float displaySize) => (ushort)(GetPixelSize(resolution, displaySize) * 1000);
///
/// Gets the pixel size in mm
///
/// Resolution in pixels
/// Display size in mm
/// Pixel size in mm
public static SizeF GetPixelSize(Size resolution, SizeF displaySize) => displaySize.Divide(resolution);
///
/// Gets the pixel size in microns
///
/// Resolution in pixels
/// Display size in mm
/// Pixel size in microns
public static Size GetPixelSizeMicrons(Size resolution, SizeF displaySize)
{
var pixel = GetPixelSize(resolution, displaySize);
return new Size((int)(pixel.Width * 1000), (int)(pixel.Height * 1000));
}
}
}