Here you can find the source of applyMaskImage(BufferedImage src, int x, int y, int w, int h)
public static void applyMaskImage(BufferedImage src, int x, int y, int w, int h)
//package com.java2s; //License from project: Open Source License import java.awt.image.BufferedImage; public class Main { public static void applyMaskImage(BufferedImage src, int x, int y, int w, int h) { if (x < 0) { x = 0;/*www .j ava 2 s . c o m*/ } if (y < 0) { y = 0; } int maxOffsetX = x + w; int maxOffsetY = y + h; for (int xCounter = x; xCounter < maxOffsetX; xCounter++) { for (int yCoutner = y; yCoutner < maxOffsetY; yCoutner++) { if (yCoutner > src.getHeight() || xCounter > src.getWidth()) { break; } src.setRGB(xCounter, yCoutner, 0); } } } }