FEATURE HighGUI.cc: add resize window function

This commit is contained in:
Simon Thiel 2017-09-28 14:19:50 +02:00
parent fa663d449b
commit ece9efc8c9
2 changed files with 16 additions and 3 deletions

View File

@ -19,6 +19,7 @@ void NamedWindow::Init(Local<Object> 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<Number>(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

View File

@ -16,6 +16,7 @@ public:
JSFUNC(Show)
;JSFUNC(Destroy)
;JSFUNC(BlockingWaitKey)
;JSFUNC(ResizeWindow)
;
};