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


C++ ImageView::get方法代码示例

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

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

示例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();
}
开发者ID:yhahn,项目名称:node-mapnik,代码行数:45,代码来源:mapnik_image_view.cpp

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


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