Skip to content

Commit 78fdfad

Browse files
committed
(#45) Fixed off by one error on region caputre
1 parent 045d12d commit 78fdfad

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/main.cc

+12-12
Original file line numberDiff line numberDiff line change
@@ -715,33 +715,33 @@ Napi::Object _captureScreen(const Napi::CallbackInfo &info)
715715
{
716716
Napi::Env env = info.Env();
717717

718-
size_t x;
719-
size_t y;
720-
size_t w;
721-
size_t h;
718+
int64_t x;
719+
int64_t y;
720+
int64_t w;
721+
int64_t h;
722722

723723
MMSize displaySize = getMainDisplaySize();
724724
//If user has provided screen coords, use them!
725725
if (info.Length() == 4)
726726
{
727-
x = info[0].As<Napi::Number>().Int32Value();
728-
y = info[1].As<Napi::Number>().Int32Value();
729-
w = info[2].As<Napi::Number>().Int32Value();
730-
h = info[3].As<Napi::Number>().Int32Value();
727+
x = info[0].As<Napi::Number>().Int64Value();
728+
y = info[1].As<Napi::Number>().Int64Value();
729+
w = info[2].As<Napi::Number>().Int64Value();
730+
h = info[3].As<Napi::Number>().Int64Value();
731731

732-
if (!(x >= 0 && x < displaySize.width))
732+
if (!(x >= 0 && x <= displaySize.width))
733733
{
734734
throw Napi::Error::New(env, "Error: x coordinate outside of display");
735735
}
736-
if (!(y >= 0 && y < displaySize.height))
736+
if (!(y >= 0 && y <= displaySize.height))
737737
{
738738
throw Napi::Error::New(env, "Error: y coordinate outside of display");
739739
}
740-
if (!((x + w) >= 0 && (x + w) < displaySize.width))
740+
if (!((x + w) >= 0 && (x + w) <= displaySize.width))
741741
{
742742
throw Napi::Error::New(env, "Error: Given width exceeds display dimensions");
743743
}
744-
if (!((y + h) >= 0 && (y + h) < displaySize.height))
744+
if (!((y + h) >= 0 && (y + h) <= displaySize.height))
745745
{
746746
throw Napi::Error::New(env, "Error: Given height exceeds display dimensions");
747747
}

0 commit comments

Comments
 (0)