Problem with the way I load levels

Hello,
this is the code I load the levels with :


	private void LoadImageLevel(BufferedImage image) {
		int w = image.getWidth();
		int h = image.getHeight();

		for (int xx = 0; xx < h; xx++) {
			for (int yy = 0; yy < w; yy++) {
				int pixel = image.getRGB(xx, yy);
				int red = (pixel >> 16) & 0xff;
				int green = (pixel >> 8) & 0xff;
				int blue = (pixel) & 0xff;

				if (red == 0 && green == 0 && blue == 100) {
					handler.addObject(new Background(0, 0, ObjectId.Background)); // background
					handler.addObject(new Block(xx * 32, yy * 32, 0,
							ObjectId.Block));

				}
				if (red == 100 && green == 60 && blue == 0) { // / block
					handler.addObject(new Block(xx * 32, yy * 32, 0,
							ObjectId.Block));

				}
				if (red == 100 && green == 50 && blue == 0) { // /block 1
					handler.addObject(new Block(xx * 32, yy * 32, 1,
							ObjectId.Block));

  • many more objects.
    As you can see, Im loading the level from a png file and the problem is that the objects that are checked first are rendered first.
    Thats a problem because the character gets rendered under other objects and etc…
    My question is,how can I render the objects in layers? for example, the character is in layer 5,all the blocks are layer 4 and so on.
    Thanks !!