Java ByteBuffer Size tileImage(Graphics g, BufferedImage tileImage, int width, int height)

Here you can find the source of tileImage(Graphics g, BufferedImage tileImage, int width, int height)

Description

Tiles an image as the background of a graphics object.

License

Open Source License

Parameter

Parameter Description
g - graphics to draw on.
tileImage - image used for tiling.
width - tile along x-axis.
height - tile along y-axis.

Declaration

public static void tileImage(Graphics g, BufferedImage tileImage, int width, int height) 

Method Source Code


//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);
                }
            }
        }
    }
}

Related

  1. sizeOfBytes(ByteBuffer bytes)
  2. sizeOfBytesMap(Map m)
  3. sizeOfValue(ByteBuffer bytes)
  4. sizeP(ByteBuffer bb)
  5. storeInt(ByteBuffer b, int fromIndex, int size, int value)
  6. xysizeIsWhite(BufferedImage img, int x, int y)