title: Java - Serializable Image is black when transferred over sockets
body: <p>I am sending Images through sockets in Java, and when both client and server are on one computer all is well, but when I run it over LAN, the resulting image is black. I take an image of the screen with the Robot class, then scale it down with AffineTransform.
  Client code:</p>
  
  <pre><code>        BufferedImage s = null;
          socket = new Socket("AJ-PC", 4444);
          out = new ObjectOutputStream(socket.getOutputStream());
          Robot r = new Robot();
          while(true) {
                s = r.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
                double scale = 0.75;
                int w = (int) (s.getWidth() * scale);
                int h = (int) (s.getHeight() * scale);
                BufferedImage outImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);                
                AffineTransform trans = new AffineTransform();
                trans.scale(scale, scale);
                Graphics2D g = outImage.createGraphics();
                g.drawImage(s, trans, null);
                g.dispose();
                Thread.sleep(400);
                out.writeObject(new SerializableImage(outImage));
         }
  </code></pre>
  
  <p>Server code:</p>
  
  <pre><code>        server = new ServerSocket(4444);
          socket = server.accept();
          System.out.println(socket);
          in = new ObjectInputStream(socket.getInputStream());
          while(running) {
              bi = (SerializableImage) in.readObject();
              b = true;
              System.out.println("new");
              panel.repaint();
          }
  </code></pre>