Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I send an image from server to client?  RSS feed

 
Felipe Ruiz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm developing a project for college. It's supposed to simulate a client/server electronic ballot box. When the user chooses the candidate, a picture of the candidate is supposed to appear on the screen. My problem is that the picture is chosen on the server and needs to be shown in the client. I've already googled it and I came across one piece of code that, when built apart from my project, worked just fine. I had trouble trying to mix it with my project. The code is a modified version of the one in this link: http://www.guj.com.br/posts/list/57228.java#300954

So, does anyone know how do I send the image?
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is the image stored on the server? As a file? Then you can transfer the contents of the file first, then create an image out of it on the client side. ImageIO.createImageInputStream can turn the InputStream for the file into an ImageInputStream, which you can pass to ImageIO.getImageReaders. From the result you can read a BufferedImage.
 
Felipe Ruiz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it's stored as a file. What do you mean by transfer the contents of the file first?
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably by socket communication or something similar. You know, byte by byte or byte[] by byte[].
 
Felipe Ruiz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using socket communication. I have already tried using ImageIO read() and write() methods and ObjectInputStream/ObjectOutputStream readObject() and writeObject() methods. I'm not onl sending the images though. I send the file with the candidates info and it goes just fine. When it reaches the part of sending the images it stops.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!