mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
added mat.put(buffer) function
This commit is contained in:
parent
e65202575a
commit
150fc4a66d
@ -27,6 +27,7 @@ Matrix::Init(Handle<Object> target) {
|
||||
NODE_SET_PROTOTYPE_METHOD(ctor, "empty", Empty);
|
||||
NODE_SET_PROTOTYPE_METHOD(ctor, "get", Get);
|
||||
NODE_SET_PROTOTYPE_METHOD(ctor, "set", Set);
|
||||
NODE_SET_PROTOTYPE_METHOD(ctor, "put", Put);
|
||||
NODE_SET_PROTOTYPE_METHOD(ctor, "pixel", Pixel);
|
||||
NODE_SET_PROTOTYPE_METHOD(ctor, "width", Width);
|
||||
NODE_SET_PROTOTYPE_METHOD(ctor, "height", Height);
|
||||
@ -271,6 +272,21 @@ NAN_METHOD(Matrix::Set){
|
||||
NanReturnUndefined();
|
||||
}
|
||||
|
||||
// @author tualo
|
||||
// put node buffer directly into the image data
|
||||
// img.put(new Buffer([0,100,0,100,100...]));
|
||||
NAN_METHOD(Matrix::Put){
|
||||
SETUP_FUNCTION(Matrix)
|
||||
|
||||
if (!Buffer::HasInstance(args[0])) {
|
||||
NanThrowTypeError( "Not a buffer" );
|
||||
}
|
||||
const char* buffer_data = Buffer::Data(args[0]);
|
||||
size_t buffer_length = Buffer::Length(args[0]);
|
||||
memcpy(self->mat.data, buffer_data, buffer_length);
|
||||
NanReturnUndefined();
|
||||
}
|
||||
|
||||
NAN_METHOD(Matrix::Size){
|
||||
SETUP_FUNCTION(Matrix)
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ class Matrix: public node::ObjectWrap {
|
||||
|
||||
JSFUNC(Get) // at
|
||||
JSFUNC(Set)
|
||||
JSFUNC(Put)
|
||||
|
||||
JSFUNC(Row)
|
||||
JSFUNC(PixelRow)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user