1

cinder/c++ (私は Xcode を使用しています) を使用して、画像を開いてウィンドウに表示できるプログラムを作成しました。ウィンドウのサイズを、開いていた画像のサイズと同じにするにはどうすればよいでしょうか。

これが私のコードです:

#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 )

強風

4

1 に答える 1