本文整理汇总了C++中ImageView::Ref方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageView::Ref方法的具体用法?C++ ImageView::Ref怎么用?C++ ImageView::Ref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageView
的用法示例。
在下文中一共展示了ImageView::Ref方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ThrowException
Handle<Value> ImageView::encode(const Arguments& args)
{
HandleScope scope;
ImageView* im = ObjectWrap::Unwrap<ImageView>(args.This());
std::string format = "png";
palette_ptr palette;
// accept custom format
if (args.Length() > 1){
if (!args[0]->IsString())
return ThrowException(Exception::TypeError(
String::New("first arg, 'format' must be a string")));
format = TOSTR(args[0]);
}
// options hash
if (args.Length() >= 2) {
if (!args[1]->IsObject())
return ThrowException(Exception::TypeError(
String::New("optional second arg must be an options object")));
Local<Object> options = args[1]->ToObject();
if (options->Has(String::New("palette")))
{
Local<Value> format_opt = options->Get(String::New("palette"));
if (!format_opt->IsObject())
return ThrowException(Exception::TypeError(
String::New("'palette' must be an object")));
Local<Object> obj = format_opt->ToObject();
if (obj->IsNull() || obj->IsUndefined() || !Palette::constructor->HasInstance(obj))
return ThrowException(Exception::TypeError(String::New("mapnik.Palette expected as second arg")));
palette = ObjectWrap::Unwrap<Palette>(obj)->palette();
}
}
// ensure callback is a function
Local<Value> callback = args[args.Length()-1];
if (!args[args.Length()-1]->IsFunction())
return ThrowException(Exception::TypeError(
String::New("last argument must be a callback function")));
encode_image_baton_t *closure = new encode_image_baton_t();
closure->request.data = closure;
closure->im = im;
closure->image = im->this_;
closure->format = format;
closure->palette = palette;
closure->error = false;
closure->cb = Persistent<Function>::New(Handle<Function>::Cast(callback));
uv_queue_work(uv_default_loop(), &closure->request, EIO_Encode, EIO_AfterEncode);
//uv_ref(uv_default_loop());
im->Ref();
return Undefined();
}
示例2: isSolidSync
Handle<Value> ImageView::isSolid(const Arguments& args)
{
HandleScope scope;
ImageView* im = node::ObjectWrap::Unwrap<ImageView>(args.This());
if (args.Length() == 0) {
return isSolidSync(args);
}
// ensure callback is a function
Local<Value> callback = args[args.Length()-1];
if (!args[args.Length()-1]->IsFunction())
return ThrowException(Exception::TypeError(
String::New("last argument must be a callback function")));
is_solid_image_view_baton_t *closure = new is_solid_image_view_baton_t();
closure->request.data = closure;
closure->im = im;
closure->result = true;
closure->pixel = 0;
closure->error = false;
closure->cb = Persistent<Function>::New(Handle<Function>::Cast(callback));
uv_queue_work(uv_default_loop(), &closure->request, EIO_IsSolid, (uv_after_work_cb)EIO_AfterIsSolid);
im->Ref();
return Undefined();
}