Skip to content

Commit edf9412

Browse files
committed
Pass the buffer to createMMBitmap.
1 parent e0f616a commit edf9412

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/robotjs.cc

+6-3
Original file line numberDiff line numberDiff line change
@@ -651,14 +651,17 @@ NAN_METHOD(getColor)
651651
uint8_t bytesPerPixel = obj->Get(Nan::New("bytesPerPixel").ToLocalChecked())->Uint32Value();
652652

653653
char* buf = node::Buffer::Data(obj->Get(Nan::New("image").ToLocalChecked()));
654+
655+
uint8_t *data = (uint8_t *)malloc(byteWidth * height);
656+
memcpy(data, buf, byteWidth * height);
654657

655-
bitmap = createMMBitmap(NULL, width, height, byteWidth, bitsPerPixel, bytesPerPixel);
658+
bitmap = createMMBitmap(data, width, height, byteWidth, bitsPerPixel, bytesPerPixel);
656659

657-
if (bitmap != NULL)
660+
/*if (bitmap != NULL)
658661
{
659662
bitmap->imageBuffer = malloc(bitmap->bytewidth * bitmap->height);
660663
memcpy(bitmap->imageBuffer, buf, bitmap->bytewidth * bitmap->height);
661-
}
664+
}*/
662665

663666
color = MMRGBHexAtPoint(bitmap, x, y);
664667

0 commit comments

Comments
 (0)