Coordinates out of bounds
Hey, im struggling trying to find a rough algorithm to get the colour of a pixel from where the mouse has clicked on an image, below is some of the code im working on :
Code:
//locations clicked
int pixelX,pixelY;
//make the value = area clicked - the position of the image
pixelX = e.getX() - imageXposition;
pixelY = e.getY() - imageYposition;
// get the pixel that was clicked on
image.getRGB(pixelX, pixelY);
So far it produces odd results, sometimes the results are negative numbers, Im really just looking for a way to check the RGB value anywhere clicked only within the image. Sometimes because of the erratic results of pixelX and y i get an error that the coordinates are out of bounds because the area on an image of 30 pixels cant reach 150. Any help would be fantastic :)