A fast bitmap parser API for Windows. Uses GDI+ through system.drawing.common.
Report Bug
·
Request Feature
Table of Contents
This project came to fruition in my current role and is used in two internal tools for annotating photos. The goal was to make a fast parser. This is done using access to GDI+ through System.Drawing.Common.
- Get all images in a directory or directories asynchronously.
- Batch process or modify each photo individually based on criteria you define.
- Save the modified photos.
- JetBrains Rider
- Tested with WFP & ScottPlot
using RIO.BCL.Parsing;
// for creating a parser, define an array of image locations
var paths = new[] { @"C:\img1.png", @"C:\img2.jpg" };
// for creating an image grabber that gets all images in a folder
const string folder = @"C:\your-folder\";
// create an instance of BitmapParser
var parser = new BitmapParser(ref paths);
// create an instance of ImageGrabber
var grabber = await ImageGrabber.CreateAsync(ImageType.ALL, folder);
// modify a single image via parser
parser.ModifyRgbUnsafeRef(0, ModifyFunctor);
// modify many images via parser (images w/ indices 0, 3 and 4)
parser.ModifyRgbUnsafeRef(ModifyFunctor, 0, 3, 4);
//modify all images via parser
parser.ModifyAllRgbUnsafeRef(ModifyFunctor);
// getting images via parser
var images = parser.GetAllBitmapsRef();
ref var imagesRef = ref parser.GetAllBitmapsRef();
// modify a single image via image grabber
grabber.Parser.ModifyRgbUnsafeRef(0, ModifyFunctor);
// modify many images via grabber (images w/ indices 0, 3 and 4)
grabber.Parser.ModifyRgbUnsafeRef(ModifyFunctor, 0, 3, 4);
//modify all images via grabber
grabber.Parser.ModifyAllRgbUnsafeRef(ModifyFunctor);
// getting images via image grabber
grabber.GetAllBitmapsRef();
grabber.Parser.GetAllBitmapsRef();
var imagesGrabber = grabber.GetAllBitmapsRef();
ref var imagesGrabberRef = ref grabber.Parser.GetAllBitmapsRef();
// a modify 'functor' is a delegate that takes four reference parameters: index, red, green and blue
// the core of the functor method should modify an image per logic appropriate for your application
void ModifyFunctor(ref int pxlIndex, ref int red, ref int green, ref int blue)
{
// modify the images RGB values however you see fit
if (pxlIndex % 2 == 0)
{
red -= 25;
green = 10;
blue += 20;
}
red -= 25;
green += 10;
blue += 20;
}- .NET 6
- C# 10
- System.Drawing.Common
- Microsoft.Extensions.Logging.7.0.0 (Optional)
Please feel free to contact me with any issues or concerns in regards to the dependencies defined above. We can work around the majority of them if needed.
- Clone or fork this repository. Once done, add a reference to this library in your project
- Download the latest dll and create a reference to it in your project
- Install via NPM
There is currently no future features planned.
Contributions are absolutely welcome. This is an open source project.
- Fork the repository
- Create a feature branch
git checkout -b feature/your-feature-branch- Commit changes on your feature branch
git commit -m 'Summary feature'- Push your changes to your branch
git push origin feature/your-feature-branch- Open a pull request to merge/incorporate your feature
Distributed under the MIT License.
RyanIO
[Email]
[LinkedIn]
[GitHub]
- Stephen Cleary's Blog
- In particular, his blog on Async Events in OOP provided me with inspiration for this.
