本文整理汇总了C++中Image2D::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Image2D::size方法的具体用法?C++ Image2D::size怎么用?C++ Image2D::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image2D
的用法示例。
在下文中一共展示了Image2D::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: release
void ImageTest::release() {
unsigned char data[] = {'c', 'a', 'f', 'e'};
Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 4}, data);
const unsigned char* const pointer = a.release();
CORRADE_COMPARE(pointer, data);
CORRADE_COMPARE(a.data(), nullptr);
CORRADE_COMPARE(a.size(), Vector2i());
}
示例2: screenshot
bool screenshot(PluginManager::Manager<Trade::AbstractImageConverter>& manager, GL::AbstractFramebuffer& framebuffer, const PixelFormat format, const std::string& filename) {
Containers::Pointer<Trade::AbstractImageConverter> converter;
if(!(converter = manager.loadAndInstantiate("AnyImageConverter")))
return false;
Image2D image = framebuffer.read(framebuffer.viewport(), {format});
if(!converter->exportToFile(image, filename))
return false;
Debug{} << "DebugTools::screenshot(): saved a" << format << "image of size" << image.size() << "to" << filename;
return true;
}
示例3: image
void CubeMapTextureGLTest::image() {
CubeMapTexture texture;
texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8,
ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {ColorFormat::RGBA, ColorType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(
Containers::ArrayReference<const UnsignedByte>(image.data<UnsignedByte>(), image.pixelSize()*image.size().product()),
Containers::ArrayReference<const UnsignedByte>{Data}, TestSuite::Compare::Container);
#endif
}
示例4: read
void FramebufferGLTest::read() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
#endif
Renderbuffer color;
#ifndef MAGNUM_TARGET_GLES2
color.setStorage(RenderbufferFormat::RGBA8, Vector2i(128));
#else
color.setStorage(RenderbufferFormat::RGBA4, Vector2i(128));
#endif
/* Separate depth and stencil renderbuffers are not supported (or at least
on my NVidia, thus we need to do this juggling with one renderbuffer */
Renderbuffer depthStencil;
#ifdef MAGNUM_TARGET_GLES2
if(Context::current()->isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
#endif
{
#ifdef MAGNUM_TARGET_GLES2
Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string();
#endif
depthStencil.setStorage(RenderbufferFormat::Depth24Stencil8, Vector2i(128));
}
#ifdef MAGNUM_TARGET_GLES2
else depthStencil.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128));
#endif
Framebuffer framebuffer({{}, Vector2i(128)});
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color)
.attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil);
#ifdef MAGNUM_TARGET_GLES2
if(Context::current()->isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
#endif
{
framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment::Stencil, depthStencil);
}
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::ReadDraw), Framebuffer::Status::Complete);
Renderer::setClearColor(Math::normalize<Color4>(Color4ub(128, 64, 32, 17)));
Renderer::setClearDepth(Math::normalize<Float, UnsignedShort>(48352));
Renderer::setClearStencil(67);
framebuffer.clear(FramebufferClear::Color|FramebufferClear::Depth|FramebufferClear::Stencil);
Image2D colorImage = framebuffer.read(Range2Di::fromSize({16, 8}, {8, 16}), {ColorFormat::RGBA, ColorType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(colorImage.size(), Vector2i(8, 16));
CORRADE_COMPARE(colorImage.data<Color4ub>()[0], Color4ub(128, 64, 32, 17));
#ifdef MAGNUM_TARGET_GLES
if(Context::current()->isExtensionSupported<Extensions::GL::NV::read_depth>())
#endif
{
#ifdef MAGNUM_TARGET_GLES
Debug() << "Using" << Extensions::GL::NV::read_depth::string();
#endif
Image2D depthImage = framebuffer.read({{}, Vector2i{1}}, {ColorFormat::DepthComponent, ColorType::UnsignedShort});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(depthImage.data<UnsignedShort>()[0], 48352);
}
#ifdef MAGNUM_TARGET_GLES
if(Context::current()->isExtensionSupported<Extensions::GL::NV::read_stencil>())
#endif
{
#ifdef MAGNUM_TARGET_GLES
Debug() << "Using" << Extensions::GL::NV::read_stencil::string();
#endif
Image2D stencilImage = framebuffer.read({{}, Vector2i{1}}, {ColorFormat::StencilIndex, ColorType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(stencilImage.data<UnsignedByte>()[0], 67);
}
#ifdef MAGNUM_TARGET_GLES
if(Context::current()->isExtensionSupported<Extensions::GL::NV::read_depth_stencil>())
#endif
{
#ifdef MAGNUM_TARGET_GLES
Debug() << "Using" << Extensions::GL::NV::read_depth_stencil::string();
#endif
Image2D depthStencilImage = framebuffer.read({{}, Vector2i{1}}, {ColorFormat::DepthStencil, ColorType::UnsignedInt248});
MAGNUM_VERIFY_NO_ERROR();
/** @todo This will probably fail on different systems */
CORRADE_COMPARE(depthStencilImage.data<UnsignedInt>()[0] >> 8, 12378300);
CORRADE_COMPARE(depthStencilImage.data<UnsignedByte>()[0], 67);
}