我遇到了這個任務的問題,我必須爲我的java編程類做些什麼。我所要做的就是在具有堅實背景的圖像上執行色度鍵技術。更多信息可以發現here。我創建的方法,當我把兩個對象參數的方法。但是,當我把參數放在構造函數中,然後嘗試使用該方法時,我得到一個編譯器錯誤。我有我的課下面(我必須使用兩個不同的類,一個用於方法,一個用於測試)。任何幫助將不勝感激,我是新來的Java和最簡單的路線將是最好的。找不到符號編譯器錯誤
public class ChromaKey
{
public ChromaKey(Picture backgroundDelete, Picture backgroundImage)
{
}
public void chromaKey()
{
int redValue = 0; int greenValue = 0; int blueValue = 0;
Color pixelColor = null;
Color pixelColor1 = null;
for(int y = 0; y < backgroundImage.getHeight(); y++)
{
for(int x = 0; x < backgroundImage.getWidth(); x++)
{
Pixel targetPixel = new Pixel(backgroundImage,x,y);
Pixel targetPixel1 = new Pixel(backgroundDelete,x,y);
targetPixel = backgroundImage.getPixel(x,y);
pixelColor = targetPixel.getColor();
targetPixel1 = backgroundDelete.getPixel(x,y);
pixelColor1 = targetPixel1.getColor();
int targetRed = pixelColor1.getRed();
int targetBlue = pixelColor1.getGreen();
int targetGreen = pixelColor1.getBlue();
int backgroundRed = pixelColor.getRed();
int backgroundGreen = pixelColor.getGreen();
int backgroundBlue = pixelColor.getBlue();
if(targetRed >= 200 && targetBlue >= 200 && targetGreen >= 200)
{
targetPixel1.setRed(backgroundRed);
targetPixel1.setGreen(backgroundGreen);
targetPixel1.setBlue(backgroundBlue);
}
}
}
backgroundImage.show();
backgroundDelete.show();
}
}
什麼是編譯時錯誤? –
在你的例子中,'backgroundDelete'和'backgroundImage'似乎沒有被初始化。這是你真正使用的課程嗎? –