Here you can find the source of tileImage(Graphics g, BufferedImage tileImage, int width, int height)
Parameter | Description |
---|---|
g | - graphics to draw on. |
tileImage | - image used for tiling. |
width | - tile along x-axis. |
height | - tile along y-axis. |
public static void tileImage(Graphics g, BufferedImage tileImage, int width, int height)
//package com.java2s; //License from project: Open Source License import java.awt.Graphics; import java.awt.image.BufferedImage; public class Main { /**/* ww w . ja v a2 s. com*/ * Tiles an image as the background of a graphics object. * * @param g - graphics to draw on. * @param tileImage - image used for tiling. * @param width - tile along x-axis. * @param height - tile along y-axis. */ public static void tileImage(Graphics g, BufferedImage tileImage, int width, int height) { int iw = tileImage.getWidth(); int ih = tileImage.getHeight(); if (iw > 0 && ih > 0) { for (int x = 0; x < width; x += iw) { for (int y = 0; y < height; y += ih) { g.drawImage(tileImage, x, y, iw, ih, null); } } } } }