How to create pixels on the canvas in java

Asked

Viewed 19 times

-1

I am building a drawing app (For a progam workout) and had the following question, How to create plagued java pixels on the screen?

1 answer

1


Use Bitmap , to create do so:

Bitmap exemplo = Bitmap.createBitmap(500, 1000, Bitmap.Config.ARGB_8888, true);
//500 é a largura e 1000 a altura

Then define it as mutable:

exemplo = exemplo.copy(exemplo.getConfig(), true);

And to draw the pixel use:

exemplo.setPixel(100, 200, Color.RED);
//Pintara o pixel da coordenada x:100 e y:200 com a cor vermelha
  • Thanks, I got to do what I wanted :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.