我想知道怎样才能使窗口的大小与打开的图片的大小相同?
下面是我的代码:
#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 )大风
发布于 2015-02-25 22:43:04
我做到了!
myImage = gl::Texture( processedImage );
setWindowSize(myImage.getWidth(), myImage.getWidth() );https://stackoverflow.com/questions/28718106
复制相似问题