本文整理汇总了C++中T2::data方法的典型用法代码示例。如果您正苦于以下问题:C++ T2::data方法的具体用法?C++ T2::data怎么用?C++ T2::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类T2
的用法示例。
在下文中一共展示了T2::data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: import_image
inline int import_image(T2 const& im_in,
WebPPicture & pic,
bool alpha)
{
image<typename T2::pixel> const& data = im_in.data();
std::size_t width = im_in.width();
std::size_t height = im_in.height();
std::size_t stride = sizeof(typename T2::pixel_type) * width;
if (data.width() == width &&
data.height() == height)
{
if (alpha)
{
return WebPPictureImportRGBA(&pic, data.bytes(), static_cast<int>(stride));
}
else
{
#if (WEBP_ENCODER_ABI_VERSION >> 8) >= 1
return WebPPictureImportRGBX(&pic, data.bytes(), static_cast<int>(stride));
#else
return WebPPictureImportRGBA(&pic, data.bytes(), static_cast<int>(stride));
#endif
}
}
else
{
// need to copy: https://github.com/mapnik/mapnik/issues/2024
image_rgba8 im(width,height);
for (unsigned y = 0; y < height; ++y)
{
typename T2::pixel_type const * row_from = im_in.get_row(y);
image_rgba8::pixel_type * row_to = im.get_row(y);
std::copy(row_from, row_from + width, row_to);
}
if (alpha)
{
return WebPPictureImportRGBA(&pic, im.bytes(), static_cast<int>(stride));
}
else
{
#if (WEBP_ENCODER_ABI_VERSION >> 8) >= 1
return WebPPictureImportRGBX(&pic, im.bytes(), static_cast<int>(stride));
#else
return WebPPictureImportRGBA(&pic, im.bytes(), static_cast<int>(stride));
#endif
}
}
}
示例2: import_image_data
inline int import_image_data(T2 const& image,
WebPPicture & pic,
bool alpha)
{
ImageData<typename T2::pixel_type> const& data = image.data();
int stride = sizeof(typename T2::pixel_type) * image.width();
if (data.width() == image.width() &&
data.height() == image.height())
{
if (alpha)
{
return WebPPictureImportRGBA(&pic, data.getBytes(), stride);
}
else
{
#if (WEBP_ENCODER_ABI_VERSION >> 8) >= 1
return WebPPictureImportRGBX(&pic, data.getBytes(), stride);
#else
return WebPPictureImportRGBA(&pic, data.getBytes(), stride);
#endif
}
}
else
{
// need to copy: https://github.com/mapnik/mapnik/issues/2024
image_data_32 im(image.width(),image.height());
for (unsigned y = 0; y < image.height(); ++y)
{
typename T2::pixel_type const * row_from = image.getRow(y);
image_data_32::pixel_type * row_to = im.getRow(y);
std::memcpy(row_to,row_from,stride);
}
if (alpha)
{
return WebPPictureImportRGBA(&pic, im.getBytes(), stride);
}
else
{
#if (WEBP_ENCODER_ABI_VERSION >> 8) >= 1
return WebPPictureImportRGBX(&pic, im.getBytes(), stride);
#else
return WebPPictureImportRGBA(&pic, im.getBytes(), stride);
#endif
}
}
}