Resolution and scaling pictures

Hello,

I have a simple app that loops through some pictures

What I want is to give relative (to screen resolution) coordinates and have the program position the image in such a way that the its horizontal dimension fits exactly the screen and the proportions are maintained intact in respect to the image’ s resolution

I want to make my app able to playback in other computers that would have different screen resolutions and keep the image proportions intact

any clues ?

thx !

  
float ratio = img.getWidth()/img.getHeight();  
img.draw(ofGetWidth(),ofGetWidth()/ratio);  

in case ratio<1 (width<height) the image will be partially shown actually. in that case you can adjust it to the height of the screen doing the opposite calculation.

1 Like

thx !

Newbie/artist here. I’m not having success with drawing images and scaling them to the screen while keeping the image ratio. I made a little app to isolate the problem. It seems the image is being drawn to the bottom and right of the screen(?).

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){

img.loadImage("images/01.png");

}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){

ofSetColor(255);
float ratio = img.getWidth()/img.getHeight();
img.draw(ofGetWidth(),ofGetWidth()/ratio);

}

Yes, the image will not be drawn on screen if you set its upper left hand corner to (ofGetWidth(), …). It will always draw off screen to the right.