Skip to content

Commit

Permalink
fixing type declaration
Browse files Browse the repository at this point in the history
[minor][fix]
Wrong type info, SKBitmap has to be disposed.
  • Loading branch information
X39 committed Nov 23, 2023
1 parent 88bdaf0 commit 2b22edd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions source/X39.Solutions.PdfTemplate/Abstraction/CanvasImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,15 @@ public void DrawText(TextStyle textStyle, string text, float x, float y)
});
}

public void DrawBitmap(SKBitmap bitmap, Rectangle rectangle)
public void DrawBitmap(byte[] bytes, Rectangle rectangle)
{
_drawActions.Add((canvas) => canvas.DrawBitmap(bitmap, rectangle));
_drawActions.Add((canvas) =>
{
using var stream = new MemoryStream(bytes);
using var bitmap = SKBitmap.Decode(stream);
if (bitmap is null)
return;
canvas.DrawBitmap(bitmap, rectangle);
});
}
}
2 changes: 1 addition & 1 deletion source/X39.Solutions.PdfTemplate/Abstraction/ICanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ public interface ICanvas
/// </summary>
/// <param name="bitmap">The bitmap to draw.</param>
/// <param name="rectangle">The region to draw the bitmap into.</param>
void DrawBitmap(SKBitmap bitmap, Rectangle rectangle);
void DrawBitmap(byte[] bitmap, Rectangle rectangle);
}
2 changes: 1 addition & 1 deletion test/X39.Solutions.PdfTemplate.Test/Mock/CanvasMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void DrawRect(Rectangle rectangle, Color color)
{
}

public void DrawBitmap(SKBitmap bitmap, Rectangle rectangle)
public void DrawBitmap(byte[] bitmap, Rectangle rectangle)
{
}
}
Expand Down

0 comments on commit 2b22edd

Please sign in to comment.