Ok thanks for the tips, as i said i'm quite new to java but im here for learning
I've now removed the Jframe and the Graphics object.
It solved why the pictures were painted "in" each other.
(Also i removed the rect in the background and set the background color instead.)
Now the only problem is when i try to load an image with imageIO.read() i can no longer set the picture to transparent.
Without loading anything i'm able to set the bufferedImage to any transparency and Color but as soon as i've loaded something in it i can set Color but not transparency.
import java.applet.Applet;
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
public class Testing extends Applet{
BufferedImage image;
public Testing(){}
public void init(){
image = new BufferedImage(300, 300, BufferedImage.TYPE_4BYTE_ABGR);
try{
image = ImageIO.read(new File("bump.png"));
}
catch(IOException e){}
for (int i=0; i<image.getWidth(); i++){
for (int j=0; j<image.getHeight(); j++){
image.setRGB(i,j,0x2200FFFF);
}}
setBackground(new Color(255,0,0));
}
public void paint(Graphics g){
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(image, 0,0, 100, 100, null);
}
}
--- Update ---
Ok i think i've managed to fix my problem in another way (By reading some more on this awesome forum).
Instead of overwriting the pixels with transparent pixels i instead load an image already drawn transparent. Would be fun to know how i could overwrite pixels with transparent ones in the future though but for now my problem is solved.
Thanks for your amazing help