I programmed something like paint. I have JPanel and I can draw on it.I’m using only black line. I wanna convert it to binary array, where 1 is when pixel is black, 0 when is white (background). It’s possible? How to do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In a nutshell, create a
BufferedImagewith the same dimensions as your JPanel and paint the panel to the image. Then you can iterate over the image raster to get the sequence of pixel color values corresponding to black and white. For example