Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #1373

Re: inheriting BufferedImage and using ImageIO.read()

From markspace <-@.>
Newsgroups comp.lang.java.help
Subject Re: inheriting BufferedImage and using ImageIO.read()
Date 2011-11-20 13:02 -0800
Organization A noiseless patient Spider
Message-ID <jabpsu$rcp$1@dont-email.me> (permalink)
References <4ec8ebc3$0$8437$426a34cc@news.free.fr>

Show all headers | View raw


On 11/20/2011 3:57 AM, mx wrote:
> So, I have a SubImage class which extends BufferedImage and I would like
> to use ImageIO.read() to create a SubImage, but since it returns a
> BufferedImage, I can't find a way of doing that.
> Should I be using another design?


In all seriousness, probably.  We'll need to know a lot more about your 
design and requirements, but it very probable you've subclassed 
BufferedImage here unnecessarily.


>or is there a way to get past this
> problem?


Add a constructor for SubImage that creates a SubImage from a BufferedImage?

public class SubImage extends BufferedImage {

   public SubImage() { ...// no argument ctor

   public SubImage( BufferedImage bi ) { ... // add this

...


>  Yet downcasting causes an exception.


Yup.

Back to comp.lang.java.help | Previous | NextPrevious in thread | Find similar


Thread

inheriting BufferedImage and using ImageIO.read() mx <mx@nomail.com> - 2011-11-20 12:57 +0100
  Re: inheriting BufferedImage and using ImageIO.read() Lew <lewbloch@gmail.com> - 2011-11-20 08:11 -0800
    Re: inheriting BufferedImage and using ImageIO.read() "John B. Matthews" <nospam@nospam.invalid> - 2011-11-20 15:27 -0500
  Re: inheriting BufferedImage and using ImageIO.read() Roedy Green <see_website@mindprod.com.invalid> - 2011-11-20 12:41 -0800
  Re: inheriting BufferedImage and using ImageIO.read() markspace <-@.> - 2011-11-20 13:02 -0800

csiph-web