------- Additional Comments From sven at physto dot se 2005-06-01 08:06 ------- Ok, in light of my reworking of GtkImage, I should add some thoughts here:
- GtkImagePainter is gone. GtkImage now does its own drawing, and wraps a GdkPixbuf. - ImageObserver use is pretty much elimated for GtkImage use now, although it should be reintroduced for animated gif support. This can probably be done nicely within the GtkImage class without involving other stuff. - GtkImage should probably be kept to a small extent even in the future, if only for internal Component usage. (I'm thinking about animated-gif support for ImageIcon buttons for instance) - Component and Toolkit.createImage can create two kinds of images, either from a file (essentially immutable), and drawable (createImage(int, int)). The latter should definitely become a BufferedImage with Graphics2D. (as BufferedImage is drawable and its getGraphics() method should return a Graphics2D object) The former should probably be implemented on top of ImageIO in the future. Although the question remains if that'll make things a bit too complicated for animated gifs? - the Graphics peer now supports drawing BufferedImages (although slowly) through the ImageProducer/Consumer interfaces. This should give us a chance to get BufferedImage working at least to some extent. Sketching out a BufferedImage strategy: - The goal is to draw BufferedImages and be able to draw *to* BufferedImages fast. That means no copying or converting pixel data on these operations. If we have to choose one, it should be the latter. Copying image data after every drawing operation would be costly indeed. - User-defined ColorModels are allowed. So the former goal can never be realized fully. Realistically, we should aim for the predefined BufferedImage types. - In other words, we need to differentiate our BufferedImage drawing code for the predefined types, and others. - Storing the image data in Javaland memory space will make data copying necessary, since it can be relocated by the VM. BufferedImage memory must be natively allocated then. - This makes me belive that wrapping these native memory buffers is what java.awt.image.DataBuffer is for. So our current implementation wrapping java arrays is wrong. - Currently, Cairo only seems to support RGB-24 and RGBA-32 color models. We really need it to support all predefined BufferedImage types. (or face copying and converting pixel data on every draw operation) - The easiest starting point for implementing all this should therefore be BufferedImage.TYPE_4BYTE_ABGR. - I still have no good idea how we should handle drawing to a BufferedImage with a user-defined color model and pixel storage. Although I'm not sure this is an important case either. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20630