Skip to content

Commit 2425d4a

Browse files
committed
Create imageBuffer manually.
1 parent e28cb2a commit 2425d4a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/robotjs.cc

+7-4
Original file line numberDiff line numberDiff line change
@@ -651,12 +651,15 @@ 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-
bitmap = createMMBitmap((uint8_t *)buf, width, height, byteWidth, bitsPerPixel, bytesPerPixel);
656-
657654
color = MMRGBHexAtPoint(bitmap, 300, 300);
658-
659655

656+
bitmap = createMMBitmap(NULL, width, height, byteWidth, bitsPerPixel, bytesPerPixel);
657+
658+
if (bitmap != NULL)
659+
{
660+
bitmap->imageBuffer = malloc(bitmap->bytewidth * bitmap->height);
661+
memcpy(bitmap->imageBuffer, buf, bitmap->bytewidth * bitmap->height);
662+
}
660663

661664
printf("2: %s\n", hex);
662665

0 commit comments

Comments
 (0)