开发者

Inheritance/ Casting Problem (BufferedImages

Merged with Need help getting hei开发者_StackOverflow中文版ght of image (Possible Inheritance Problem).

Ok so this is the KernelHandler Class

getWidth() is a method of the BufferedImage Class

public class KernelHandler extends ImageHandler

I'm getting a cannot find method getWidth()

I know it has something to do with inheritance, but I need help, please

//Heres the contructor

public KernelHandler(String nameOfFile) {

super(nameOfFile);

}

// here's the super constructor

public ImageHandler(String nameOfFile){

 URL imageURL = getClass().getClassLoader().getResource(nameOfFile);
try
{
 myImage = ImageIO.read(imageURL);
}
catch ( IOException e )
{
    System.out.println( "image missing" );
}

// Here's the method were trying to use

public static int numOfRedBoxes(String nameOfImg)

{
    KernelHandler myHand = new KernelHandler(nameOfImg);
    for(int i = 0; i < myHand.getWidth(); i++)

        for(int j = 0; j < myHand.getHeight(); j++){
            if(img.getRGB(i, j) == red){
                numOfRedBoxes++;
           }   
        }
   }
  return numOfRedBoxes;

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜