Hi, I’m scaling an image by dragging the corners and the result is a bit strange. As I scale, I keep track of my new width and height. When I draw using ofScale and the scale ratio, I notice an offset between my image and the border. When I don’t use ofScale and just draw the image using the scaled width and height everything works.
Not using ofScale:
ofPushMatrix();
ofSetColor(255,255,255);
ofTranslate(pic->imageCenter.x, pic->imageCenter.y);
ofRotateZRad(pic->angle);
pic->image.draw(-1*pic->width/2, -1*pic->height/2, pic->width, pic->height); //Using scaled width and height 
ofPopMatrix();
ofPushMatrix();
ofTranslate(pic->imageCenter.x, pic->imageCenter.y);
ofRotateZRad(pic->angle);
ofSetColor(255,0,0);
ofNoFill();
ofSetLineWidth(3);
ofDrawRectangle(-1*pic->width/2, -1*pic->height/2, pic->width, pic->height);
Using ofScale:
ofPushMatrix();
ofSetColor(255,255,255);
ofTranslate(pic->imageCenter.x, pic->imageCenter.y);
ofScale((pic->width/pic->image.getWidth()), (pic->height/pic->image.getHeight()), 0); //Scale using ratio
ofRotateZRad(pic->angle);
pic->image.draw(-1*pic->width/2, -1*pic->height/2); //Using original image dimensions
ofPopMatrix();
ofPushMatrix();
ofTranslate(pic->imageCenter.x, pic->imageCenter.y);
ofRotateZRad(pic->angle);
ofSetColor(255,0,0);
ofNoFill();
ofSetLineWidth(3);
ofDrawRectangle(-1*pic->width/2, -1*pic->height/2, pic->width, pic->height);
pic is just an object that contains the original image, scaled width, scaled height, and angle.
offset when using ofScale: