Resizing movie window without stretching width & height

hello all,

i cant remember the exact term for this, so please excuse.

but when setting my movie to the window width and height, then when clicking and dragging, resizing in different directions, it is latched to the corners, which i knew would happen. it squashes the video.

but how can, if i resize the window, it resizes the movie in the correct resolution. say its starts off as 1080, then i drag the corner of the window upwards, it will not squash the video but make the XY of the video 640x480. rather than 640x10 :wink:

looked at some examples, but nothing applies this. if someone helps with the right term its called then ill update the title.

thanks

Hi,

There’s a few ways to go about this, you could store the width and height relation of the movie and make sure you resize things while keeping the original proportions, alternatively have a look at the rectangleAlignmentAndScaling example in the examples/graphics folder, ofRectangle has a lot of scaling options to help you with exactly this.

/A

There’s a nice example in @julapy’s ofxAVFoundationVideoPlayer addon. From https://github.com/julapy/ofxAVFoundationVideoPlayer/blob/b075f3721c87fe44d940408e7decc68483f38913/osxVideoPlayerExample/src/ofApp.cpp#L28-L34

ofRectangle screenRect(0, 0, ofGetWidth(), ofGetHeight());
ofRectangle videoRect(0, 0, video.getWidth(), video.getHeight());
ofRectangle videoFullscreenRect = videoRect;
videoFullscreenRect.scaleTo(screenRect, OF_ASPECT_RATIO_KEEP_BY_EXPANDING);

video.draw(videoFullscreenRect);

Hope that helps!

1 Like

oooh sexy bitch. fantstic. ill give those a look

thank you :wink:

it was @mattfelsen’s one that did the job. really nice. i need to work on it to latch the top left corner, but a great starting point.

both thanks to you both. ofRectangle is pretty useful :wink: