We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I'm new here to processing and to programming in general. I've tried to get into coding but I never had a goal to work to. Now I finally found something I want to build: a program that converts a image that you can draw yourself into a binary code.
I've made a simple start; a drawing program with erasing tool that draws a black line on white. but I'm running into 2 problems
1: zooming in, I want to convert a 16x16 image to binary but making a screen of that size is just way too small. I need to find a way to make it bigger without changing resolution.
2: The actual conversion a black pixel needs to become a 1 and a white (background) needs to become a 0. example of a 3x3 output: (every code is a horizontal row)
101
010
101
a friend of mine told me it's handy to use a bit shifter for this, but I just don't know how!
Any help would be appreciated.
Answers
Some old threads related to image cropping:
http://forum.processing.org/two/discussion/5618/crop-image
http://forum.processing.org/two/discussion/7149/how-do-i-use-a-custom-brush-on-a-separate-layer-using-pgraphics
Basic idea for scaling a 16 x 16 image up. Note that width and height are both divisible by 16:
Thx asimes! I now have a 16x16 drawing app with pixels that are 16x16 on my screen!
I made another interpretation of what a bitImage could mean by using a long instead of a double array of booleans. A long has 64 bits which means it can represent an 8 x 8 image of bits. This is probably more in the spirit of what your friend was talking about:
As an example of why this is more like what your friend was talking about, here is a sketch that makes a random bit image and left shifts the image every time the mouse is pressed: