本文整理汇总了C++中ImageRGB::AllocImageData方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageRGB::AllocImageData方法的具体用法?C++ ImageRGB::AllocImageData怎么用?C++ ImageRGB::AllocImageData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageRGB
的用法示例。
在下文中一共展示了ImageRGB::AllocImageData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadImage
// Minimal mock of VW imageio routines
void ReadImage(const std::string& file, ImageRGB<byte>& image) {
CHECK_PRED1(fs::exists, file);
bool jpeg = IsJpegFilename(file);
// Get size
point2<ptrdiff_t> size;
if (jpeg) {
size = jpeg_read_dimensions(file);
} else {
size = png_read_dimensions(file);
}
// Allocate image data
image.AllocImageData(size.x, size.y);
rgba8_view_t v = interleaved_view(image.GetWidth(),
image.GetHeight(),
(rgba8_pixel_t*)image.GetImageBuffer(),
image.GetWidth()*sizeof(PixelRGB<byte>));
// Load the image
if (jpeg) {
jpeg_read_and_convert_view(file, v);
} else {
png_read_and_convert_view(file, v);
}
// GIL uses 255=opaque but we use 0=opaque
InvertAlpha(image);
}
示例2: MatlabArrayToImage
void MatlabArrayToImage(const mxArray* m, ImageRGB<byte>& image) {
CHECK(mxIsDouble(m)) << "Only images of double type are supported at present";
VecI dims = GetMatlabArrayDims(m);
CHECK_EQ(dims.Size(), 3) << "MatlabArrayToImage expects a H x W x 3 array";
CHECK_EQ(dims[2], 3) << "MatlabArrayToImage expects a H x W x 3 array";
image.AllocImageData(dims[1], dims[0]);
double* p = mxGetPr(m);
for (int x = 0; x < dims[1]; x++)
for (int y = 0; y < dims[0]; y++)
image[y][x].r = *p++ * 255; // pixels of type double are in [0,1] under matlab
for (int x = 0; x < dims[1]; x++)
for (int y = 0; y < dims[0]; y++)
image[y][x].g = *p++ * 255; // pixels of type double are in [0,1] under matlab
for (int x = 0; x < dims[1]; x++)
for (int y = 0; y < dims[0]; y++)
image[y][x].b = *p++ * 255; // pixels of type double are in [0,1] under matlab
for (int x = 0; x < dims[1]; x++)
for (int y = 0; y < dims[0]; y++)
image[y][x].alpha = 0;
}