Created
March 26, 2019 15:48
-
-
Save jldubz/745dd221cd2e888abf83b9eb27269946 to your computer and use it in GitHub Desktop.
Draw directly to a canvas in Android using a matrix of boolean values for black or white pixels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var canvas = new Canvas(); | |
canvas.SetViewport(256, 256); | |
var bitMatrix = new bool[256][]; //bool[256][256] | |
//Generate the bitMatrix | |
//... | |
var blackPaint = new Paint {Color = Color.Black}; | |
var whitePaint = new Paint {Color = Color.White}; | |
for (var x = 0; x < 256; x++) { | |
for (var y = 0; y < 256; y++) { | |
canvas.DrawPoint(x,y, bitMatrix[x][y] ? blackPaint : whitePaint); | |
} | |
} | |
_image.SetImageBitmap(bitmap); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment