Skip to content

Commit

Permalink
fix: Refactor render size handling in PosterIconBase
Browse files Browse the repository at this point in the history
Refactor to use predefined window render size. The render size is now a static readonly property, ensuring it's not being created for each instance.
  • Loading branch information
DineshSolanki committed Jul 28, 2024
1 parent c9c7f82 commit 2ff27e7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions FoliCon/Models/Data/PosterIconBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace FoliCon.Models.Data;
public abstract class PosterIconBase : UserControl
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly Size WindowRenderSize = new(256, 256);
protected PosterIconBase()
{
}
Expand All @@ -16,16 +17,15 @@ protected PosterIconBase(object dataContext)

public Bitmap RenderToBitmap()
{
return RenderTargetBitmapTo32BppArgb(AsRenderTargetBitmap());
var rtb = AsRenderTargetBitmap();
return RenderTargetBitmapTo32BppArgb(rtb);
}

private RenderTargetBitmap AsRenderTargetBitmap()
{
var size = new Size(256, 256);
Measure(size);
Arrange(new Rect(size));

var rtb = new RenderTargetBitmap((int)size.Width, (int)size.Height, 96, 96, PixelFormats.Default);
Measure(WindowRenderSize);
Arrange(new Rect(WindowRenderSize));
var rtb = new RenderTargetBitmap((int)WindowRenderSize.Width, (int)WindowRenderSize.Height, 96, 96, PixelFormats.Default);
RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.HighQuality);
RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
rtb.Render(this);
Expand Down

0 comments on commit 2ff27e7

Please sign in to comment.