首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使窗口大小与在C++/Cinder中打开的图像相同

如何使窗口大小与在C++/Cinder中打开的图像相同
EN

Stack Overflow用户
提问于 2015-02-25 19:40:33
回答 1查看 484关注 0票数 1

我想知道怎样才能使窗口的大小与打开的图片的大小相同?

下面是我的代码:

代码语言:javascript
复制
#include "cinder/app/AppNative.h"
#include "cinder/gl/Texture.h"
#include "cinder/Text.h"
#include "cinder/ImageIo.h"

using namespace ci;
using namespace ci::app;
using namespace std;

class ConvexSpiralApp : public AppNative {
  public:
    void setup();
    void draw();

    gl::Texture myImage;
};

void ConvexSpiralApp::setup()
{
    try
    {
        ci::fs::path p = getOpenFilePath( "", ImageIo::getLoadExtensions());

        if( ! p.empty() )
        { // an empty string means the user canceled
            myImage = gl::Texture( loadImage( p ) );
        }
    }

    catch( ... )
    {
        console() << "Unable to load the image." << std::endl;
    }
}

void ConvexSpiralApp::draw()
{
    // clear out the window with black
    gl::clear( Color( 0, 0, 0 ) );

    gl::draw( myImage, getWindowBounds() );
}

CINDER_APP_NATIVE( ConvexSpiralApp, RendererGl )

大风

EN

回答 1

Stack Overflow用户

发布于 2015-02-25 22:43:04

我做到了!

代码语言:javascript
复制
myImage = gl::Texture( processedImage );

setWindowSize(myImage.getWidth(), myImage.getWidth() );
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28718106

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档