我用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 )
大风
答案 0 :(得分:0)
我做到了!
myImage = gl::Texture( processedImage );
setWindowSize(myImage.getWidth(), myImage.getWidth() );