dpi: add ScaleBitmap static method to DisplayHelper

This commit is contained in:
Nick Vella 2019-05-16 18:36:11 +10:00
parent a1c4d542e0
commit d02e120386
1 changed files with 11 additions and 0 deletions

View File

@ -101,6 +101,17 @@ namespace OpenLiveWriter.CoreServices
c.Scale(new SizeF((float)PixelsPerLogicalInchX / DEFAULT_DPI, (float)PixelsPerLogicalInchY / DEFAULT_DPI));
}
/// <summary>
/// Scales a bitmap from 96dpi to the actual screen dpi.
/// </summary>
public static Bitmap ScaleBitmap(Bitmap original)
{
return new Bitmap(original, new Size(
(int)Math.Ceiling(ScaleX(original.Width)),
(int)Math.Ceiling(ScaleY(original.Height))
));
}
/// <summary>
/// When PMingLiU is rendered by GDI+ with StringFormat.LineAlignment == StringAlignment.Center
/// with at least one Chinese character, it ends up 2-3 pixels higher than it should be.