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
114 stars 18 forks source link

IRON-1233 Implement extract alpha data. #69

Closed mee-ironsoftware closed 1 year ago

mee-ironsoftware commented 1 year ago

Description

Implement ExtractAlphaData() which will return array of alpha channel in byte. This function supported only image which in 32 bpp format.

Also add tag NuGet version to deployment pipeline when run successfully.

var bitmap = new AnyBitmap("32_bit_transparent.png");
byte[] result = bitmap.ExtractAlphaData();

Fixes #IRON-1233

Type of change

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

How Has This Been Tested?

Add 2 tests which are return correct result and throw exception.

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

artem-iron commented 1 year ago

Is alpha 0 means that the pixel is transparent? Maybe in the unit test, check also a couple of pixels that don't have 0?

artem-iron commented 1 year ago

Just to be safe.

mee-ironsoftware commented 1 year ago

Is alpha 0 means that the pixel is transparent? Maybe in the unit test, check also a couple of pixels that don't have 0?

@artem-iron Thanks, good point. 💪 I modified test to check various values from result.