I think you just discovered a missing feature.
- Does it make sense to have
BufferedImage implements Serializable ? In my opinion, this is so. Especially if BufferedImage not loaded from a file, but created and drawn. But even if it is from a file that takes care of where the material comes from, if I want to exchange it between virtual machines via RMI or similar? - Is there anything in
BufferedImage that gives a strong technical reason against BufferedImage implements Serializable ? I looked at the source code and I don't think so.
I checked if the error database already contains an entry for this, and I could not find anything related. So, this is your chance to contribute and suggest a feature request through the error database. http://bugs.java.com/bugdatabase/
As a workaround, you can take a look at the implementation of readObject() and writeObject() in the javax.swing.ImageIcon class. ImageIcon Serializable . Perhaps you can wrap the BufferedImage in ImageIcon for your use case or otherwise provide the logic from ImageIcon.readObject() / ImageIcon.writeObject() .
source share