diff --git a/src/HighGUI.cc b/src/HighGUI.cc index 139fe94..4126c69 100644 --- a/src/HighGUI.cc +++ b/src/HighGUI.cc @@ -19,6 +19,7 @@ void NamedWindow::Init(Local target) { Nan::SetPrototypeMethod(ctor, "show", Show); Nan::SetPrototypeMethod(ctor, "destroy", Destroy); Nan::SetPrototypeMethod(ctor, "blockingWaitKey", BlockingWaitKey); + Nan::SetPrototypeMethod(ctor, "resizeWindow", ResizeWindow); target->Set(Nan::New("NamedWindow").ToLocalChecked(), ctor->GetFunction()); }; @@ -34,7 +35,8 @@ NAN_METHOD(NamedWindow::New) { if (info.Length() == 1) { win = new NamedWindow(std::string(*Nan::Utf8String(info[0]->ToString())), 0); } else { //if (info.Length() == 2){ - win = new NamedWindow(std::string(*Nan::Utf8String(info[0]->ToString())), 0); + win = new NamedWindow(std::string(*Nan::Utf8String(info[0]->ToString())), + info[1]->IntegerValue()); } win->Wrap(info.Holder()); @@ -68,8 +70,6 @@ NAN_METHOD(NamedWindow::Destroy) { } NAN_METHOD(NamedWindow::BlockingWaitKey) { - Nan::HandleScope scope; - //SETUP_FUNCTION(NamedWindow) int time = 0; if (info.Length() > 1) { @@ -85,4 +85,16 @@ NAN_METHOD(NamedWindow::BlockingWaitKey) { info.GetReturnValue().Set(Nan::New(res)); } +NAN_METHOD(NamedWindow::ResizeWindow) { + SETUP_FUNCTION(NamedWindow) + + if (info.Length() != 2) { + throw "expected 2 argurments: width, height"; + }//otherwise + + int width = info[0]->IntegerValue(); + int height = info[1]->IntegerValue(); + cv::resizeWindow(self->winname, width, height); +} + #endif diff --git a/src/HighGUI.h b/src/HighGUI.h index 3994892..7b18116 100644 --- a/src/HighGUI.h +++ b/src/HighGUI.h @@ -16,6 +16,7 @@ public: JSFUNC(Show) ;JSFUNC(Destroy) ;JSFUNC(BlockingWaitKey) + ;JSFUNC(ResizeWindow) ; };