Slick2D not drawing Images?


package net.ld.invalid.main;

import net.ld.invalid.res.resImages;

import org.newdawn.slick.Animation;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

public class Game extends BasicGameState {
	Image i;

	@Override
	public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
		i = new Image("/res/Ghost.png", Color.white);
	}

	@Override
	public void render(GameContainer gc, StateBasedGame sbg, Graphics g)throws SlickException {
		i.draw(100, 100, 300);
	}

	@Override
	public void update(GameContainer gc, StateBasedGame sbg, int Int) throws SlickException {
	}

	@Override
	public int getID() {
		return 0;
	}

}

And it is not working i dont know why?
pls help!

Well what errors are you getting? Is the program compiling, but no textures show up? More details please.

The third variable in .draw(float,float,float) is “scale”. You’re drawing your image at 300x scale. You’re probably drawing it so large you’re only rendering the top left pixel on screen (and it’s probably transparent) :o

no i tried everything it just wont draw i thought that it is small so i put the scale like that no errors nothing!

Slick PNGDecoder Error - java.lang.UnsupportedOperationException: Unsupported format for this image
I got this error… omg and it doesnt show in the console, when i have no transparent pixels i can see the image and get this error and when i have transparent pixels no error no image showing! NO LD FOR ME!e

Haven’t used slick, but make sure the path to image is correct.

It is it works when the image has no transparent pixels! hhmmmmm

Did you make sure you’re decoding with the proper format for including alpha values (which would be affect by transparency)?

CopyableCougar4

Maybe an error with the PNG image. Did you try other images?

I just did -.-’
My image is corupted omg ! thx

Slick’s PNG decoder doesn’t support PNG8, only PNG24. Although it sounds like you solved the problem anyway. :stuck_out_tongue:

EDIT:
Just glanced at the code again, are you sure you’re even entering the state in the first place? init() will load regardless if you enter the state, thus throwing back your error with the image even if the state is not loaded. But then once you fix that and nothing is rendering, there’s a possibility you’re not even in the state to begin with.

Also I just noticed you have Color.white in your image’s constructor, unless you want your image to be solid white for some reason that shouldn’t be there. If your background is white as well, that could be your problem. But slick2D defaults to black I believe.