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


C++ TypeDesc::is_floating_point方法代码示例

本文整理汇总了C++中TypeDesc::is_floating_point方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeDesc::is_floating_point方法的具体用法?C++ TypeDesc::is_floating_point怎么用?C++ TypeDesc::is_floating_point使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeDesc的用法示例。


在下文中一共展示了TypeDesc::is_floating_point方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: convert_image

bool
ImageOutput::copy_to_image_buffer (int xbegin, int xend, int ybegin, int yend,
                                   int zbegin, int zend, TypeDesc format,
                                   const void *data, stride_t xstride,
                                   stride_t ystride, stride_t zstride,
                                   void *image_buffer, TypeDesc buf_format)
{
    const ImageSpec &spec (this->spec());
    if (buf_format == TypeDesc::UNKNOWN)
        buf_format = spec.format;
    spec.auto_stride (xstride, ystride, zstride, format, spec.nchannels,
                      spec.width, spec.height);
    stride_t buf_xstride = spec.nchannels * buf_format.size();
    stride_t buf_ystride = buf_xstride * spec.width;
    stride_t buf_zstride = buf_ystride * spec.height;
    stride_t offset = (xbegin-spec.x)*buf_xstride
                    + (ybegin-spec.y)*buf_ystride
                    + (zbegin-spec.z)*buf_zstride;
    int width = xend-xbegin, height = yend-ybegin, depth = zend-zbegin;
    imagesize_t npixels = imagesize_t(width) * imagesize_t(height) * imagesize_t(depth);

    // Add dither if requested -- requires making a temporary staging area
    boost::scoped_array<float> ditherarea;
    unsigned int dither = spec.get_int_attribute ("oiio:dither", 0);
    if (dither && format.is_floating_point() &&
            buf_format.basetype == TypeDesc::UINT8) {
        stride_t pixelsize = spec.nchannels * sizeof(float);
        ditherarea.reset (new float [pixelsize * npixels]);
        OIIO::convert_image (spec.nchannels, width, height, depth,
                             data, format, xstride, ystride, zstride,
                             ditherarea.get(), TypeDesc::FLOAT,
                             pixelsize, pixelsize*width,
                             pixelsize*width*height);
        data = ditherarea.get();
        format = TypeDesc::FLOAT;
        xstride = pixelsize;
        ystride = xstride * width;
        zstride = ystride * height;
        float ditheramp = spec.get_float_attribute ("oiio:ditheramplitude", 1.0f/255.0f);
        OIIO::add_dither (spec.nchannels, width, height, depth, (float *)data,
                          pixelsize, pixelsize*width, pixelsize*width*height,
                          ditheramp, spec.alpha_channel, spec.z_channel,
                          dither, 0, xbegin, ybegin, zbegin);
    }

    return OIIO::convert_image (spec.nchannels, width, height, depth,
                                data, format, xstride, ystride, zstride,
                                (char *)image_buffer + offset, buf_format,
                                buf_xstride, buf_ystride, buf_zstride);
}
开发者ID:LumaPictures,项目名称:oiio,代码行数:50,代码来源:imageoutput.cpp


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