Родитель
cf4a66d5f1
Коммит
db9497337c
|
@ -459,8 +459,15 @@ namespace Xwt.WPFBackend
|
|||
|
||||
var f = GetBestFrame (actx, scaleFactor, idesc.Size.Width, idesc.Size.Height, false);
|
||||
var bmpImage = f as BitmapSource;
|
||||
if (bmpImage != null && (bmpImage.PixelHeight != idesc.Size.Height || bmpImage.PixelWidth != idesc.Size.Width))
|
||||
f = new TransformedBitmap (bmpImage, new ScaleTransform (idesc.Size.Width / bmpImage.PixelWidth, idesc.Size.Height / bmpImage.PixelHeight));
|
||||
|
||||
// When an image is a single bitmap that doesn't have the same intrinsic size as the drawing size, dc.DrawImage makes a very poor job of down/up scaling it.
|
||||
// Thus we handle this manually by using a TransformedBitmap to handle the conversion in a better way when it's needed.
|
||||
|
||||
var scaledWidth = idesc.Size.Height * scaleFactor;
|
||||
var scaledHeight = idesc.Size.Width * scaleFactor;
|
||||
if (bmpImage != null && (Math.Abs (bmpImage.PixelHeight - scaledHeight) > 0.001 || Math.Abs (bmpImage.PixelWidth - scaledWidth) > 0.001))
|
||||
f = new TransformedBitmap (bmpImage, new ScaleTransform (scaledWidth / bmpImage.PixelWidth, scaledHeight / bmpImage.PixelHeight));
|
||||
|
||||
dc.DrawImage (f, new Rect (x, y, idesc.Size.Width, idesc.Size.Height));
|
||||
|
||||
if (idesc.Alpha < 1)
|
||||
|
|
Загрузка…
Ссылка в новой задаче