Skip to content

Commit

Permalink
Throw catchable error if requested pixels are outside the bitmap's di…
Browse files Browse the repository at this point in the history
…mensions.
  • Loading branch information
octalmage committed Apr 17, 2016
1 parent 3eef8cb commit d65576b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,12 @@ NAN_METHOD(getColor)
//Create the bitmap.
bitmap = createMMBitmap(img.image, img.width, img.height, img.byteWidth, img.bitsPerPixel, img.bytesPerPixel);

// Make sure the requested pixel is inside the bitmap.
if (!MMBitmapPointInBounds(bitmap, MMPointMake(x, y)))
{
return Nan::ThrowError("Requested coordinates are outside the bitmap's dimensions.");
}

color = MMRGBHexAtPoint(bitmap, x, y);

char hex[7];
Expand Down

0 comments on commit d65576b

Please sign in to comment.