jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes Writing a pixel mapping program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Writing a pixel mapping program" Watch "Writing a pixel mapping program" New topic

Writing a pixel mapping program

Mikpo Siru
Ranch Hand

Joined: Apr 09, 2009
Posts: 54

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.
Mikpo Siru
Ranch Hand

Joined: Apr 09, 2009
Posts: 54
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.

Thanks for any suggestions.
Rob Spoor

Joined: Oct 27, 2005
Posts: 20276

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.

How To Ask Questions How To Answer Questions
I agree. Here's the link: http://aspose.com/file-tools
subject: Writing a pixel mapping program
It's not a secret anymore!