public static unsafe Bitmap ToBitmap(this IReadOnlyImageByte <RgbImageType> @this) { var answer = Bitmap.CreateBitmap(@this.Width(), @this.Height(), Bitmap.Config.Argb8888); var step = @this.Step; var dimensions = @this.Dimensions; using (var pin = @this.Open()) { var ptr = pin.Ptr; for (var j = 0; j < dimensions.Y; j++) { var pixelPtr = ptr; for (var i = 0; i < dimensions.X; i++) { var colour = Color.Rgb(pixelPtr[0], pixelPtr[1], pixelPtr[2]); answer.SetPixel(i, j, colour); pixelPtr += step.X; } ptr += step.Y; } } return(answer); }
public static unsafe Bitmap ToBitmap(this IReadOnlyImageByte <MonoImageType> @this) { var answer = Bitmap.CreateBitmap(@this.Width(), @this.Height(), Bitmap.Config.Alpha8); var step = @this.Step; var dimensions = @this.Dimensions; using (var pin = @this.Open()) { var ptr = pin.Ptr; for (var j = 0; j < dimensions.Y; j++) { var pixelPtr = ptr; for (var i = 0; i < dimensions.X; i++) { var colour = Color.Argb(alpha: *pixelPtr, red: 0, blue: 0, green: 0); answer.SetPixel(i, j, colour); pixelPtr += step.X; } ptr += step.Y; } } return(answer); }
public static unsafe Bitmap ToBitmap(this IReadOnlyImageByte <MonoImageType> @this) { var answer = new Bitmap(@this.Width(), @this.Height()); var step = @this.Step; var dimensions = @this.Dimensions; using (var pin = @this.Open()) { var ptr = pin.Ptr; for (var j = 0; j < dimensions.Y; j++) { var pixelPtr = ptr; for (var i = 0; i < dimensions.X; i++) { var colour = Color.FromArgb(*pixelPtr, *pixelPtr, *pixelPtr); answer.SetPixel(i, j, colour); pixelPtr += step.X; } ptr += step.Y; } } return(answer); }