Skip to content

Commit

Permalink
0 is the image, 1 is x, and 2 is y. :|
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Apr 16, 2016
1 parent 0dfd515 commit c411267
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -746,37 +746,37 @@ BMP buildBMP(Local<Object> info)

char* buf = node::Buffer::Data(obj->Get(Nan::New("image").ToLocalChecked()));

//Convert the buffer to a uint8_t which createMMBitmap requires.
//Convert the buffer to a uint8_t which createMMBitmap requires.
img.image = (uint8_t *)malloc(img.byteWidth * img.height);
memcpy(img.image, buf, img.byteWidth * img.height);

return img;
}

NAN_METHOD(getColor)
{
NAN_METHOD(getColor)
{
MMBitmapRef bitmap;
MMRGBHex color;
size_t x = info[0]->Int32Value();
size_t y = info[1]->Int32Value();

size_t x = info[1]->Int32Value();
size_t y = info[2]->Int32Value();

//Get our image object from JavaScript.
BMP img = buildBMP(Nan::To<v8::Object>(info[0]).ToLocalChecked());

//Create the bitmap.
bitmap = createMMBitmap(img.image, img.width, img.height, img.byteWidth, img.bitsPerPixel, img.bytesPerPixel);

color = MMRGBHexAtPoint(bitmap, x, y);

char hex[7];

padHex(color, hex);

destroyMMBitmap(bitmap);

info.GetReturnValue().Set(Nan::New(hex).ToLocalChecked());

}

NAN_MODULE_INIT(InitAll)
Expand Down

0 comments on commit c411267

Please sign in to comment.