I've loaded an image in java but it looks like it zoomed in as the edges have gone in the image
there is what is loading I have tried many methods of trying to fix it. I'm trying to make a windows 95 text based adventure in java, all is going well but the said image loading issue.
Here's the code, please ignore the messiness
package com.TTG1.screen;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
public class Game extends JFrame{
Image dbImage;
Graphics dbg;
double startTime;
double tempTime;
Thread thread = new Thread();
public Color WIN95GREEN = new Color(33, 135, 99);
public int WIDTH = 320;
public int HEIGHT = 240;
public int SCALE = 2;
public boolean boot = true;
BufferedImage bu;
BufferedImage tb;
BufferedImage d;
public Game() {
setSize(WIDTH * SCALE, HEIGHT * SCALE);
setVisible(true);
setBackground(Color.white);
setTitle("Swodniw 21");
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setStartTime();
loopTime();
}
public void paint(Graphics g){
dbImage = createImage(getWidth(), getHeight());
dbg = dbImage.getGraphics();
draw(dbg);
g.drawImage(dbImage, 0, 0, this);
}
public void setStartTime(){
if(boot){
startTime = System.currentTimeMillis();
System.out.println("Time Set!");
}
}
public void draw(Graphics g){
if(boot){
try{
bu = ImageIO.read(getClass().getResource("/images/load.png"));
d = ImageIO.read(getClass().getResource("/images/desktop.png"));
}catch(Exception e){
e.printStackTrace();
}
g.drawImage(bu, 0, 0, null);
}
else{
g.drawImage(d, 0, 0, null);
}
repaint();
}
public static void main(String[] args){
Game game = new Game();
}
public void loopTime(){
while(boot){
System.out.println(tempTime - startTime);
tempTime = System.currentTimeMillis();
if(tempTime - startTime > 5000){
boot = false;
System.out.print("boot set to false");
}
}
}
}