January 26, 2018, 3:31pm
I am a newbie in Openframeworks. I was wondering if there is a way to automatically preserve aspect ratio of an Image?
image.draw(ofGetWidth()/2 - image.getWidth()/2, ofGetHeight()/2 - image.getHeight()/2, 100, auto?);
I did search for topics on this is the forum but didn’t find anything. Sorry if this is such a noob question.
January 26, 2018, 5:33pm
image.draw(ofGetWidth() / 2 - image.getWidth() / 2,
ofGetHeight()/ 2 - image.getHeight()/ 2,
100 * image.getHeight() / image.getWidth());
Sometimes it’s convenient to use
ofRectangle, because it has many methods to query corners, scale, fit, cover… Not needed if you are just drawing one image, but if you want to draw other items next to the image it can be useful.
fitArea.setFromCenter(ofGetWidth()/2, ofGetHeight()/2, 100, 100);