本文整理汇总了C++中ImageRGB::GetImageBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageRGB::GetImageBuffer方法的具体用法?C++ ImageRGB::GetImageBuffer怎么用?C++ ImageRGB::GetImageBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageRGB
的用法示例。
在下文中一共展示了ImageRGB::GetImageBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: CaptureFrameBuffer
void GlutWindow::CaptureFrameBuffer(ImageRGB<byte>& out) const {
CHECK(InGlutThread())
<< "Frame buffer can only be captured inside the GLUT thread.";
Flush();
ResizeImage(out, size_);
glReadPixels(0, 0, size_.x, size_.y,
GL_BGRA, GL_UNSIGNED_BYTE, out.GetImageBuffer());
ResetAlpha(out); // the GL convention for alpha is different to ours
FlipVertical(out); // the GL convention for top and bottom is different to ours
}
示例3: WriteImage
void WriteImage(const std::string& file, const ImageRGB<byte>& image) {
rgba8c_view_t v = interleaved_view(image.GetWidth(),
image.GetHeight(),
(const rgba8_pixel_t*)image.GetImageBuffer(),
image.GetWidth()*sizeof(PixelRGB<byte>));
// Here we use a hack to work around the fact that GIL uses
// 255=opaque but we use 0=opaque
InvertAlpha(const_cast<ImageRGB<byte>&>(image));
if (IsJpegFilename(file)) {
CHECK(false) << "jpeg output not supported";
//jpeg_write_view(file, v);
} else {
png_write_view(file, v);
}
InvertAlpha(const_cast<ImageRGB<byte>&>(image));
}