• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

How to send image over a network

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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[].


Dale
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

Server.java

Good luck!
 
What's gotten into you? Could it be this tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic