GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - LuizZak/FastBitmap: A fast C# Bitmap wrapping layer

BranchesTags
Open more actions menu

Latest commit

 

History

82 Commits
82 Commits

Folders and files

NameName
Last commit message
Last commit date
FastBitmap
FastBitmap
 
 
FastBitmapTests
FastBitmapTests
 
 
.gitignore
.gitignore
 
 
FastBitmap.sln
FastBitmap.sln
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
appveyor.yml
appveyor.yml
 
 

Repository files navigation

FastBitmap - The Fast C# Bitmap Layer

Based on work found on Visual C# Kicks: http://www.vcskicks.com/fast-image-processing.php

Build status codecov

FastBitmap is a bitmap wrapper class that intends to provide fast bitmap read/write operations on top of a safe layer of abstraction.

It provides operations for setting/getting pixel colors, copying regions accross bitmaps, clearing whole bitmaps, and copying whole bitmaps.

Editing pixels of a bitmap is just as easy as:

    Bitmap bitmap = new Bitmap(64, 64);
    
    using(var fastBitmap = bitmap.FastLock())
    {
        // Do your changes here...
        fastBitmap.Clear(Color.White);
        fastBitmap.SetPixel(1, 1, Color.Red);
    }

Or alternatively, albeit longer:

    Bitmap bitmap = new Bitmap(64, 64);
    FastBitmap fastBitmap = new FastBitmap(bitmap);
    
    // Locking bitmap before doing operations
    fastBitmap.Lock();
    
    // Do your changes here...
    fastBitmap.Clear(Color.White);
    fastBitmap.SetPixel(1, 1, Color.Red);
    
    // Don't forget to unlock!
    fastBitmap.Unlock();

This project contains the FastBitmap class and acompanying unit test suite.
Note that to compile this class you must have the /unsafe compiler flag turned on in your project settings.

Note: This code currently only works with 32bpp bitmaps

Installation

FastBitmap is available as a Nuget package:

PM > Install-Package FastBitmapLib

Speed

The following profiling tests showcase comparisions with the native System.Drawing.Bitmap equivalent method calls

SetPixel profiling
1024 x 1024 Bitmap SetPixel: 2054ms
1024 x 1024 FastBitmap SetPixel: 398ms
1024 x 1024 FastBitmap Int SetPixel: 331ms

Results: FastBitmap 6,21x faster

GetPixel profiling
1024 x 1024 Bitmap GetPixel: 1498ms
1024 x 1024 FastBitmap GetPixel: 382ms
1024 x 1024 FastBitmap Int GetPixel: 327ms

Results: FastBitmap 4,58x faster

Bitmap copying profiling
1024 x 1024 Bitmap SetPixel: 2888ms
1024 x 1024 FastBitmap CopyPixels: 5ms

Results: FastBitmap 577,60x faster

Bitmap clearing profiling
1024 x 1024 Bitmap SetPixel: 1795ms
1024 x 1024 FastBitmap Clear: 5ms

Results: FastBitmap 359,00x faster

About

A fast C# Bitmap wrapping layer

Topics

bitmapc-sharp

Resources

Readme
MIT license
Activity

Stars

95 stars

Watchers

6 watching

Forks

23 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.