こんにちは、白と黒を画像とブレンドする必要があるプロジェクトがあります。黒のコードは機能していますが、白を機能させることができないようです。誰かが私が間違っていることについて私にアドバイスしてもらえますか?私は以前に簡単に白い作業をしていましたが、それは消えてしまい、どうすればよいのかわかりません...ありがとう! 一番下に写真の結果へのリンクがあります!
import java.awt.Color;
public class BlendingWithBlackAndWhite
{
public static void main(String[] args)
{
FileChooser.pickMediaPath();
BlendablePic pRef = new BlendablePic(FileChooser.pickAFile());
double a[]= new double[3];
a[0]=0.1;
a[1]=0.3;
a[2]=0.5;
pRef.blendRectWithWhite(0, 920, 920, 920, a[0]+0.9);
pRef.blendRectWithWhite(920, 920, 920, 1840, a[2]);
pRef.blendRectWithWhite(1840, 920, 920, 2760, a[1]-0.3);
pRef.blendRectWithBlack(0,0, 920, 920, a[1]);
pRef.blendRectWithBlack(920,0, 1784, 920, a[0]);
pRef.blendRectWithBlack(1785,0, 2600, 920, a[2]*-0.2);
pRef.explore();
}}
public class BlendablePic extends Picture{
public BlendablePic(String filename){
super(filename);
}
public void blendRectWithWhite(int xMin, int yMin, int xMax, int yMax, double a)
{
int x;
x = xMin;
while (x<= xMax)
{
int y;
y = yMin;
while(y <= yMax)
{
Pixel refPix = this.getPixel(x,y);
refPix.setRed((int)Math.round(refPix.getRed() * (1.0-a)+255*a));
refPix.setGreen((int)Math.round(refPix.getGreen() * (1.0-a)+200*a));
refPix.setBlue((int)Math.round(refPix.getBlue() * (1.0-a)+255*a));
y= y+1;
}
x = x+1;
}
}
public void blendRectWithBlack(int xMin, int yMin, int xMax, int yMax, double a)
{
int x;
x = xMin;
while (x<= xMax)
{
int y;
y = yMin;
while(y <= yMax)
{
Pixel refPix = this.getPixel(x,y);
refPix.setRed((int)Math.round(refPix.getRed() * (0.2 +a)+0*a));
refPix.setGreen((int)Math.round(refPix.getGreen() * (0.2 +a)+0*a));
refPix.setBlue((int)Math.round(refPix.getBlue() * (0.2 +a)+0*a));
y = y+1;
}
x = x+1;
}
}}
最初の画像は私が行う必要があるもので、2 番目の画像は上記のコーディングから取得したものです。