graphics are now drawn in the center of the frame regardless of frame size and scaling

This commit is contained in:
Diego Waxemberg
2013-12-13 13:27:54 -05:00
parent 3147e34a5a
commit bc64f094ce

View File

@@ -91,8 +91,18 @@ public class SwingCpuDecoderRenderer implements VideoDecoderRenderer {
int newHeight = (int)(height * lowerScale);
nextFrameTime = computePresentationTimeMs(targetFps);
int dx1 = 0;
int dy1 = 0;
if (frame.getWidth() > newWidth) {
dx1 = (frame.getWidth()-newWidth)/2;
}
if (frame.getHeight() > newHeight) {
dy1 = (frame.getHeight()-newHeight)/2;
}
if (AvcDecoder.getRgbFrameInt(imageBuffer, imageBuffer.length)) {
graphics.drawImage(image, 0, 0, newWidth, newHeight, null);
graphics.drawImage(image, dx1, dy1, dx1+newWidth, dy1+newHeight, 0, 0, width, height, null);
//graphics.drawImage(image, 0, 0, newWidth, newHeight, null);
}
}
}