This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I want to write a pixel mapping program which performs like this (the image below is just so you know what the grid should look like):
(image from ladyada's SpokePOV project: www.ladyada.net/make/spokepov)
1. The home screen is a blank grid of segments. The segments are made by dividing a circle into sections
2. The user loads a monochrome (black and white) image, and the grid is overlaid onto the image
3. The program generates a boolean data array which says which grid segments contain part of the image
There are a number of aspects which I don't know how to address:
-How to draw a segmented circular grid with a 32-segment radius and 256 angular segments (in total there are 32 x 256 = 8192 segments)
-How to make an individual segment detect whether it contains part of the image or not
-How to efficiently generate a data table from the segments. For example, is individually checking the boolean values of the ~8200 pixels a good approach?
Thanks for any suggestions.
Joined: Apr 09, 2009
Maybe I can start simpler.
Lets say I want a square grid. The image below demonstrates what I mean.
The black shapes are a user-loaded image. The the grid is overlaid onto the image. Each segment of the grid should return a boolean value:
true, if it contains part of the image
false, if it is blank.
If you have a BufferedImage you can query its data using getRGB:
Here x and Y are the coordinates of the grid part to check, and block is the size of each grid. You'll have to check out what values of getRGB indicate data and which do not.