-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImage.cpp
More file actions
37 lines (24 loc) · 865 Bytes
/
Image.cpp
File metadata and controls
37 lines (24 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "Image.h"
#include "Arguments.hpp"
#include "imebra.hpp"
using namespace bindings;
Nan::Persistent<v8::Function> Image::constructor;
Image::Image() {
}
void Image::Init(v8::Local<v8::Object> exports) {
auto tpl = Nan::New<v8::FunctionTemplate>(New);
tpl->SetClassName(Nan::New("Image").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);
Nan::SetPrototypeMethod(tpl,"getWidth",GetWidth);
constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked());
Nan::Set(exports,Nan::New("Image").ToLocalChecked(),Nan::GetFunction(tpl).ToLocalChecked());
}
NAN_METHOD(Image::New) {
auto img = new Image();
img->Wrap(info.This());
info.GetReturnValue().Set(info.This());
}
NAN_METHOD(Image::GetWidth) {
UNWRAP(info.This(),Image,img);
info.GetReturnValue().Set(Nan::New(img->value->getWidth()));
}