Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Pixed.Application/Controls/PixelDrawOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void Render(ImmediateDrawingContext context)

if (!SkiaUtils.IsNull(bitmap))
{
lease.SkCanvas.DrawBitmap(bitmap, Bounds);
lease.SkCanvas.DrawBitmapLock(bitmap, Bounds);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Pixed.Application/Controls/ProjectAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void Render(ImmediateDrawingContext context)

if (!SkiaUtils.IsNull(renderSource))
{
canvas.DrawBitmap(renderSource, new Rect(Bounds.X, Bounds.Y, Bounds.Width, height));
canvas.DrawBitmapLock(renderSource, new Rect(Bounds.X, Bounds.Y, Bounds.Width, height));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Pixed.Application/Controls/SkiaBitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Render(ImmediateDrawingContext context)
ISkiaSharpApiLease lease = leaseFeature.Lease();
using (lease)
{
lease.SkCanvas.DrawBitmap(_source, SKRect.Create((float)Bounds.X, (float)Bounds.Y, (float)Bounds.Width, (float)Bounds.Height));
lease.SkCanvas.DrawBitmapLock(_source, Bounds);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Pixed.Application/IO/IconProjectSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Pixed.Core.Models;
using Pixed.Core.Utils;
using SkiaSharp;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -47,7 +48,7 @@ public void Serialize(Stream stream, PixedModel model, bool close)
var scaledBitmap = new SKBitmap(format.X, format.Y, true);
var canvas = new SKCanvas(scaledBitmap);
canvas.Clear(SKColors.Transparent);
canvas.DrawBitmap(bitmap, SKRect.Create(scaledBitmap.Width, scaledBitmap.Height));
canvas.DrawBitmapLock(bitmap, SKRect.Create(scaledBitmap.Width, scaledBitmap.Height));
canvas.Dispose();
images.Add(new SkiaIconImage(scaledBitmap));
}
Expand Down
9 changes: 7 additions & 2 deletions Pixed.Core/Utils/SkiaUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ public static class SkiaUtils
{
private static readonly object _lock = new();

public static void DrawBitmap(this SKCanvas canvas, SKBitmap bitmap, Rect rect)
public static void DrawBitmapLock(this SKCanvas canvas, SKBitmap bitmap, Rect rect)
{
DrawBitmapLock(canvas, bitmap, SKRect.Create((float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height));
}

public static void DrawBitmapLock(this SKCanvas canvas, SKBitmap bitmap, SKRect rect)
{
lock (_lock)
{
if (!IsNull(bitmap))
{
SKImage image = SKImage.FromBitmap(bitmap);
canvas.DrawImage(image, SKRect.Create((float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height));
canvas.DrawImage(image, rect);
}
}
}
Expand Down
Loading