Browse Source

fixed bitmap render and opacity

pull/559/head
donandren 10 years ago
parent
commit
4aa0d003b0
  1. 4
      src/Skia/Avalonia.Skia/BitmapImpl.cs
  2. 13
      src/Skia/Avalonia.Skia/DrawingContextImpl.cs

4
src/Skia/Avalonia.Skia/BitmapImpl.cs

@ -16,8 +16,8 @@ namespace Avalonia.Skia
public BitmapImpl(SKBitmap bm)
{
Bitmap = bm;
PixelHeight = bm.Width;
PixelWidth = bm.Height;
PixelHeight = bm.Height;
PixelWidth = bm.Width;
}
public BitmapImpl(int width, int height)

13
src/Skia/Avalonia.Skia/DrawingContextImpl.cs

@ -23,7 +23,11 @@ namespace Avalonia.Skia
var impl = (BitmapImpl)source.PlatformImpl;
var s = sourceRect.ToSKRect();
var d = destRect.ToSKRect();
Canvas.DrawBitmap(impl.Bitmap, s, d);
using (var paint = new SKPaint()
{ Color = new SKColor(255, 255, 255, (byte)(255 * opacity)) })
{
Canvas.DrawBitmap(impl.Bitmap, s, d, paint);
}
}
public void DrawLine(Pen pen, Point p1, Point p2)
@ -73,12 +77,13 @@ namespace Avalonia.Skia
//We are saving memory allocations there
//TODO: add more disposable fields if needed
public readonly SKPaint Paint;
private IDisposable _disposable1;
private Func<SKPaint, SKPaint, IDisposable> _applyToAction;
public void SetApplyToAction<T>(Func<SKPaint, T> get,
Action<SKPaint, SKPaint> apply,
public void SetApplyToAction<T>(Func<SKPaint, T> get,
Action<SKPaint, SKPaint> apply,
Action<SKPaint, T> revert)
{
_applyToAction = (from, to) =>
@ -143,8 +148,6 @@ namespace Avalonia.Skia
return rv;
}
var gradient = brush as GradientBrush;
if (gradient != null)
{

Loading…
Cancel
Save