isImagePixel method

bool isImagePixel(
  1. int x,
  2. int y,
  3. Size size
)

Implementation

bool isImagePixel(int x, int y, Size size) {
  // Calculate the coordinates of the pixel in the image space
  double imageSize = size.width * 0.3;
  double imageX = (size.width - imageSize) / 2;
  double imageY = (size.height - imageSize) / 2;
  double pixelSize = imageSize / image!.width;

  // Calculate the coordinates of the pixel in the image
  int imagePixelX = ((x - imageX) / pixelSize).toInt();
  int imagePixelY = ((y - imageY) / pixelSize).toInt();

  // Check if the pixel coordinates are within the image boundaries
  return imagePixelX >= 0 && imagePixelX < image!.width && imagePixelY >= 0 && imagePixelY < image!.height;
}