BitmapPainter 1.1.2.5

dotnet add package BitmapPainter --version 1.1.2.5
NuGet\Install-Package BitmapPainter -Version 1.1.2.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BitmapPainter" Version="1.1.2.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BitmapPainter --version 1.1.2.5
#r "nuget: BitmapPainter, 1.1.2.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BitmapPainter as a Cake Addin
#addin nuget:?package=BitmapPainter&version=1.1.2.5

// Install BitmapPainter as a Cake Tool
#tool nuget:?package=BitmapPainter&version=1.1.2.5

BitmapPainter

Nuget

A simple way to paint a Bitmap and update the User Interface Extremely Fast

Example

using System;
using System.Drawing;
using System.Threading.Tasks;

public class MainContext : NotifyPropertyChanged, IDisposable
{
    private bool tick;

    private readonly int Width = 1000;
    private readonly int Height = 1000;

    private readonly BitmapPainter BitmapPainter;

    private static readonly Brush Red = new SolidBrush(Color.Red);
    private static readonly Brush Yellow = new SolidBrush(Color.FromArgb(100, 250, 208, 0));

    public MainContext()
    {
        BitmapPainter = new(NextModification, Width, Height, NextInterfaceUpdate);

        uint delayMs = 15;

        Task.Run(() =>
        {
            BitmapPainter.StartPainting(delayMs);
        }).ConfigureAwait(false);
    }

    public bool NextModification(Graphics g)
    {
        bool updateUI;

        if (!tick)
        {
            tick = true;

            g.FillRectangle(Yellow, new Rectangle(0, 0, Width, Height));

            updateUI = true;
        }
        else
        {
            tick = false;

            g.FillRectangle(Red, new Rectangle(0, 0, Width, Height));

            updateUI = true;
        }

        return updateUI;
    }

    public void NextInterfaceUpdate()
    {
        UI.Invoke(() =>
        {
            SomeVM.Image = BitmapPainter.CreateBitmapSource();
        });
    }

    public void Dispose()
    {
        BitmapPainter.Dispose();

        GC.SuppressFinalize(this);
    }
}

Auto Upgrade Resolution

Automatically adjusts the resolution of the delay to the highest available at the interval for the lifetime of the application

BitmapPainter.StartLifeTimeUpgradeService.StartLifeTimeUpgradeService(uint delay)

You only need to run this once, running it more than once will do nothing.

Attempt Upgrade Resolution Once

BitmapPainter.TryUpgradeOnce();
Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.2.5 78 4/11/2024
1.1.2.4 81 3/20/2024

Initial releases