I need to render a large amount of images for my game and they need to be scaled to any aspect ration to fit the screen and I can't find a solution anywhere.
It already renders the image just not in the correct aspect ratio.
Rendering code:
class _canvas extends JComponent {
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
for (renderable_object part : objs) {
if (part.type == 5) {
g.drawImage(part.get_Image(), part.i, part.j, 23,23);
}
}
}
}
Renderable object:
class renderable_object {
int i = 0;
int j = 0;
int k = 0;
int l = 0;
int type = 0;
String file = "";
Image get_Image() {
return(Toolkit.getDefaultToolkit().getImage(file));
}
}