iron-software / IronSoftware.System.Drawing

An open-source System.Drawing.Common replacement for .NET 5 and above on all platforms. Bringing together System.Drawing, Maui, and ImageSharp's Bitmap, Image, Font, and Shape types via an agnostic free NuGet package.
Other
120 stars 19 forks source link

Feature: Added methods to load AnyBitmap from RGB buffer and retrieve RGB buffer from image #59

Closed mee-ironsoftware closed 1 year ago

mee-ironsoftware commented 1 year ago

Description

In this PR, two new methods were implemented:

LoadAnyBitmapFromRGBBuffer: This method creates an AnyBitmap object from a provided buffer of RGB pixel data. It takes in a byte array, along with width and height parameters, and returns an AnyBitmap object.

byte[] buffer = YOUR_RGB_BUFFER;
using AnyBitmap result = AnyBitmap.LoadAnyBitmapFromRGBBuffer(buffer, width, height);

GetRGBBuffer: This method retrieves the RGB buffer from an AnyBitmap object. It returns an array of bytes representing the RGB buffer of the image.

using var bitmap = new AnyBitmap(YOUR_IMAGE_PATH);
byte[] buffer = bitmap.GetRGBBuffer();

These methods provide more flexibility when working with images and RGB data, simplifying the process of creating AnyBitmap objects from RGB buffers and retrieving RGB buffers from images.

Fixes #29

Type of change

Please select the relevant option by placing an 'x' inside the brackets, like this: [x].

How Has This Been Tested?

Describe the tests you ran to verify your changes. Provide instructions so others can reproduce the tests. Also, list any relevant details for your test configuration.

Checklist:

Please run through the checklist as much as possible and mark the items completed by placing an 'x' inside the brackets, like this: [x].