Skip to content

ryan-io/BitmapParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bitmap Parser

A fast bitmap parser API for Windows. Uses GDI+ through system.drawing.common.

Report Bug · Request Feature


Table of Contents
  1. Overview
  2. Getting Started & Usage
  3. Roadmap
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgments

Overview

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.

Features
  1. Get all images in a directory or directories asynchronously.
  2. Batch process or modify each photo individually based on criteria you define.
  3. Save the modified photos.

(back to top)

Built With

  • JetBrains Rider
  • Tested with WFP & ScottPlot

(back to top)

Getting Started & Usage

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;  
}

(back to top)

Prerequisites and Dependencies

  • .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.

(back to top)

Installation

  • 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

(back to top)

Roadmap

There is currently no future features planned.

(back to top)

Contributing

Contributions are absolutely welcome. This is an open source project.

  1. Fork the repository
  2. Create a feature branch
git checkout -b feature/your-feature-branch
  1. Commit changes on your feature branch
git commit -m 'Summary feature'
  1. Push your changes to your branch
git push origin feature/your-feature-branch
  1. Open a pull request to merge/incorporate your feature

(back to top)

License

Distributed under the MIT License.

(back to top)

Contact

RyanIO

[Email]
[LinkedIn]
[GitHub]

(back to top)

Acknowledgments and Credit

(back to top)

About

A fast parallel bitmap parser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages