This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, Since the BufferedImage class does not implement the Serializable interface, how can i send an image over a network, say using RMI. Since i am a bit (or maybe a byte) weak in graphics, the question may be too simple. I would be grateful if someone could give me the name of a book to make swing, 2d graphics strong. Garry
Garry, I think you can go from BufferedImage to a Raster with getData(). From the Raster you can call getDataBuffer(). The DataBuffer class is abstract, so you have to find out (or already know) which subclass you really have. getDataType() on the DataBuffer can tell you that. If your DataBuffer is DataBufferByte, for instance, then you could get an array byte by calling getBankData() on the DataBufferByte. Then you have the data as primitives. There is an online Programmer's Guide to Java 2D at: http://java.sun.com/products/jdk/1.2/docs/guide/2d/spec/j2d-title.fm.html Before the 2D API, the David Geary book "Graphic Java" was very good. I have not read the later editions. Look for user reviews at online book sellers. HTH, Joe
Depending on what you want to do with the image you could convert the BufferedImage into some other format. In jdk1.2 and 1.3 there is a package called com.sun.image.codec.jpeg that can encode your BufferedImage into a JPEG. This image can be sent via RMI. On the other end, you can use this image as is or use the JPEGImageDecoder class to create a BufferedImage from the transported byte.
This is a client and server I made to transfer any kind of file to anothe computer over a network. It is really rough and REALLY limited and all command line based. But it might give you an idea. Client.java