找不到符号编译器错误 [英] Cannot find symbol compiler error

查看:178
本文介绍了找不到符号编译器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个作业的问题,我必须做我的java编程类。我要做的是在具有实心背景的图像上执行色度键技术。有关详情,请访问这里。我创建的方法工作时,我把方法的两个对象参数。但是,当我把参数在构造函数,然后尝试使用该方法,我得到一个编译器错误。我有我的类下面(我必须使用两个不同的类,一个用于方法,一个用于测试)。任何帮助将不胜感激,我是新的java和最简单的路线将是最好的。

I'm having problems with this assignment I have to do for my java programming class. What I have to do is perform a chroma key technique on an image with a solid background. More info can be found here. The method I created works when I put the two object parameters for the method. But, when I put the parameters in the constructor and then try to use the method, I get a compiler error. I have my class down below (I have to use two different classes, one for methods, one for testing). Any help would be appreciated, I'm new to java and the most simple route would be best.

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


推荐答案

一些看起来像他们失踪的东西。首先,你是导入Color和Pixel类,还是包含在与ChromaKey类相同的包中?

There's a few things that look like they're missing. First of all, are you importing the Color and Pixel classes, or are they included in the same package as your ChromaKey class?

其次,你需要定义backgroundImage和backgroundDelete作为类变量,以便在你的void chromaKey()方法中调用它(注意private Picture backgroundDelete;以及您的构造函数中的赋值):

Second, you need to define backgroundImage and backgroundDelete as a class variable in order to call it in your void chromaKey() method (notice "private Picture backgroundDelete;" line I added, along with the assignment in your constructor):

public class ChromaKey
{

public class ChromaKey {

private Picture backgroundDelete;
private Picture backgroundImage;


public ChromaKey(Picture backgroundDelete, Picture backgroundImage)
{  
    this.backgroundDelete = backgroundDelete;
    this.backgroundImage = 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();
}

}

这篇关于找不到符号编译器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆