本文整理汇总了C++中DynamicJpegStack类的典型用法代码示例。如果您正苦于以下问题:C++ DynamicJpegStack类的具体用法?C++ DynamicJpegStack怎么用?C++ DynamicJpegStack使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DynamicJpegStack类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VException
Handle<Value>
DynamicJpegStack::JpegEncodeAsync(const Arguments &args)
{
HandleScope scope;
if (args.Length() != 1)
return VException("One argument required - callback function.");
if (!args[0]->IsFunction())
return VException("First argument must be a function.");
Local<Function> callback = Local<Function>::Cast(args[0]);
DynamicJpegStack *jpeg = ObjectWrap::Unwrap<DynamicJpegStack>(args.This());
encode_request *enc_req = (encode_request *)malloc(sizeof(*enc_req));
if (!enc_req)
return VException("malloc in DynamicJpegStack::JpegEncodeAsync failed.");
enc_req->callback = Persistent<Function>::New(callback);
enc_req->jpeg_obj = jpeg;
enc_req->jpeg = NULL;
enc_req->jpeg_len = 0;
enc_req->error = NULL;
eio_custom(EIO_JpegEncode, EIO_PRI_DEFAULT, EIO_JpegEncodeAfter, enc_req);
ev_ref(EV_DEFAULT_UC);
jpeg->Ref();
return Undefined();
}
示例2:
Handle<Value>
DynamicJpegStack::JpegEncodeSync(const Arguments &args)
{
HandleScope scope;
DynamicJpegStack *jpeg = ObjectWrap::Unwrap<DynamicJpegStack>(args.This());
return scope.Close(jpeg->JpegEncodeSync());
}
示例3: free
void
DynamicJpegStack::UV_JpegEncodeAfter(uv_work_t *req)
{
;
encode_request *enc_req = (encode_request *)req->data;
delete req;
DynamicJpegStack *jpeg = (DynamicJpegStack *)enc_req->jpeg_obj;
Handle<Value> argv[3];
if (enc_req->error) {
argv[0] = Nan::Undefined();
argv[1] = Nan::Undefined();
argv[2] = Nan::Error(enc_req->error);
}
else {
Handle<Object> buf = Nan::NewBuffer(enc_req->jpeg, enc_req->jpeg_len).ToLocalChecked();
argv[0] = buf;
argv[1] = jpeg->Dimensions();
argv[2] = Nan::Undefined();
}
enc_req->callback->Call(3, argv);
delete enc_req->callback;
free(enc_req->jpeg);
free(enc_req->error);
jpeg->Unref();
free(enc_req);
}
示例4: VException
Handle<Value>
DynamicJpegStack::JpegEncodeAsync(const Arguments &args)
{
HandleScope scope;
if (args.Length() != 1)
return VException("One argument required - callback function.");
if (!args[0]->IsFunction())
return VException("First argument must be a function.");
Local<Function> callback = Local<Function>::Cast(args[0]);
DynamicJpegStack *jpeg = ObjectWrap::Unwrap<DynamicJpegStack>(args.This());
encode_request *enc_req = (encode_request *)malloc(sizeof(*enc_req));
if (!enc_req)
return VException("malloc in DynamicJpegStack::JpegEncodeAsync failed.");
enc_req->callback = Persistent<Function>::New(callback);
enc_req->jpeg_obj = jpeg;
enc_req->jpeg = NULL;
enc_req->jpeg_len = 0;
enc_req->error = NULL;
uv_work_t* req = new uv_work_t;
req->data = enc_req;
uv_queue_work(uv_default_loop(), req, UV_JpegEncode, (uv_after_work_cb)UV_JpegEncodeAfter);
jpeg->Ref();
return Undefined();
}
示例5: Undefined
Handle<Value>
DynamicJpegStack::Reset(const Arguments &args)
{
HandleScope scope;
DynamicJpegStack *jpeg = ObjectWrap::Unwrap<DynamicJpegStack>(args.This());
jpeg->Reset();
return Undefined();
}
示例6: ev_unref
int
DynamicJpegStack::EIO_JpegEncodeAfter(eio_req *req)
{
HandleScope scope;
ev_unref(EV_DEFAULT_UC);
encode_request *enc_req = (encode_request *)req->data;
DynamicJpegStack *jpeg = (DynamicJpegStack *)enc_req->jpeg_obj;
Handle<Value> argv[3];
if (enc_req->error) {
argv[0] = Undefined();
argv[1] = Undefined();
argv[2] = ErrorException(enc_req->error);
}
else {
Buffer *buf = Buffer::New(enc_req->jpeg_len);
memcpy(BufferData(buf), enc_req->jpeg, enc_req->jpeg_len);
argv[0] = buf->handle_;
argv[1] = jpeg->Dimensions();
argv[2] = Undefined();
}
TryCatch try_catch; // don't quite see the necessity of this
enc_req->callback->Call(Context::GetCurrent()->Global(), 3, argv);
if (try_catch.HasCaught())
FatalException(try_catch);
enc_req->callback.Dispose();
free(enc_req->jpeg);
free(enc_req->error);
jpeg->Unref();
free(enc_req);
return 0;
}