public void renderFromImage(Image i, int xp, int yp, int tileId, int tileWidth, int flip, boolean light) {
		xp -= xOff;
		yp -= yOff;

		boolean flipx = (flip & BIT_MIRROR_X) == BIT_MIRROR_X;
		boolean flipy = (flip & BIT_MIRROR_Y) == BIT_MIRROR_Y;

		int tw = i.getWidth() / tileWidth;
		int xt = tileId % tw;
		int yt = tileId / tw;
		int tileOffset = xt * tileWidth + yt * tileWidth * i.width;

		for (int y = 0; y < tileWidth; y++) {
			if ((y + yp) < 0 || (y + yp) >= height)
				continue;
			int ys = y;
			if (flipy)
				ys = (tileWidth - 1) - y;

			for (int x = 0; x < tileWidth; x++) {
				if ((x + xp) < 0 || (x + xp) >= width)
					continue;
				int xs = x;
				if (flipx)
					xs = (tileWidth - 1) - x;

				int c = i.pixels[xs + (ys * i.width) + tileOffset];
				if (c == 0x7f007f)
					continue;
				if (lightingEnabled && light) {
					c = applyLighting(c, x + xp, y + yp);
				}
				pixels[(x + xp) + (y + yp) * width] = c;
			}
		}
	}