From e9f505c73d14a24c1bcc43f2b0e47dd58cd99a0d Mon Sep 17 00:00:00 2001 From: morkt Date: Sun, 3 May 2015 22:09:16 +0400 Subject: [PATCH] (ImageData): added default DPI properties. --- GameRes/Image.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/GameRes/Image.cs b/GameRes/Image.cs index 11a0980e..b77e97fc 100644 --- a/GameRes/Image.cs +++ b/GameRes/Image.cs @@ -54,6 +54,20 @@ namespace GameRes public int OffsetY { get; set; } public int BPP { get { return m_bitmap.Format.BitsPerPixel; } } + public static double DefaultDpiX { get; set; } + public static double DefaultDpiY { get; set; } + + static ImageData () + { + SetDefaultDpi (96, 96); + } + + public static void SetDefaultDpi (double x, double y) + { + DefaultDpiX = x; + DefaultDpiY = y; + } + public ImageData (BitmapSource data, ImageMetaData meta) { m_bitmap = data; @@ -72,7 +86,7 @@ namespace GameRes byte[] pixel_data) { int stride = (int)info.Width*((format.BitsPerPixel+7)/8); - var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, 96, 96, + var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, DefaultDpiX, DefaultDpiY, format, palette, pixel_data, stride); bitmap.Freeze(); return new ImageData (bitmap, info);