本文整理汇总了C++中ImageView::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageView::get方法的具体用法?C++ ImageView::get怎么用?C++ ImageView::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageView
的用法示例。
在下文中一共展示了ImageView::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Handle<Value> ImageView::height(const Arguments& args)
{
HandleScope scope;
ImageView* im = ObjectWrap::Unwrap<ImageView>(args.This());
return scope.Close(Integer::New(im->get()->height()));
}
示例2: x
Handle<Value> ImageView::getPixel(const Arguments& args)
{
HandleScope scope;
unsigned x(0);
unsigned y(0);
if (args.Length() >= 2) {
if (!args[0]->IsNumber())
return ThrowException(Exception::TypeError(
String::New("first arg, 'x' must be an integer")));
if (!args[1]->IsNumber())
return ThrowException(Exception::TypeError(
String::New("second arg, 'y' must be an integer")));
x = args[0]->IntegerValue();
y = args[1]->IntegerValue();
} else {
return ThrowException(Exception::TypeError(
String::New("must supply x,y to query pixel color")));
}
ImageView* im = ObjectWrap::Unwrap<ImageView>(args.This());
image_view_ptr view = im->get();
if (x < view->width() && y < view->height())
{
mapnik::image_view<mapnik::image_data_32>::pixel_type const * row = view->getRow(y);
mapnik::image_view<mapnik::image_data_32>::pixel_type const pixel = row[x];
unsigned r = pixel & 0xff;
unsigned g = (pixel >> 8) & 0xff;
unsigned b = (pixel >> 16) & 0xff;
unsigned a = (pixel >> 24) & 0xff;
return Color::New(mapnik::color(r,g,b,a));
}
示例3: ThrowException
Handle<Value> ImageView::save(const Arguments& args)
{
HandleScope scope;
if (!args.Length() >= 1 || !args[0]->IsString()){
return ThrowException(Exception::TypeError(
String::New("filename required")));
}
std::string filename = TOSTR(args[0]);
std::string format("");
if (args.Length() >= 2) {
if (!args[1]->IsString())
return ThrowException(Exception::TypeError(
String::New("both 'filename' and 'format' arguments must be strings")));
format = mapnik::guess_type(TOSTR(args[1]));
if (format == "<unknown>") {
std::ostringstream s("");
s << "unknown output extension for: " << filename << "\n";
return ThrowException(Exception::Error(
String::New(s.str().c_str())));
}
}
ImageView* im = ObjectWrap::Unwrap<ImageView>(args.This());
try
{
save_to_file(*im->get(),filename);
}
catch (const std::exception & ex)
{
return ThrowException(Exception::Error(
String::New(ex.what())));
}
catch (...)
{
return ThrowException(Exception::TypeError(
String::New("unknown exception happened while saving an image, please submit a bug report")));
}
return Undefined();
}
示例4:
Handle<Value> ImageView::isSolid(const Arguments& args)
{
HandleScope scope;
ImageView* im = ObjectWrap::Unwrap<ImageView>(args.This());
image_view_ptr view = im->get();
if (view->width() > 0 && view->height() > 0)
{
mapnik::image_view<mapnik::image_data_32>::pixel_type const* first_row = view->getRow(0);
mapnik::image_view<mapnik::image_data_32>::pixel_type const first_pixel = first_row[0];
for (unsigned y = 0; y < view->height(); ++y)
{
mapnik::image_view<mapnik::image_data_32>::pixel_type const * row = view->getRow(y);
for (unsigned x = 0; x < view->width(); ++x)
{
if (first_pixel != row[x])
{
return scope.Close(Boolean::New(false));
}
}
}
}
return scope.Close(Boolean::New(true));
}