mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-22 11:55:15 -04:00
adds scaling to VGA window; closes #800
This commit is contained in:
parent
f7184bc72c
commit
3efe8f32ee
@ -54,7 +54,17 @@ public class VGADialog extends JDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
g.drawImage(image, 0, 0, null);
|
double sx = ((double) getWidth()) / image.getWidth();
|
||||||
|
double sy = ((double) getHeight()) / image.getHeight();
|
||||||
|
|
||||||
|
double s = Math.min(sx, sy);
|
||||||
|
int w = (int) Math.floor(image.getWidth() * s);
|
||||||
|
int h = (int) Math.floor(image.getHeight() * s);
|
||||||
|
|
||||||
|
int x = (getWidth() - w) / 2;
|
||||||
|
int y = (getHeight() - h) / 2;
|
||||||
|
|
||||||
|
g.drawImage(image, x, y, w, h, 0, 0, image.getWidth(), image.getHeight(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user