I am stuck with a downcasting issue with java.
Here is the plot:
The class MyPicture
extends the abstract class BufferedImage
. The point is to add a few methods to BufferedImage
. Then, I have the class MyWindow
which sets a user-friendly window. In this class, I want to load a picture in MyPic
, copy it in MyPic_filtered
, use a method used in MyPicture
on MyPic_filtered
and finally show MyPic
and MyPic_filtered
in separated windows (but this last part is OK ^^).
I don't know which types I should use for MyPic
and MyPic_filtered
. I tried the cast them in the right type, it builds but doesn't run.
Here is the code:
//Loading the picture
BufferedImage MyPic = ImageIO.read(new File(URL)); //URL is a string
//Copy the picture
MyPicture myPic_filtered = myPic;
//Use the method from MyPicture
myPic_filtered.method_from_MyPicture();`
Could someone help me please?