I have a PNG image that I am editing in Inkscape. It is an irregular, jagged shape, but I need to do collision detection with it. It's too big to make a crude rect around it (it takes up more than a standard phone screen).So I have been drawing rectangles in INkscape around it and noting down the pixel dimensions of the these rects.
My intention is to use the union of these "imaginary" rectangles for collision detection. However my efforts hit a snag. The default size of the image on the phone seems to be different from in Inkscape.
I want to know the best way to do collision detection with a large, irregular object, and/or how to make the canvas bitmap measuremtns the same as its pixel (or mm) measurements.
What I suggest to do is to create an equivalent image where you have defined your collision area with a value of 1, and the non collision area with a value of 0 (or 0 and 255).
So, you will have two images, the colourful one which you will display, and the collision image where you will load.
Then, you can detect if you are inside a collision area with:
Bitmap collision;
collision = BitmapFactory.decodeStream(...yourImage...);
collision.getPixel(x,y)
Another solution is to create two arrays post processing the collision image, you could do that creating a Java application that process your original image and creates a text file with two lines, first line is the x coordinate and the second line is the pair y coordinate.
Then, read this file in your Android application and if your x and y exist in this array, is a collision point.