easiest way to zoom on a camera image?

I’m pulling in a camera image in the style of movieGrabberExample and I want to (simulate) a zoom in and out of the image. I had thought I could do it just by altering the origin and width/height values I put in ofVideoGrabber.draw(), e.g.:

void testApp::draw() {



and then update the values of originX/Y and screenW/H as necessary. This does mean that origin values will go negative (in order to keep image centered) and the W/H values will be larger than the original sometimes.

In other words, I’m trying to scale the image just by drawing it larger and shifting its origin.

However, I started getting strange behavior, including an ERROR: SampleCB().

What’s the easiest way to do this? I’m coming from Processing and this is my first oF proj. I’m guessing I need to, on each frame:

-copy a frame from the camera,
-scale it to the size I need
-draw it centered on the screen

but I don’t know how to do that.


your idea of modifying the parameters in draw() should work, maybe your pushing in weird values?

another way would be using opengl like this:

int w = img.width;  
int h = img.height;  
float zoom = mouseX; //or whatever zoom value you need  

1 Like