画像の透明度の特別な部分をもたらしたいと思います。Javaでこれを行うにはどうすればよいですか? 私はいくつかのコードを試しました:
public BufferedImage[] splitBackgroundImages() throws IOException {
int count = 0;
bimages = new BufferedImage[chuncks];
for (int x = 0; x < columns; x++) {
for (int y = 0; y < rows; y++) {
// Initialize the image array with image chunks
bimages[count] = image.getSubimage(x * this.chunckwidth, y
* this.chunckheigth, this.chunckwidth,
this.chunckheigth);
Graphics2D gr = bimages[count].createGraphics();
gr.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 1));
//gr.clearRect(5, 5, chunckwidth-10, chunckheigth -10);
Color transparent = new Color(0,0,0,0);
gr.setPaint(transparent);
gr.setBackground(transparent);
gr.fillRect(5, 5, chunckwidth-10, chunckheigth-10);
/*bimages[count] = gr.getDeviceConfiguration().createCompatibleImage(
chunckwidth, chunckheigth, Transparency.TRANSLUCENT);
*/
gr.fillRect(5, 5, chunckwidth-10, chunckheigth-10);
gr.drawImage(bimages[count++], 0, 0, chunckwidth, chunckheigth,
chunckwidth * y, chunckheigth * x, chunckwidth * y
+ chunckwidth, chunckheigth * x + chunckwidth,
null);
gr.dispose();
}