I made a program with cinder/c++ (I am using Xcode) that allows you to open an image and show it in a window. I was wondering how can I make the size of the window the same as the size of the picture that had been opened?
Here is my code:
#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 )
Gale