Hi Eric,

Object.clone() implements a shallow copy.  The object itself is
copied along with its references to other objects, but those other
objects that are referenced are not themselves copied.  Since the
BufferedImage is essentially just a pointer to a raster and a
colormodel, all you've done is create another object pointing to
the same raster and colormodel.  You will need to make a copy of
the raster itself in order to avoid drawing into the same buffer.
(Making that copy is more than just cloning the Raster object which
is itself just a pointer to a bunch of other related data - you
eventually have to get down to the databuffers and make copies of
their Java arrays...)

One idea would be to implement clone by creating another BufferedImage
of the same width, height and type and then drawImage the current
BI into the new one to initialize it.

                                ...jim

=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 2D Home Page: http://java.sun.com/products/java-media/2D/

Reply via email to