File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
IronSoftware.Drawing.Common.Tests/UnitTests
IronSoftware.Drawing.Common Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -798,6 +798,25 @@ public void TestGetRGBBuffer()
798798 Assert . Equal ( firstPixel . B , buffer [ 2 ] ) ;
799799 }
800800
801+ [ FactWithAutomaticDisplayName ]
802+ public void TestGetRGBABuffer ( )
803+ {
804+ string imagePath = GetRelativeFilePath ( "checkmark.jpg" ) ;
805+ using var bitmap = new AnyBitmap ( imagePath ) ;
806+ var expectedSize = bitmap . Width * bitmap . Height * 4 ; // 3 bytes per pixel (RGB)
807+
808+ byte [ ] buffer = bitmap . GetRGBABuffer ( ) ;
809+
810+ Assert . Equal ( expectedSize , buffer . Length ) ;
811+
812+ // Verify the first pixel's RGB values
813+ var firstPixel = bitmap . GetPixel ( 0 , 0 ) ;
814+ Assert . Equal ( firstPixel . R , buffer [ 0 ] ) ;
815+ Assert . Equal ( firstPixel . G , buffer [ 1 ] ) ;
816+ Assert . Equal ( firstPixel . B , buffer [ 2 ] ) ;
817+ Assert . Equal ( firstPixel . A , buffer [ 3 ] ) ;
818+ }
819+
801820 [ FactWithAutomaticDisplayName ]
802821 public void Test_LoadFromRGBBuffer ( )
803822 {
Original file line number Diff line number Diff line change @@ -1625,7 +1625,7 @@ public byte[] GetRGBABuffer()
16251625 var image = _lazyImage . Value . First ( ) ;
16261626 int width = image . Width ;
16271627 int height = image . Height ;
1628- byte [ ] rgbBuffer = new byte [ width * height * 3 ] ; // 3 bytes per pixel (RGB)
1628+ byte [ ] rgbBuffer = new byte [ width * height * 4 ] ; // 3 bytes per pixel (RGB)
16291629 switch ( image )
16301630 {
16311631 case Image < Rgba32 > imageAsFormat :
You can’t perform that action at this time.
0 commit comments