Skip to content

Commit

Permalink
merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlm committed Oct 31, 2024
1 parent 5c61422 commit 6f3a4c7
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/Consolonia.Core/Drawing/BitmapImpl.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Globalization;
using System.IO;
using Avalonia;
using Avalonia.Media.Imaging;
Expand All @@ -11,15 +10,17 @@ namespace Consolonia.Core.Drawing
{
internal class BitmapImpl : IWriteableBitmapImpl
{
private SKBitmap _bitmap;

public BitmapImpl(int width, int height, PixelFormat format, AlphaFormat? alphaFormat = null)
{
Bitmap = new SKBitmap(new SKImageInfo(width, height, format.ToSkColorType(),
_bitmap = new SKBitmap(new SKImageInfo(width, height, format.ToSkColorType(),
alphaFormat?.ToSkAlphaType() ?? SKAlphaType.Unknown));
}

public BitmapImpl(SKBitmap bitmap)
{
Bitmap = bitmap;
_bitmap = bitmap;
}

public BitmapImpl(Stream stream)
Expand All @@ -30,7 +31,7 @@ public BitmapImpl(Stream stream)

public BitmapImpl(string fileName)
{
Bitmap = SKBitmap.Decode(fileName);
_bitmap = SKBitmap.Decode(fileName);
}

public SKBitmap Bitmap => _bitmap;

Check notice on line 37 in src/Consolonia.Core/Drawing/BitmapImpl.cs

View workflow job for this annotation

GitHub Actions / build

"[ConvertToAutoPropertyWhenPossible] Convert into auto-property" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/BitmapImpl.cs(37,25)
Expand Down Expand Up @@ -80,18 +81,6 @@ public ILockedFramebuffer Lock()
throw new NotImplementedException();
}

public IBitmapImpl Resize(PixelSize pixelSize, BitmapInterpolationMode interpolationMode)
{
var resized = new SKBitmap(pixelSize.Width, pixelSize.Height);
using (var canvas = new SKCanvas(resized))
{
canvas.DrawBitmap(Bitmap, new SKRect(0, 0, pixelSize.Width, pixelSize.Height),
new SKPaint { FilterQuality = interpolationMode.ToSKFilterQuality() });
}

return new BitmapImpl(resized);
}

private static SKEncodedImageFormat GetFormatFromFileName(string fileName)
{
if (Enum.TryParse<SKEncodedImageFormat>(Path.GetExtension(fileName).Trim('.'), ignoreCase: true, out var format))

Check notice on line 86 in src/Consolonia.Core/Drawing/BitmapImpl.cs

View workflow job for this annotation

GitHub Actions / build

"[ArgumentsStyleLiteral] Inconsistent argument style: redundant name identifier" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/BitmapImpl.cs(86,92)

Check notice on line 86 in src/Consolonia.Core/Drawing/BitmapImpl.cs

View workflow job for this annotation

GitHub Actions / build

"[ConvertIfStatementToReturnStatement] Convert into 'return' statement" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/BitmapImpl.cs(86,13)
Expand Down

0 comments on commit 6f3a4c7

Please sign in to comment.