@@ -544,16 +544,16 @@ internal static Bitmap ConvertWhiteToTransparent(Bitmap image, int threshold)
544544 ImageHelper . ValidateImage ( nameof ( ConvertWhiteToTransparent ) , image ) ;
545545
546546 //use our new Format
547- var result = DirectBitmap . GetInstance ( image ) ;
547+ var dbm = DirectBitmap . GetInstance ( image ) ;
548548
549549 //255,255,255 is White
550550 var replacementColor = Color . FromArgb ( 255 , 255 , 255 ) ;
551551 var pixelsToSet = new List < ( int x , int y , Color color ) > ( ) ;
552552
553- for ( var x = 0 ; x < result . Width ; x ++ )
554- for ( var y = 0 ; y < result . Height ; y ++ )
553+ for ( var x = 0 ; x < dbm . Width ; x ++ )
554+ for ( var y = 0 ; y < dbm . Height ; y ++ )
555555 {
556- var color = result . GetPixel ( x , y ) ;
556+ var color = dbm . GetPixel ( x , y ) ;
557557
558558 //not in the area? continue, 255 is White
559559 if ( 255 - color . R >= threshold || 255 - color . G >= threshold || 255 - color . B >= threshold )
@@ -567,14 +567,14 @@ internal static Bitmap ConvertWhiteToTransparent(Bitmap image, int threshold)
567567
568568 try
569569 {
570- result . SetPixels ( pixelsToSet ) ;
570+ dbm . SetPixels ( pixelsToSet ) ;
571571
572572 //get the Bitmap
573- var btm = new Bitmap ( result . UnsafeBitmap ) ;
573+ var btm = dbm . ToBitmap ( ) ;
574574 //make Transparent
575575 btm . MakeTransparent ( replacementColor ) ;
576576 //cleanup
577- result . Dispose ( ) ;
577+ dbm . Dispose ( ) ;
578578 return btm ;
579579 }
580580 catch ( Exception ex )
@@ -672,7 +672,7 @@ internal static Bitmap SetPixel(Bitmap image, Point point, Color color)
672672 var dbm = DirectBitmap . GetInstance ( image ) ;
673673 dbm . SetPixel ( point . X , point . Y , color ) ;
674674
675- return new Bitmap ( dbm . UnsafeBitmap ) ;
675+ return dbm . ToBitmap ( ) ;
676676 }
677677
678678 /// <summary>
@@ -688,7 +688,7 @@ internal static Bitmap AdjustBrightness(Bitmap image, float brightnessFactor)
688688 ImageHelper . ValidateImage ( nameof ( GetPixel ) , image ) ;
689689
690690 var source = new DirectBitmap ( image ) ;
691- var result = new DirectBitmap ( source . Width , source . Height ) ;
691+ var dbm = new DirectBitmap ( source . Width , source . Height ) ;
692692
693693 for ( var y = 0 ; y < source . Height ; y ++ )
694694 for ( var x = 0 ; x < source . Width ; x ++ )
@@ -700,10 +700,10 @@ internal static Bitmap AdjustBrightness(Bitmap image, float brightnessFactor)
700700 var newGreen = ImageHelper . Clamp ( pixelColor . G * brightnessFactor ) ;
701701 var newBlue = ImageHelper . Clamp ( pixelColor . B * brightnessFactor ) ;
702702
703- result . SetPixel ( x , y , Color . FromArgb ( newRed , newGreen , newBlue ) ) ;
703+ dbm . SetPixel ( x , y , Color . FromArgb ( newRed , newGreen , newBlue ) ) ;
704704 }
705705
706- return new Bitmap ( result . UnsafeBitmap ) ;
706+ return dbm . ToBitmap ( ) ;
707707 }
708708
709709 /// <summary>
@@ -748,7 +748,7 @@ internal static Bitmap FillAreaWithColor(
748748 int ? height ,
749749 Color color ,
750750 MaskShape shape ,
751- object shapeParams = null ,
751+ object ? shapeParams = null ,
752752 Point ? startPoint = null )
753753 {
754754 // Validate input
@@ -871,7 +871,7 @@ internal static Bitmap FloodFillScanLineStack(Bitmap image, int x, int y, Color
871871 pixelData . Clear ( ) ;
872872
873873 // Return the modified image as a Bitmap
874- return new Bitmap ( result . UnsafeBitmap ) ;
874+ return result . ToBitmap ( ) ;
875875 }
876876
877877 /// <summary>
0 commit comments