当前位置: 首页>>代码示例>>C++>>正文


C++ DynamicJpegStack类代码示例

本文整理汇总了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();
}
开发者ID:elbart,项目名称:node-jpeg,代码行数:31,代码来源:dynamic_jpeg_stack.cpp

示例2:

Handle<Value>
DynamicJpegStack::JpegEncodeSync(const Arguments &args)
{
    HandleScope scope;
    DynamicJpegStack *jpeg = ObjectWrap::Unwrap<DynamicJpegStack>(args.This());
    return scope.Close(jpeg->JpegEncodeSync());
}
开发者ID:elbart,项目名称:node-jpeg,代码行数:7,代码来源:dynamic_jpeg_stack.cpp

示例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);
}
开发者ID:kfitzgerald,项目名称:node-libjpeg,代码行数:32,代码来源:dynamic_jpeg_stack.cpp

示例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();
}
开发者ID:CryptArc,项目名称:lamassu-machine,代码行数:32,代码来源:dynamic_jpeg_stack.cpp

示例5: Undefined

Handle<Value>
DynamicJpegStack::Reset(const Arguments &args)
{
    HandleScope scope;

    DynamicJpegStack *jpeg = ObjectWrap::Unwrap<DynamicJpegStack>(args.This());
    jpeg->Reset();
    return Undefined();
}
开发者ID:elbart,项目名称:node-jpeg,代码行数:9,代码来源:dynamic_jpeg_stack.cpp

示例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;
}
开发者ID:elbart,项目名称:node-jpeg,代码行数:40,代码来源:dynamic_jpeg_stack.cpp


注:本文中的DynamicJpegStack类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。