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) public BitmapImpl(SKBitmap bm)
{ {
Bitmap = bm; Bitmap = bm;
PixelHeight = bm.Width; PixelHeight = bm.Height;
PixelWidth = bm.Height; PixelWidth = bm.Width;
} }
public BitmapImpl(int width, int height) 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 impl = (BitmapImpl)source.PlatformImpl;
var s = sourceRect.ToSKRect(); var s = sourceRect.ToSKRect();
var d = destRect.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) public void DrawLine(Pen pen, Point p1, Point p2)
@ -73,12 +77,13 @@ namespace Avalonia.Skia
//We are saving memory allocations there //We are saving memory allocations there
//TODO: add more disposable fields if needed //TODO: add more disposable fields if needed
public readonly SKPaint Paint; public readonly SKPaint Paint;
private IDisposable _disposable1; private IDisposable _disposable1;
private Func<SKPaint, SKPaint, IDisposable> _applyToAction; private Func<SKPaint, SKPaint, IDisposable> _applyToAction;
public void SetApplyToAction<T>(Func<SKPaint, T> get, public void SetApplyToAction<T>(Func<SKPaint, T> get,
Action<SKPaint, SKPaint> apply, Action<SKPaint, SKPaint> apply,
Action<SKPaint, T> revert) Action<SKPaint, T> revert)
{ {
_applyToAction = (from, to) => _applyToAction = (from, to) =>
@ -143,8 +148,6 @@ namespace Avalonia.Skia
return rv; return rv;
} }
var gradient = brush as GradientBrush; var gradient = brush as GradientBrush;
if (gradient != null) if (gradient != null)
{ {

Loading…
Cancel
Save