I’m looping through a bitmap pixel by pixel to determin if that pixel is within a circle placed on the bitmap. i’ve been kindly given the math to determin this but the algorithm is using pow(double, double). i’ve tried casting and using Integer.doubleValue to no avail. has anyone got any ideas how to get the pow method to return an int which the sqrt() method needs? centreX and centreY are both int too.
[update]
sorry sqrt returns and needs a double:)
thanks mat.
for (int i=0; i < bgr.getWidth(); ++i) {
for (int y=0; y < bgr.getHeight(); ++y) {
int aPixel = bgr.getPixel(i,y);
if( sqrt( pow(i - centreX, 2) + ( pow(y - centreY, 2) ) ) <= radius ){
bgr.setPixel(i,y,Color.MAGENTA);
}
}
}
Thanks all,
My bad the pow() method is static from the Math class so needed the dot operator to access it statically. silly mistake:) eg Math.pow(d,d);